-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
PEP 751 pip lock
command
#13213
base: main
Are you sure you want to change the base?
PEP 751 pip lock
command
#13213
Conversation
0b02620
to
914bd0b
Compare
Nice. I would love to help with making it happen (of course it depends on PEP 751 to be approved). We are currently doing our own custom and pretty "poor" implementation of locks with cosntraints in Airlfow and having a "standard" way of reproducible installs would be a great thing. Not sure what is the status now of the PEP and whether it has a chance to be approved soon, but that looks really great that we are trying to standardise it now. |
I appreciate this is draft, but some small early feedback. Firstly, I am advocating for an "output file" option. Writing pip's output to a file in other commands has several footguns, e.g knowing the correct flags to turn off non-relevant output, determining if pip hit errors or warnings when you do, and writing non-UTF-8 files when you direct standard out from powershell on Windows. pip-compile (and uv pip compile) solve this by having an output file option which is considered best practice to use. That said, I don't know the history of why other commands don't offer this, perhaps it's non-trivial.
I agree, I think pip should start as limited as possible around known difficult issues, and expand from there. This will give the chance for the lock API to evolve, if able. |
Cool. I did some early PoC work on the PEP, but things have evolved drastically since then, and I never got back to it. But one of my goals was always for the pip installation report format to be easily convertible into a lockfile. Another thing I'd like to see pip implement (I may well get round to this myself, in due course, it's not a request for someone else to pick it up!) is I'd very definitely aim pip at solely producing "environment reproduction" lockfiles, and not cross-platform ones. To that end, I think that disallowing the I don't have a strong opinion on the question of an
The PEP is in its final stages before being submitted for pronouncement. At this point, it's extremely unlikely that any major changes will occur. Speaking as the PEP-delegate, I can say that I've been heavily involved in the discussions on the PEP, and I'm confident that it has a good chance of being accepted2. Footnotes
|
I think a pre-requisite for that is PEP 710 |
I'm fine with this being in a follow up PR if there are non-trivial questions to answer. Though looking now at the PEP I do think a pedantic reading of it would be that the data should only ever be written as a file and not outputted as stdout as that would technically violate those same file name specifications 😉. (If not made clear by emoji I think that's terrible and that stdout should absolutely be an option at least). |
🙂 I wasn't trying to be pedantic, just noting the likelihood that someone would ask the question about validating the filename. Getting the encoding correct by using the |
914bd0b
to
a29a039
Compare
I choose not to emit Also, I choose to emit a relative path for |
d124afc
to
4b4f84a
Compare
0333893
to
ef393e6
Compare
It could be dynamic, so not emitting it is a better default. In the future we could consider emitting it when we know it is not dynamic.
ef393e6
to
f77d21c
Compare
Now that PEP 751 is accepted, let's see if we want to move forward with this A few questions I have:
|
+1 from me. I think the CLI is good (we can make changes later if needed). I agree, let's not emit Let's not worry about inlining for now. Layout is an area where there are a number of possible options, and I imagine tools will ultimately converge on an approach that provides good readability/auditability and easy generation. It's possible that someone could even produce a dedicated lockfile writer module. I'd rather we stuck with something simple, and with a smaller new library to vendor, until we have a better feel for where the community is going here. |
Good, I'll see if I can add some tests in time for 25.1. Except for the absence of tests (and docs?), this is ready to review. |
I've added the 25.1 milestone, but if you don't have the time (we're about 2 weeks away from the release) feel free to reassign to 25.2 or just remove the milestone. |
I haven't reviewed the PR at all, but if we're going to land this feature for pip 25.1, would it be beneficial to mark this new command as experimental like |
+1 to marking this as experiemental. |
Question: this PR implements a command that generates a lockfile, but what about installing from a lockfile? Would this be by way of Naïvely, I wonder if it may be possible (or even preferable) to overload |
No-one has yet implemented a |
I added the documentation pages, and an experimental warning. |
We should probably document that the generated lock file is not portable across platforms or Python versions, except in simple cases. |
This is a
roughPoC for apip lock
command that writes PEP 751 compliant tomlto stdout.Use with:
pip --quiet lock -o - .
to lock the local project to stdout.pip lock -e .
to lock the local project in editable mode topylock.toml
I wrote this mainly as a way to better understand the PEP.
A few comments:
pip install --dry-run --ignore-installed
, with mostly the same options.environments
,requires-python
,packages.marker
.--only-deps
option (Add--only-deps
(and--only-build-deps
) option(s) #11440)