Skip to content
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

Adding an editable install function for the build-system API #6950

Closed
adamboche opened this issue Aug 30, 2019 · 5 comments
Closed

Adding an editable install function for the build-system API #6950

adamboche opened this issue Aug 30, 2019 · 5 comments
Labels
auto-locked Outdated issues that have been locked by automation C: PEP 517 impact Affected by PEP 517 processing PEP implementation Involves some PEP state: needs discussion This needs some more discussion type: feature request Request for a new feature

Comments

@adamboche
Copy link

adamboche commented Aug 30, 2019

What's the problem this feature will solve?

Currently, pip does not support editable installs for build systems using pyproject.toml
instead of setup.py.

For example, in a project that uses Poetry, I get an error when I try to install editable.

venv/bin/pip install -e /path/to/project
ERROR: File "setup.py" not found. Directory cannot be installed in editable mode: /path/to/project
(A "pyproject.toml" file was found, but editable mode currently requires a setup.py based build.)

The pip install -e <path> command is useful in cases where I want to make frequent updates to a package while using it from another environment.

A proposal

PEP 517 defines a build-system API that provides several hooks, such as build_wheel() and
build_sdist(), and some additional optional hooks. I propose that specification be
expanded to include an optional function:

def editable_install(config_settings: Dict[str, Union[str, List[str]]]) -> None: ...
    """Build an egg-link file in the current site-packages directory."""

The function should create an egg-link file as described in the setuptools docs.

An alternative specification could instead return path to the package source's parent directory, and pip could build the egg-link itself.

def editable_install(
    config_settings: Dict[str, Union[str, List[str]]]
) -> Dict[str, str]:
    """Return a mapping from the package name to the parent directory of its source."""    

A third would be to leave it up to the build system how it wants to implement editable installs, but I'm not sure what that would mean in practice.

Alternative Solutions

  1. Workaround by build systems.

Poetry could create a setup.py for use by pip, which users could check into version
control. This means the build backend is once again coupled to setuptools, which is
contrary to the intent of PEP 517.

  1. Workaround by users.

Another workaround is to activate a virtualenv, cd to the Poetry project's directory, and run
poetry install there. With a virtualenv activated, Poetry will detect the environment by
checking $VIRTUALENV_ENV and install into that environment rather than creating a new
virtualenv like it normally would. If a virtualenv's pip is used without activating, it might be detectable using sys.real_prefix, but then the user's intent is less clear about whether Poetry should create a new virtualenv.

This workaround is non-obvious and would require explanation for each user. It would be
easier if we could just use pip install -e /path/to/project like normal.

  1. Workaround by pip.

An alternative solution is to just use the regular installation code path but pass -e in
the config_settings dict. However, if the build system does not support that option, it
would probably fail silently by installing in non-editable mode. It is better to be
informed that the editable build failed, which means there should be an explicit API for
pip to check. If the builder does not provide the editable_install() function, pip can
raise an exception itself.

Additional context


/cc @sdispater (Poetry) @takluyver (Flit) in case you have thoughts on this.

@triage-new-issues triage-new-issues bot added the S: needs triage Issues/PRs that need to be triaged label Aug 30, 2019
@chrahunt chrahunt added C: PEP 517 impact Affected by PEP 517 processing PEP implementation Involves some PEP state: needs discussion This needs some more discussion type: feature request Request for a new feature labels Aug 31, 2019
@triage-new-issues triage-new-issues bot removed S: needs triage Issues/PRs that need to be triaged labels Aug 31, 2019
@chrahunt
Copy link
Member

chrahunt commented Aug 31, 2019

Given that we can't make a unilateral decision, and this would need input and discussion from a larger audience, it may be more effective to start or find a discussion on discuss.python.org to get feedback. There are several there already, but I couldn't find an authoritative-looking thread where people are following up on the PEP517 note regarding editable installs.

@adamboche
Copy link
Author

adamboche commented Sep 8, 2019

For future readers: The most relevant discussion I can find is https://discuss.python.org/t/specification-of-editable-installation/1564.

@pradyunsg
Copy link
Member

See pypa/packaging-problems#256 (comment)

@pradyunsg
Copy link
Member

To reiterate what @chrahunt said, this is a multi project, interoperability specification. Thus, this needs much broader discussion and Packaging category on discuss.python.org is likely the best place for moving this forward.

There are a lot of the details here to figure out so, know that it'll take a fair amount of effort and time to get this done. That's just the nature of a packaging ecosystem that's almost completely maintained by folks on a volunteer basis.

@chrahunt
Copy link
Member

Since there's no action for pip here I will close this issue. Anyone interested should participate in the discussions linked above.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Nov 25, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Nov 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation C: PEP 517 impact Affected by PEP 517 processing PEP implementation Involves some PEP state: needs discussion This needs some more discussion type: feature request Request for a new feature
Projects
None yet
Development

No branches or pull requests

3 participants