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

Consider python specific options via --pip-args #1898

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

atugushev
Copy link
Member

Contributor checklist
  • Provided the tests for the changes.
  • Assure PR title is short, clear, and good to be included in the user-oriented changelog
Maintainer checklist
  • Assure one of these labels is present: backwards incompatible, feature, enhancement, deprecation, bug, dependency, docs or skip-changelog as they determine changelog listing.
  • Assign the PR to an existing or new milestone for the target version (following Semantic Versioning).

@atugushev
Copy link
Member Author

atugushev commented Jul 1, 2023

This allows targeting specific Python versions:

$ echo click | pip-compile - -qo- --no-header --no-annotate
click==8.1.3

$ echo click | pip-compile - -qo- --no-header --no-annotate --pip-args='--python-version=3.0.0'
click==6.7

cc: @mitsuhiko

@chrysle
Copy link
Contributor

chrysle commented Jul 6, 2023

Looks good, but this will need a test.

@chrysle
Copy link
Contributor

chrysle commented Oct 20, 2023

@atugushev This would need merging for the feature worked on in #1998. Could you add a test?

@atugushev
Copy link
Member Author

@chrysle I'm inclined to close this, as is may not work as expected.

@chrysle
Copy link
Contributor

chrysle commented Oct 31, 2023

@atugushev Could you elaborate on that?

@georgek
Copy link
Contributor

georgek commented Nov 12, 2023

@atugushev would love to know more about what you don't think would work as expected. I was looking to build upon this to enable the correct default behaviour of pip-tools when installed by pipx or as a system package etc.

@chrysle
Copy link
Contributor

chrysle commented Mar 6, 2024

@atugushev Gentle ping.

@atugushev
Copy link
Member Author

My initial intent was to target a specific Python interpreter. I thought --python-version was the solution. However, it is only used for wheel and "Requires-Python" compatibility checks, as stated in the documentation:

$ pip install --help
...
  --python-version <python_version>
                              The Python interpreter version to use for wheel and "Requires-Python"
                              compatibility checks. Defaults to a version derived from the running
                              interpreter. The version can be specified using up to three dot-
                              separated integers (e.g. "3" for 3.0.0, "3.7" for 3.7.0, or "3.7.3").
                              A major-minor version can also be given as a string without dots (e.g.
                              "37" for 3.7.0).

I know there is a --python <python> option, however it runs pip in a subprocess which doesn't work well with the pip-tools resolver.

@georgek
Copy link
Contributor

georgek commented Mar 8, 2024

It sounds like this approach might be ruled out for the purposes of #1998 then. But just for my own curiosity and perhaps to help others look for this:

What difference is there in practice between targeting a specific interpreter vs specifying --python-version?

What is the problem with pip-tools and --python? Could pip-tools be changed to work better with this option?

@chrysle
Copy link
Contributor

chrysle commented Jun 25, 2024

What is the problem with pip-tools and --python? Could pip-tools be changed to work better with this option?

I think @atugushev refers to the problem that we too heavily rely on pip's internals; it doesn't help us to pass the Python option to pip, as we create a command representation manually via the corresponding InstallCommand only to utilize it to parse and return the options to us, and then invoke the resolution process manually – which means our setting doesn't have any impact on the actual resolution result. In order to benefit from the option, we would instead need to run pip and parse its results, as done for pip-sync. There is an open issue for that (#1654) but actually decoupling would require huge changes; I can look into it, but won't promise anything, especially since activity here has been largely reduced by most maintainers and uv is likely to kick us totally out of business (no hard feelings).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants