This focuses on the long-term specification since the desicussion on solutions before it is covered in Pip 19.1 and installing in editable mode with pyproject.toml.
Editable install (before 19.1, at least) works by invoking
setup.py develop. Here is how (Setuptools) make it work, as I understand it (also briefly mentioned here):
- Creates an
.egg-infoin near vicinity of the package (instead of in the target
- Adds an
.egg-linkin the target
site-packages, containing paths to look for the distrubiton’s
- The source’s parent directory is added to a
.pthfile maintained by Setuptools (
easy-install.pth). The listed directories are injected into
sys.pathso the package is importable at runtime.
There are some problems with this implementation, but I think people agree it is “good enough” as a baseline of expectation. Most of the theoretical problems can be worked around in practice without much hassle as well. IMO we should try to standardise the current behaviour (and tackling only the most obvious improvements in the process), and work from there.
What needs to be done to implement editable install with build isolation? From the top of my head:
- Should we continue to use
.egg-info? I believe it is totally possible to switch to
.dist-infoinstead. This would minimise work for backends to add support (they only need to implement one db format)
- Is the
egg-linkmechanism required? Can we just put the
- How should pip inject the module for import?
.pthis not very inspiring, but I don’t think there is a better way unless we propose a new mechanism to the core interpreter.