Respect .python-version in pip-compile#14624
Respect .python-version in pip-compile#14624staticf0x wants to merge 3 commits intoastral-sh:mainfrom
Conversation
8fdd21d to
0507b50
Compare
|
Let's say my project supports Python 3.9+ but I build my project with Python 3.12, so I have a ".python-version" with 3.9 on the root and a ".python-version" with 3.12 in "build-project" sub directory. Now because I pin my build requirements I call This change will break that, so at the least it should be called out as a breaking change to pip-compile and the behavior should be documented. The reason I have all these ".python-version" files floating around is to get dependendabot and other tools to know which Python is a good Python to default against, not to assist uv. |
|
I think inferring the
Wouldn't (or couldn't) we still prefer the current Python version in the environment over a |
You could, I would prefer it, but does it solve what OP wants? (Genuine question, I don't know). |
|
So we're running self-hosted Renovate with a Docker image with default Python 3.9 and while there are other Python versions available, because it's not the official Ubuntu based image, we can't install tools on the fly when processing repositories. Now instead of relying on The support for Anyway, when you run Renovate with the I do realize this implementation is a bit flawed, so I definitely appreciate the discussion here. Hopefully my explanation avoids the XY problem and perhaps there's a way to solve my problem without this code change (that would be great though). Just mind that setting And only now I realized I can pass the Python version in the compiled file header and Renovate will parse it and pass it back to So this actually solves my use case, sorry for the confusion! I don't mind closing this PR, do you think this discussion is still helpful though? Or should we stick to #9581? |
|
Thanks for all the details! I'm glad just including it in the header solves the problem. That makes sense as a best practice to me anyway. I think #9581 is the best place for future conversation on this, yeah. |
Summary
This is an attempt to make
uv pip compilerespect.python-versionfile as reported in #9581.The problem at hand is more complex than I anticipated, because you can specify multiple source files, which makes it difficult to "guess" where the
.python-versionmight be. I chose this approach:.python-versionin cwd (for simple invocations likeuv pip compile requirements.in)I am more than open to suggestions how to make this better, though, it doesn't feel exactly right.
Test Plan
Given this
requirements.in:and
.python-version:3.11My machine has Python 3.9, 3.11, 3.12 and 3.13 (default) installed. When I run
uv -v pip compile requirements.inbefore this PR, I get:and after this PR:
and the output
requirements.txtbefore:and after:
This is also reflected in the unit tests.