-
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
pip should read configuration from pyproject.toml
for local projects
#13003
Comments
pyproject.toml
for local project specific pip configurationpyproject.toml
for local projects
Without opt in this can be abused |
Can you expand, this approach is already being used by other front end package tools such as uv, rye, poetry, hatch, etc. |
Yeah. I think it's a good idea to add "pip frontend" configuration options for When it comes to security/abuse - the only thing I see where It could be abused is when some external "tooling" (IDE's mainly) would automatically start using it and use it in some kind of security-related scenario. I think that could be mitigated by only adding configuration that is not "security-scenario-sensitive" to be handled by |
Also just to add a concrete "positive" scenario - I can imagine it would be super useful to have private package registries configured in |
For abuse, how about a sdist that included an index URL in its |
Yes, I see that there are some potential "sensitive" properties, but I'd argue if those are declarative parameters are made part of published standard (and maybe even finding some way to mark such options are sensitive) it's far easier to make audit tools to support it, than for example analyse "hatch_build.py" code that can be triggered automatically by just adding "hatchling" as your build tool. So I'd argue that increases the "auditability" rather than decreases it, because declarative specification is far easier to audit than dynamic python code (which is currently already supported). |
This proposal is for local projects, not packaged ones, so this scenario wouldn't apply. And yes, sdists can already run arbitrary code, including calling pip with any any arguments. |
Sorry, I'd missed that. How would it work then? Would pip have to change its config settings mid-run, when it detected that it was installing from a local project? How would something like The point here is that pip currently reads its config at startup, which is before it's determined what (if any) local project(s) are being installed. So this would be a significant change to pip's config handling, to change it dynamically, during a single run. I'm -1 on this as it stands. But I understand that it's a placeholder for someone who's interested in this feature to make a fully-specified proposal, so maybe it would be better to say that I doubt that it will be possible to come up with a satisfactory proposal for this. |
I would suggest that we take a look at existing tools that already face this problem, e.g. uv, rye, poetry, hatch, etc.
Perhaps this restrictions means that pip will only take the settings once, and by default from the immediate current working directory. I'm not sure, I agree it is an important design choice to anyone who wants to take this on, thanks for bringing it up. |
Very good points @pfmoore - indeed thanks for bringing it up. I agree, this sounds like pretty complex one to pull off in a reasonable fashion. And looking at the complexities involved, it is quite an investment (and I also started to doubt if it is worth it at all). By looking at https://docs.astral.sh/uv/configuration/files/ for example, they are merging configuration from uv.toml and pyproject.toml, but it's already pretty unclear how it works, I can immediately think of a number of edge-cases that are not really straightforward to handle. Side comment - now when I think of it, from the "philosophy" of the way how I understand packaging works - in this case the I think one of the big benefits of the "frontend/backend" split is that (ideally) project maintainers choose the backend and appropriate backend configuration in the "tool" section - so that their projects can be build reproducibly in local case regardless from the "frontend" anyone uses. And "frontend" configuration should be entirely driven by other means - and should be really "optional", so having it in "pyproject.toml" somewhat mixes the two. Probably in this case better to keep frontend configuration in a separate file to make a cleaner split - even if you want to provide some defaults for certain frontend. |
That was the original intention. Unfortunately (or fortunately, depending on your point of view!) tools other than build backends found the idea of a single file for all configuration very tempting, and so we ended up in the current situation. But you're right - I don't think
If you can produce good, reproducible bug reports, I'd strongly encourage you to submit them to |
I agree the rules of precedence and merging need to be well defined. Though I would point out that pip already faces similar problems, as it merges it's own configuration files from system directories, user directories, site directories, environmental variables, and CLI. For example, on Windows does |
Oh absolutely - I already work closely with Also they responded to our idea of how Airflow is structured and implemented the This comment: astral-sh/uv#3404 (comment) is that they modelled their solution on. So yeah. I am already doing it. |
What's the problem this feature will solve?
Increasingly users expect tools to be able to read from their
pyproject.toml
for their local project. At this point pip stands as an outlier in not being able to define pip configuration inpyproject.toml
.Describe the solution you'd like
When installing a local package that has a
pyproject.toml
check for a section[tool.pip]
and prioritize any configuration there as more important than configuration in environmental variables or configuration in the users environment (e.g. system directory, user directory, venv directory), but not as important as configuration passed on the command line.Alternative Solutions
Do nothing
Additional context
This ticket is created to track this feature and point issues that require it to here. I think this would require a lot of design choices and I am not volunteering to lead it. But perhaps someone else might be sufficiently motivated!
Some immediate design choices that come to mind are:
pyproject.toml
configuration in[tool.{tool-name}]
also offer{tool-name}.toml
configuration, would pip want to also read from a dedicatedpip.toml
?pip.toml
should it be possible to use apip.toml
in all the current places pip allowspip.[conf|ini]
and in which case would it be the recommended format going forward?Code of Conduct
The text was updated successfully, but these errors were encountered: