-
Notifications
You must be signed in to change notification settings - Fork 3k
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 723 support #12891
Comments
I feel that this is a reasonable request, although personally I consider it to be a suboptimal use of inline script metadata - the point of that data is for a tool that runs the script to transparently manage the environment the script runs in. Manually managing the environment with pip is not the intended use and I wouldn’t want to see it become a common pattern. Having said that, if someone wants to submit a PR, I wouldn’t object. It’s not a feature I intend to work on myself, though. |
I'm willing to dabble into this. |
I'm not sure what part of the pipx code you're thinking of. Parsing the PEP 723 metadata uses the code from the PEP itself, I believe, so it'll be the same code wherever you take it from. Most of the rest of the pipx code is about managing virtual environments, which is not suitable for pip. The "fun" bit of this would likely be around designing the UI. Would the new I don't want to over-complicate the problem here, but I'd strongly encourage you to think about the design, rather than hoping to just copy/paste some code from another project. A bit of test-driven design, where you start by writing some tests to exercise the behaviour you want, and then write code to implement it (and hence "fix" the tests) would be very useful here, IMO. |
Thinking about this issue again. I agree with Paul that the venv part of this is not
I don't really see any reason to exclude
That's the way I read the PEP. It's not quite a requirement, but it does say that this
That's an interesting question. I can see a case for ignoring
+1, I think implementing this is going to require the kind of motivated design from where |
Making a note here that the implications of this feature for Edit: from a minimal draft I spent the last few hours putting together, it looks like functionality for those commands is "free" inasmuch as the commands that build requirement sets all get this functionality via |
A use case for this which I've come across is AWS lambdas where you want to install your dependencies to a specific folder so that you can then zip it up with your script. Allowing pip to read the dependencies from the inline script metadata means you don't need an extra requirements file, and that you can separate your runtime dependencies from your development dependencies. |
What's the problem this feature will solve?
This feature request represents support for installing the requirements of a single-file script with inline metadata (PEP 723) using
pip
.Pessimistically assuming that this feature request is rejected, this issue is also being filed as a home for a specific record of the maintainer rationale for not including this functionality in
pip
.Describe the solution you'd like
I am imagining functionality that would be similar to the existing
--requirement
argument, with a suitably distinct name to indicate that the metadata format is the one defined by PEP 723 and the living PyPA spec.Perhaps something like:
Where the
pip install
invocation is equivalent topip install "requests<3" "rich"
if therequires-python
bound is satisfiedAlternative Solutions
I know that other tools¹ in the Python packaging ecosystem do support PEP 723, but these tools are not "included batteries" nearly as often as
pip
is. In my estimation, supporting in-line metadata inpip
will improve the experience of many users (especially non-programmers) who just want to run a script they've been given and are starting with a "typical" bare Python environment.¹non-exhaustive list:
pipx, hatch, pip-run
Additional context
The reference implementation for parsing inline metadata seems to be enough to retrieve the list of requirements from a file. I imagine that the result of this can be plumbed into existing machinery used for satisfying dependencies listed in requirements files.
It's worth mentioning that there is a potential argument for allowing multiple scripts to be parsed and installed from in a single
pip
invocation (in the same way that--requirement
can be given multiple times). I think it makes sense but I can see why there might be some reluctance about doing it since it is more or less directly against the grain of the primary "single script" use-case of inline metadata.Code of Conduct
The text was updated successfully, but these errors were encountered: