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

--unsafe-package doesn't normalize hyphens/underscores #2150

Open
ntjess opened this issue Dec 22, 2024 · 3 comments
Open

--unsafe-package doesn't normalize hyphens/underscores #2150

ntjess opened this issue Dec 22, 2024 · 3 comments
Labels
bug Something is not working help wanted Request help from the community needs reproduce Need to reproduce an issue PR wanted Feature is discussed or bug is confirmed, PR needed

Comments

@ntjess
Copy link

ntjess commented Dec 22, 2024

Pip resolves package-name and package_name to the same dependency. However, the unsafe package specifier doesn't take this into account on the latest released version.

Example: pip-compile --unsafe-package opencv_python --no-allow-unsafe still installs opencv-python in the final output.

@webknjaz webknjaz added the bug Something is not working label Dec 23, 2024
@webknjaz
Copy link
Member

Sounds like a normalization issue. Is it still reproducible on main? I think there were some PRs related to normalizing the dist names in the summer.

@webknjaz webknjaz added PR wanted Feature is discussed or bug is confirmed, PR needed help wanted Request help from the community needs reproduce Need to reproduce an issue labels Dec 23, 2024
@webknjaz
Copy link
Member

A good starting point would be submitting a PR with regression tests.

@ntjess
Copy link
Author

ntjess commented Dec 23, 2024

Here's my reproduction:

# in a new environment
pip install "pip-tools@git+https://github.com/jazzband/pip-tools@main"
pip-compile --version
# pip-compile, version 7.4.2.dev87

# tmp.in contains just `opencv-python`
pip-compile tmp.in --no-allow-unsafe --unsafe-package opencv_python

Outputs:

#
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
#    pip-compile --unsafe-package=opencv_python tmp.in
#
numpy==2.2.1
    # via opencv-python
opencv-python==4.10.0.84
    # via -r tmp.in

If you change --unsafe-package to opencv-python, it works as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working help wanted Request help from the community needs reproduce Need to reproduce an issue PR wanted Feature is discussed or bug is confirmed, PR needed
Projects
None yet
Development

No branches or pull requests

2 participants