Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest docker images fail with an ImportError #4163

Open
ravishi opened this issue Jan 22, 2024 · 3 comments
Open

Latest docker images fail with an ImportError #4163

ravishi opened this issue Jan 22, 2024 · 3 comments
Assignees
Labels
T: bug Something isn't working

Comments

@ravishi
Copy link

ravishi commented Jan 22, 2024

Describe the bug

I'm on MacOS. I try to run Black through Docker, but the container promptly stops with an ImportError related to the missing aiohttp dep.

To Reproduce

docker run -d -p 45484:45484 --pull always pyfound/black blackd --bind-host 0.0.0.0
# returns c42cfd39d8047d840beb779ea529005ef4d5682b060bcbca9b154e940bd346ab
docker logs -f c42cfd39d8047d840beb779ea529005ef4d5682b060bcbca9b154e940bd346ab
Traceback (most recent call last):
  File "/opt/venv/bin/blackd", line 5, in <module>
    from blackd import patched_main
  File "/opt/venv/lib/python3.12/site-packages/blackd/__init__.py", line 14, in <module>
    raise ImportError(
ImportError: aiohttp dependency is not installed: No module named 'aiohttp'. Please re-install black with the '[d]' extra install to obtain aiohttp_cors: `pip install black[d]`
  • Black's version: Any tag greater than pyfound/black:23.10.0
  • OS and Python version: [MacOS/14.2.1 (23C71)]
@ravishi ravishi added the T: bug Something isn't working label Jan 22, 2024
@ravishi ravishi changed the title Latest docker images Latest docker images fail with an ImportError Jan 22, 2024
@cooperlees cooperlees added the T: enhancement New feature or request label Jan 22, 2024
@cooperlees
Copy link
Collaborator

Howdy

We've on purpose never built the docker image with the [d] extra dependencies to keep the images as small as possible.

We could add this in - But I want to see what people prefer:

  • Add by default and make the image smaller (I have not calculated the size - But I expect it to be a small different)
    • Simple, but everyone occurs the size increase even if not using blackd
    • Image is currently around 55MB
    • aiohttp wheels seem to be around 1.5MB (but that's zip compressed)
  • Add a dedicated built for a extra [d] install and make new tags
    • A lot more complicated and more things to potentially fix in the future

Thoughts all?

@cooperlees
Copy link
Collaborator

cooperlees commented Jan 22, 2024

Actually, I am wrong, we do try to do the extra install:

https://github.com/psf/black/blob/main/Dockerfile#L13

I will look into it - But if anyone has time, PR welcoming fixing getting aiohttp into the container.

  • I would have expected it to be in the venv we copy over from the build container ...

@cooperlees cooperlees removed the T: enhancement New feature or request label Jan 22, 2024
@cooperlees cooperlees self-assigned this Jan 22, 2024
@JelleZijlstra
Copy link
Collaborator

I haven't delved into the history, but might be worth looking at what we changed in 23.10. Could be a Hatch bug; this reminds me of #4107 which is sort of the opposite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants