-
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
Compatibility with uv and relative imports #12597
Comments
Package metadata ( You would be better building the 2 projects independently, and then installing them from wheels, with the dependency being given using the dependency name, rather than with a path. |
Yes, I agree. That is the right way. I can see how relative imports may be harmful. But for historical reason we have a logically single package which is split between local directories. If it is ok Is it possible at least set PROJECT_ROOT variable? P.S.: after some trial and error we got a working solution with an absolute path astral-sh/uv#2635 (comment) |
SUpporting this in package metadata does not sound right to me. It makes sense if the package is installed in the specific way you described, but the format is also used in other scenarios, e.g. when the metadata is packaged into an sdist or wheel—arguably the main use case_—where the feature would not only not make sense, but produce either confusing or bad results. It would be preferrable to me if this is only allowed specifically for things that can’t be packaged into those formats. See #8828 (which unfortunately I failed to carry out). |
No, because if we did that people would rely on it for all sorts of things (that we can't necessarily anticipate). And given that we're talking about having that environment variable in the published metadata of a wheel, this could cause problems in all sorts of other contexts. Why does uv set |
I found its usage in some issue After blaming the code I found a commit which references other tools |
OK, I don't think pip will support this unless it becomes a standard (and personally, I don't think a proposal to standardise it would succeed, but that's a separate matter). |
I would add that uv’s reimplementation on pip’s environment variable expansion seems to not be exactly feature-compatible. As far as I am aware, pip only expands environment variables in requirements and constraints files (which |
What's the problem this feature will solve?
Hi! I searched for related issues and found none.
I am trying to make a setup.py which works with both pip and uv. But I have a relative import which can be worked around in different ways for pip and uv. More at astral-sh/uv#2635
I wish for more straightforward interop and I believe the asked feature would help pip itself.
Describe the solution you'd like
To set the PROJECT_ROOT variable automatically before evaluation setup.py or support relative imports without https://peps.python.org/pep-0440/#direct-references
Alternative Solutions
I have a workaround but it has a condition based on an undocumented feature of uv.
See astral-sh/uv#2635
Additional context
I can try to make a pull request if you are ok with one of the solutions.
Code of Conduct
The text was updated successfully, but these errors were encountered: