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

Unable to install dependency aiohttp using requirements.txt generated by poetry after upgrade to black 23.12.0 #4122

Closed
PrieJos opened this issue Dec 22, 2023 · 2 comments
Labels
T: bug Something isn't working

Comments

@PrieJos
Copy link

PrieJos commented Dec 22, 2023

Describe the bug

Our build pipeline is executing the following command to generate a requirements.txt that will be used to create a virtual environment to execute to the build afterwards:

poetry export --with dev --with-credentials -o requirements.txt

Since our project has black as a development dependency, the file will also contain the dependencies required by black. However since we upgraded to blackversion 23.12.0, when the pipele installs the dependencies using pip install -r requirements.txt, that latter command fails with the following error which looks like it is unable to regenerate a consistent requirements.txt in that new black version:

Collecting aiohttp>=3.7.4 (from black==23.12.0->-r requirements.txt (line 13))
ERROR: In --require-hashes mode, all requirements must have their versions pinned with ==. These do not:
    aiohttp>=3.7.4 from https://files.pythonhosted.org/packages/a0/ed/83c4e2ae68bf31ef28b50fdcbd885792de03e94e4b0587ed08a02095f79a/aiohttp-3.9.1-cp311-cp311-musllinux_1_1_x86_64.whl (from black==23.12.0->-r requirements.txt (line 13))

To Reproduce

  1. Create a project with poetry
  2. Add black 23.12.0 as a dependency to that new project
  3. Generate a requirements.txt using command poetry export --with dev --with-credentials -o requirements.txt
  4. Now tries to create a new Python virtual environment out of the generated requirements.txt issuing command pip install -r requirements.txt.

Expected behavior

We were expecting poetry to generate the requirements.txt consistently and not getting the error above when using that file to install dependencies using pip install -r requirements.txt.

Environment

  • Black version: 23.12.0
  • OS and Python version: official Python 3.11.7 docker image based on alpine -> docker pull python:3.11.7-alpine

Additional context

No additional context.

@PrieJos PrieJos added the T: bug Something isn't working label Dec 22, 2023
@jon88
Copy link

jon88 commented Dec 22, 2023

Is this intended that aiohttp is blacks default dependency

I have a different concern that I am unable to install black without installing aiohttp. To me it seems by pyproject.toml that default installation should not include aiohttp and only pip install black[d] should by dependent on aiohttp and create blackd script.

For example

docker run --rm -it python:alpine pip install black | grep aiohttp
Collecting aiohttp>=3.7.4 (from black)
  Obtaining dependency information for aiohttp>=3.7.4 from https://files.pythonhosted.org/packages/d0/89/5cdbebbdfe91c1f937ef4cc2836152cce0d2a0138029b53703d0c3f13199/aiohttp-3.9.1-cp312-cp312-musllinux_1_1_x86_64.whl.metadata
  Downloading aiohttp-3.9.1-cp312-cp312-musllinux_1_1_x86_64.whl.metadata (7.4 kB)
Collecting attrs>=17.3.0 (from aiohttp>=3.7.4->black)
Collecting multidict<7.0,>=4.5 (from aiohttp>=3.7.4->black)
Collecting yarl<2.0,>=1.0 (from aiohttp>=3.7.4->black)
Collecting frozenlist>=1.1.1 (from aiohttp>=3.7.4->black)
Collecting aiosignal>=1.1.2 (from aiohttp>=3.7.4->black)
Collecting idna>=2.0 (from yarl<2.0,>=1.0->aiohttp>=3.7.4->black)
Downloading aiohttp-3.9.1-cp312-cp312-musllinux_1_1_x86_64.whl (1.3 MB)

Is this intended?

@hauntsaninja
Copy link
Collaborator

This was due to an issue in hatch (the build backend Black uses). Thanks to BryceStevenWilley and cooperlees, 23.12.1 should have this fix. See #4107

@hauntsaninja hauntsaninja closed this as not planned Won't fix, can't repro, duplicate, stale Dec 23, 2023
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