-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add PWD to sys.path as part of the PEP 517 build #1642
Comments
I am amenable to this change, but I think if we start messing around with Given that you need to opt in to using PEP 517, we have an opportunity now to decide what we want the semantics to be, rather than trying to maintain the existing semantics. What are the downsides of requiring that setup.py be more explicit about where it's importing from? I suppose adding to the difficulty of migration is one. |
That's not the case, hence the swift response to the pip-release, see https://github.com/pypa/pip/labels/C%3A%20PEP%20517%20impact |
Maybe I'm wrong, but this should only be affecting projects that have added |
I’ll note that this affects any project with a For example, I have a project that uses a |
https://github.com/altendky/tempexample/tree/82bd123917bedce24b7e19acbfc4a289f681ca28 There's a pretty minimal example showing the success without Click to expand log
|
For reference—here’s the thread discussing how a https://mail.python.org/archives/list/[email protected]/message/4QWJJAPLH7HECEMOPUFVFX35VVR5MJ4L/ |
Hm, if I also do not want to break anyone who has deliberately removed PWD from their |
The old code path (before PEP 517) in pip I’ll try to find some time to come up with something today. |
While working on this, I realise I am personally against the practice of importing the module in setup.py. This kind of runtime-dependent setup is fundamentally at odds with the recent move to declarative build systems, and is a very common source of breakages in environment-agnostic tools (e.g. Pipenv). I kind of wish this can be an opportunity to push people away from this. |
@uranusjr I agree, I think it's a bad practice to import the module being installed from its PEP 517's Build Environment section specifies nothing about an environment should be assumed except that the dependencies declared in |
Yeah, this was my thinking when I thought PEP 517 was opt-in, but at this point I think we are stuck with the existing semantics at least for a while, unless we can switch PEP 517 into being opt-in. If anyone can think of a way to detect this reliance so that we can deprecate it (possibly some sort of import hook?), I'd like that. That said, this is also a problem for things other than importing the module you're trying to install. People may have build scripts that live alongside
If this is the case, I'd prefer to solve it with |
I’ve submitted a PR in #1643. A few observations: First of all, the build backend is already run in the “correct” directory, i.e. where
But here’s what you get in a pip-invoked PEP 517 backend:
This is why the to-be-installed module cannot be imported in setup.py. I did not read pip’s PEP 517 implementation, but this is likely intentional, and with a good reason (it makes sense intuitively—isolation). For Setuptools specifically, however, I agree that we’re probably stuck with the current semantics. The proposed change in the submitted PR only patches the PEP 517 interface to mimic the common |
@uranusjr Yes, that makes sense. The discussion is now happening across two tickets, which is kinda unfortunate, but in the If we can get |
Cross-posting from the pip issue: I also implemented this as a separate package so package maintainers can apply the work around immediately. |
It isn't affecting all projects that have added build-backend to their pyproject.toml either. I have a whole suite of packages declaring |
@jaraco it is only affecting projects that also import their own packages in Pendulum has a directory structure that looks like:
However, at runtime, $ pip install pendulum==1.5.1
['/home/hawk/.virtualenvs/tempenv-734a94685113/bin', '/home/hawk/.virtualenvs/tempenv-734a94685113/lib/python37.zip', '/home/hawk/.virtualenvs/tempenv-734a94685113/lib/python3.7', '/home/hawk/.virtualenvs/tempenv-734a94685113/lib/python3.7/lib-dynload', '/home/hawk/.pyenv/versions/3.7.1/lib/python3.7', '/home/hawk/.virtualenvs/tempenv-734a94685113/lib/python3.7/site-packages', '/home/hawk/git/pip/src', '/home/hawk/git/setuptools']
Getting requirements to build wheel ... error
...
Complete output from command /home/hawk/.virtualenvs/tempenv-734a94685113/bin/python /home/hawk/git/pip/src/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpy5g2z_86:
['/home/hawk/git/pip/src/pip/_vendor/pep517', '/tmp/pip-build-env-ufcjvf_c/site', '/home/hawk/.virtualenvs/tempenv-734a94685113/lib/python37.zip', '/home/hawk/.virtualenvs/tempenv-734a94685113/lib/python3.7', '/home/hawk/.virtualenvs/tempenv-734a94685113/lib/python3.7/lib-dynload', '/home/hawk/.pyenv/versions/3.7.1/lib/python3.7', '/tmp/pip-build-env-ufcjvf_c/overlay/lib/python3.7/site-packages', '/tmp/pip-build-env-ufcjvf_c/normal/lib/python3.7/site-packages'] If you check And then again in the called function: https://github.com/pypa/pip/blob/e5f4bbb7ddff87f48f2b5815513e4211ccdde83a/src/pip/_vendor/pep517/_in_process.py#L48 You'll notice that the parent directory of the All of this is to say, when The simple fix is to just add |
I think at this point we should go with the But yeah, in |
That seems good to me -- just to clarify -- (this may be rehashing what's been discussed) does that mean independently determining if the project has enabled pep517 even if pip has called for a pep517 build? |
No we won't be messing around with the PEP517 build, just providing two backends: the "legacy" backend, which will attempt to maintain the semantics of invoking |
so for projects where a |
Does this mean that |
This is part of the solution to GH pypa#1642, it is a backwards-compatibility backend that can be used as a default PEP 517 backend for projects that use setuptools but haven't opted in to build_meta.
This is part of the solution to GH pypa#1642, it is a backwards-compatibility backend that can be used as a default PEP 517 backend for projects that use setuptools but haven't opted in to build_meta.
(on mobile) My understanding of @pganssle's proposal is: When there's a pyproject.toml without a build-backend, it'll result in a build with the "legacy" backend, with This needs a pip update and addition of the legacy backend in setuptools. I don't think this needs a PEP update since a different backend could choose different tradeoffs - in this case setuptools itself providing 2 backends. The current opt-in to the lack of a '' in sys.path is the presence of pyproject.toml. The future opt-in would be explicitly setting the build-backend to Fun Fact: My phone autosuggests "setuptools.build_meta" on typing "setupt" |
FYI - most of the discussion is happening on pypa/pip#6163 and let's keep the discussion on pip's tracker in the interest of keeping discussions in one place. |
This is part of the solution to GH pypa#1642, it is a backwards-compatibility backend that can be used as a default PEP 517 backend for projects that use setuptools but haven't opted in to build_meta.
This is part of the solution to GH pypa#1642, it is a backwards-compatibility backend that can be used as a default PEP 517 backend for projects that use setuptools but haven't opted in to build_meta.
Closed in #1652 |
in reference to this: pypa/pip#6163
The text was updated successfully, but these errors were encountered: