pip-tools: pip==23.3 breaking "extras" behavior
Using pip==23.3.x can result in invalid requirements.txt for projects that declare extras.
A change in pip==23.3.0 introduced the “canonicalization” of extras names:
The canonicalization leads to this outcome:
requirements.in:sqlalchemy[postgresql_psycopg2binary]requirements.txt:sqlalchemy[postgresql-psycopg2binary]
For many cases, this probably isn’t an issue.
psycopg2-binary still makes it into requirements.txt as an individual entry.
For more “niche” cases, the extras still carry some significance. eg. When using rules_python under the Bazel build system, the extras must properly resolve to build out a dependency graph.
Environment Versions
- OS Type: Linux
- Python version:
3.10.9 - pip version:
23.3.0 - pip-tools version:
7.3.0
Steps to replicate
- Create a simple
requirements.infile.
sqlalchemy[postgresql_psycopg2binary]==1.4.47
- Create a virtual environment, install
pip-toolsand the previous majorpipversion, runpip-compile.
python -m venv .venv
. ./.venv/bin/activate
pip install pip-tools==7.3.0 pip==22.3.1
pip-compile --no-strip-extras
- Observe that the resulting
requirement.txtfile listssqlalchemy[postgresql_psycopg2binary](with an underscore).
greenlet==3.0.0
# via sqlalchemy
psycopg2-binary==2.9.9
# via sqlalchemy
sqlalchemy[postgresql_psycopg2binary]==1.4.47
# via -r requirements.in
- On the same virtual environment, upgrade to
pip>=23.3, runpip-compile.
pip install pip==23.3.0
pip-compile --no-strip-extras
- Observe that the resulting
requirement.txtfile listssqlalchemy[postgresql-psycopg2binary](with a hyphen).
WARNING: sqlalchemy 1.4.47 does not provide the extra 'postgresql-psycopg2binary'
greenlet==3.0.0
# via sqlalchemy
psycopg2-binary==2.9.9
# via sqlalchemy
sqlalchemy[postgresql-psycopg2binary]==1.4.47
# via
# -r requirements.in
# sqlalchemy
Expected result
The valid input extras should still be valid in the output.
Actual result
The output extras will not resolve.
About this issue
- Original URL
- State: open
- Created 8 months ago
- Reactions: 3
- Comments: 19 (12 by maintainers)
Commits related to this issue
- Add test: canonicalize_extras Based on the case in #2004 — committed to AndydeCleyre/pip-tools by AndydeCleyre 8 months ago
- Add test: canonicalize_extras Based on the case in #2004 — committed to AndydeCleyre/pip-tools by AndydeCleyre 8 months ago
- Add test: canonicalize_extras Based on the case in #2004 — committed to AndydeCleyre/pip-tools by AndydeCleyre 8 months ago
- Add test: canonicalize_extras Based on the case in #2004 — committed to AndydeCleyre/pip-tools by AndydeCleyre 8 months ago
- Add test: canonicalize_extras Based on the case in #2004 — committed to AndydeCleyre/pip-tools by AndydeCleyre 8 months ago
- Add test: canonicalize_extras Based on the case in #2004 — committed to AndydeCleyre/pip-tools by AndydeCleyre 8 months ago
- Add test: canonicalize_extras Based on the case in #2004 — committed to AndydeCleyre/pip-tools by AndydeCleyre 8 months ago
- Add test: canonicalize_extras Based on the case in #2004 — committed to AndydeCleyre/pip-tools by AndydeCleyre 8 months ago
- Add test: canonicalize_extras Based on the case in #2004 — committed to AndydeCleyre/pip-tools by AndydeCleyre 8 months ago
Thanks! I can now reproduce using the main branch. I can’t confidently say that’s fixed by the mentioned PR, because I didn’t set out to fix that problem, but I am not seeing it there.