-
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 install .
leaves a build directory that is causing issues for some tools
#8165
Comments
Hey @omry, I'm getting a different error message but also coming from the
And getting
It seems to me that version |
In-place builds are new in 20.1, the reason 20.0.2 did not create a |
Presumably the workaround is simply to use the |
Thanks for the quick reply @pfmoore, that's worked on my end! |
Yes, or to use [pytest]
norecursedirs = build |
I think it would make sense to build from the current directory but place the output in a temporary location (assuming whatever is consuming that output can also be adjusted). |
@omry, I've just found out about this and hope you like it too: https://discuss.python.org/t/proposal-adding-a-persistent-cache-directory-to-pep-517-hooks/2303 |
Is there an option to pip to use the temporary location as in 20.0.2? |
This comment has been minimized.
This comment has been minimized.
It's worth noting that this affects more than pytest -- git, docker, linters, IDEs, other test runners, etc. Of course they all have options to ignore a directory, but it's a hassle. It would be better if there was an option (or default) for pip to clean up the build directory after installing. |
@hsharrison, I hope the discussion on IRC yesterday provide you some extra info:
Per my understanding, |
Hmm, so I suppose the solution in Dockerfiles is |
Proposed solution:
|
@hsharrison, that should work for you, assuming you're using |
This is causing style tests to suddenly fail on two projects I'm involved with, which both use a pip install and then run flake8
Strongly agree with this! |
What is the expected behavior of the |
@thetic Seconded @hsharrison seconded this is breaking us for more than just pytest. And we have an entire repo named "build" that doesn't play nicely with this new capability. And it appears the -b/--build option is not honored during creation of the build/ directory.
Yet, passing in any -b/--build value doesn't seem to influence anything. [edit]: Can we get -b/--build to honor input into it? That way we can at least choose the name of the build output directory. |
So setuptools (setup.py) is making the folder when setup.py bdist_wheel runs. Did pip ever build non isolated in a much older version? |
I found another problem caused by this issue: it breaks manylinux builds which are based on the official manylinux demo project. It creates wheels which can't be installed because of ABI incompatibility! The demo iterates over many different pythons and runs
For a minimal example, look at this gist: it runs
This example (and all the travis-based projects which are based on manylinux-demo) still works with If you manually downgrade to I expect that many projects will start to automatically upload broken wheels as soon as they trigger a new travis-based version release, so it's probably better to fix it soon. |
Thanks for all the reports folks! For anyone who hasn't been following this closely, a bunch of related discussion has taken place at #7555 (comment). If you're wondering why this change was made: pip's copy-to-a-temporary-directory-and-build-there logic has been a source of a lot of bugs (performance issues, correctness issues and more) over the years. We made this change to improve the user experience in this area, to solve those issues by removing that band-aid solution for something much simpler and less fragile. With hindsight, I think we pulled the band-aid out a bit too early/quickly. Although we expected there to be some workflows that'd break, we'd expected the breakages would occur in more niche usecases, and not be as broadly affecting as they have been. In summary, this change is being lot more disruptive than we had initially anticipated and we'll be reverting the "build in place" behavior change in a pip 20.1.1 release. We'll be pursuing a different avenues to push build tools to stop making the assumption that we've broken with this change (that they can put whatever crap I want in the package's root directory), likely by collaborating on mechanisms like the one proposed in https://discuss.python.org/t/2303/. |
I'm really curious how folks here, think we should communicate around potentially disruptive stuff like this. We had a beta period for getting feedback on this change, that was publicized an order of magnitude more than we've ever done in the past, and we still got no reports from users that would even hint at how disruptive this could be to their workflows. We've been bitten by these things in the past (like back in 2018, with pip 10.0) and if you have any thoughts or feedback on how we can do communication around changes, and get feedback on those changes, please chime in at #7628. Everything from "here's where I go to look for information, to I don't expect pip to ever change, to I don't look for information ever" is useful input to us. A personal noteI still believe that none of the issues that have been flagged here are "pip's fault" -- they're occurring because other tools (setuptools, pytest etc) are making incorrect assumptions about what the contents of a package directory are, and what they can do with that directory. Obviously, practicality beats purity here, and reverting this change and figuring out a significantly smoother approach is the right thing to do. pip isn't generating the But like, why would tooling not ignore a This feels a lot like #5599 -- Linux distros made an incorrect assumption, and a change in pip exposed that. What happens next? Lots of users reporting errors to pip, instead of their distro, and many Linux distros still don't fix that assumption). I'm starting to really dislike not being able to make improvements to pip because "other stuff" is making assumptions about how pip's internal processes work. |
That's a hard one. One possibility is something along the lines of asking people to explicitly opt into the new flow by introducing a command line flag / config file option. The warning might look like:
|
I am also amazed that the build directory was so surprising. |
As a user, I didn't expect there to be any "building" at all. Just some copying of files into a site-packages dir somewhere. I can understand that there's more going on and that some temporary "build" path is needed, but that still seems like a pip implementation detail to me, and not something users should be aware of? Also I find it very hard to see leaving the dir there instead of deleting it as anything other than a side effect. I'm asking pip to install from a certain source folder into a system: I expect that to modify the system but not the source folder. Thanks for how you've handled this, by the way. All your work on pip makes my life much easier! So just trying to help out with a user's perspective here |
There's always building. People don't expect this for their .py files but it happens. |
So, still curious... what is the point of |
I will say, I think that most or all of the breakages we ran into came up during the PEP 517 as things that were likely to be possible sources of breakages (for example). Maybe we need to do a better job of summarizing these discussions or when making changes related to past discussions going back and reviewing past discussions or something. I've long believed that beta releases for tools like pip are of marginal benefit. When we've tried to do them in the past we've rarely caught many if any issues, even show stopping ones, until a final release was cut. That's why I stopped doing them when I was still releasing pip and instead tried to be available to quickly react to broken releases. Attempting to phase large scale changes in over time is also a good pattern (with many ways to handle it like dark reads, opt in or opt out flags, etc). I don't think "blame" is the most useful thing to focus on. One could easily argue that everything was working fine until pip broke backwards compatibility by no longer ensuring builds were done in an ephemeral location. Unfortunately Python's packaging has hit Hyrum's Law to a pretty large degree, so it's super common that anytime we make any changes to long standing behavior we're going to be breaking compatibility with something. The only real solution to it is to be more deliberate and careful with rollback plans and provide ways to work round etc the more risky a change is, but to fundamentally accept that these things are going to happen as well. |
That's definitely an oversight in this case that didn't help -- its doc-string should've been updated but didn't get updated. :)
should have changed to:
|
(coming back to this, after stepping away for a few days)
Agreed. That was perhaps my frustration speaking, more than anything else.
TIL there's an internet law, for describing this situation!
Hmph. I agree that this is likely the only solution, but... I'll still occasionally get grumpy that we're in this situation. :) |
So, some background work has been done on this front and #2195 (comment) contains a proposal for us to reintroduce this with a better rollout plan. :) Closing this issue since the fix was included in 20.1.1 and that's been out for... months. If you want to follow future updates, please look at #7555 and #2195. :) |
Environment
Description
Build-in-place leaves a build directory in the working directory, which can sometimes confuse tools like pytest when they discover pyc files inside.
Expected behavior
How to Reproduce
Output
The text was updated successfully, but these errors were encountered: