Closed
Description
I open this issue as an attempt to consolidate discussion about out-of-tree builds, the related issues and possible solutions.
What's the problem this feature will solve?
When building projects from local directories, pip first copies them to a temporary location.
This approach has raised a number of issues over time:
- When setup.py / pyproject.toml is not at the root of the project and when the build depends on resources outside of the setup.py / pyproject.toml subtree (pip wheel . does not follow symlinks whereas python setup.py bdist_wheel does #3500, Modify pip build behavior to better support tools like setuptools_scm #7549, PEP 517 isolation breaks test module with relative out-of-source dependency #6276), e.g.:
- build needs resources that are symlinks to files/directories outside of the subtree
- build needs the git repository (eg when using setuptools_scm), and .git/ is in a parent directory not copied to the temp dir by pip
- build relies on the subdirectory name (somewhat exotic maybe, yet I have such as case where I want to create a custom build backend and part of the metadata depends on the subdirectory name)
- Performance issues when the the project directory is large (pip install of a directory is super slow #2195).
Why does pip copy to a temporary directory before building? Caveat: this is unclear to me - here is what I collected so far:
- To avoid relying to something out of source (pip install of a directory is super slow #2195 (comment)) - although the definition of "out of source" is the cause of some issues above
- To avoid polluting the source directory with build artifacts or residues (?)
- Something else?
Possible Solutions
- Build an sdist in place, unpack the sdist in a temporary location, then build from that.
- Add a pip option to build in place.
- Update PEP 517 with some sort of mechanism to let back-ends communicate to front-ends if they are "safe" for in-place builds.
- Change pip to always build in place.
- Change pip to build in place by default with an option to build out-of-tree.
Additional context
More discussion about building via sdist on discuss.python.org.