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

[FR] Implement PEP 660 -- Editable Installations #2816

Closed
1 task done
pradyunsg opened this issue Oct 15, 2021 · 14 comments · Fixed by #3265 or #3488
Closed
1 task done

[FR] Implement PEP 660 -- Editable Installations #2816

pradyunsg opened this issue Oct 15, 2021 · 14 comments · Fixed by #3265 or #3488
Labels
enhancement help wanted Needs Discussion Issues where the implementation still needs to be discussed. Needs Implementation Issues that are ready to be implemented. Needs Investigation Issues which are likely in scope but need investigation to figure out the cause proposal task

Comments

@pradyunsg
Copy link
Member

What's the problem this feature will solve?

PEP 660 standardises the mechanism that setup.py develop uses to make "editable" packages.

Currently, pip needs to implement fairly horrible hacks to make legacy setup.py develop builds work. It'd be great if setuptools could implement PEP 660, which would be the last item from setuptools' end before pip can start the process of removing the legacy directly-call-setup.py build system.

Describe the solution you'd like

PEP 660's build_editable hook gets implemented in aetuptools.

Alternative Solutions

Not doing this.

I imagine this will mean that either (a) pip continues to maintain editable installs for setuptools or (b) pip drops the legacy build system entirely and users of setuptools projects will no longer be able to make editable installations.

I don't think (b) is happening any time soon, and it'd likely be best to implement the hook here.

Additional context

IIUC, this has been implemented in setuptools-pep660 already. It might not be a lot of work to migrate the work done there into seriptools directly.

Code of Conduct

  • I agree to follow the PSF Code of Conduct
@jaraco
Copy link
Member

jaraco commented Nov 8, 2021

@ichard26
Copy link
Member

ichard26 commented Nov 9, 2021

I took a stab at this but I can't seem to find a reliable way to query the importable base of the packages / modules (i.e. the parent directory of {name}.dist-info generated from an in-tree build). For what it's worth this is my first time working in the setuptools codebase so there's probably something I'm missing :)

@ichard26
Copy link
Member

Status update: after adding some more runtime patching of setuptools internals to query all of the information I need I got an implementation that can do an editable install for at least a simple single pure-Python module distribution and a src-style pure-Python multi-package distribution (psf/black, duh 🙂) 🎉

main...ichard26:pep-660

I need to test other situations and packaging configurations, but I've ran out of time for today :)

@tacaswell
Copy link

I think that preserving editable installs for packages with c / c++ / cython installations via some mechanism is cirtical (I say with my Matplotlib and h5py hats on).

I would be perfectly happy to absorb changes to our setup.py / pyproject.toml / built incantation, but there needs to be some path forward.

@ichard26
Copy link
Member

ichard26 commented Nov 11, 2021

I think that preserving editable installs for packages with c / c++ / cython installations via some mechanism is cirtical (I say with my Matplotlib and h5py hats on).

Right, unfortunately I don't really have much experience in this domain1. It is my understanding that PEP 660's way of handling extensions is by mandating a in-tree and in-place extension build (effectively python setup.py build_ext -i) before the editable wheel is produced. This obviously means the editable install / the in-place extension build will have to be redone to see changes in the extensions. Other than that I don't see how using a root .pth file (pointing to the importable base which by now should have the built extensions in-tree)2 changes things as it's basically how python setup.py develop worked anyway, just codified ^^

I'd love input and insight from people like yourself regarding extensions for both my own understanding and implementation testing!

Footnotes

  1. I can only speak with my psf/black (and maybe pypa/bandersnatch) hats on 🙂

  2. This is the implementation strategy I chose as it seems the simplest haha

@webknjaz webknjaz added help wanted Needs Discussion Issues where the implementation still needs to be discussed. Needs Implementation Issues that are ready to be implemented. Needs Investigation Issues which are likely in scope but need investigation to figure out the cause proposal task and removed Needs Triage Issues that need to be evaluated for severity and status. labels Nov 11, 2021
LoicGrobol added a commit to LoicGrobol/zeldarose that referenced this issue Mar 26, 2022
We still need a stup setup.cfg
[until](pypa/setuptools#2816)
setuptools gets proper editable installs
and either
flake8 [**finally**](python/mypy#5205)
gets the hint and support pyproject or
[flakeheaven](https://github.com/flakeheaven/flakeheaven) is usable with
vscode.
@pradyunsg
Copy link
Member Author

For completeness, making an update here with how I understand the state of affairs to be.

With #1688 closed, this is now a blocker for getting editable installs working for setuptools' new pyproject.toml only projects.

In #2872, there has been extensive discussion about the implementation approach that setuptools can take for this. There seems to be no clear concensus about how to implement the PEP 660 hooks -- there's significant pushback from the maintainers for implementing the PEP 660 hooks (that enable editable installations, without a setup.py file) using a mechanism similar to setup.py develop today.

akkornel added a commit to stanford-rc/globus-group-manager that referenced this issue May 4, 2022
Hello from an empty setup.cfg file!

This project is meant to be developed using an "editable installation".  That
is, an installation you get from running something like `pip install -e .`.
With traditional distributions, from the pre-`pyproject.toml` days, this
would be supported through something like `setup.py develop`.
Later, Pip included support for `pip install -e .` in Setuptools-based
installations that only had a `setup.cfg` (no `setup.py`).

PEP 660 (https://peps.python.org/pep-0660/) has standardized editable
installations that use only `pyproject.toml`.  Unfortunately, Setuptools does
not yet implement the hooks needed to support this.

Luckily, the presence of a `setup.cfg` file is enough to trigger Pip to
fall back to the existing Setuptools editable-install mechanism, which is
still able to read project configuration from `pyproject.toml`.  And so, we
have an empty `setup.cfg`.

Once pypa/setuptools#2816 is completed, the file
can probably be removed.
@EwoutH
Copy link

EwoutH commented May 19, 2022

Thanks a lot for the effort so far! Is there any update it’s progress?

@abravalheri
Copy link
Contributor

abravalheri commented May 19, 2022

Hi @EwoutH I left a PR with a possible approach in #3265 (so the other setuptools maintainers can see if it matches their expectation). Please feel free to have a look and even submit a review.

gurza added a commit to yggdr-io/pybase26 that referenced this issue May 30, 2022
Error
Project file has a ‘pyproject.toml’ and
its build backend is missing the ‘build_editable’ hook.

This is due to a limitation in Setuptools support for PEP 660.
pypa/setuptools#2816
@pradyunsg
Copy link
Member Author

pradyunsg commented Jun 13, 2022

This is now one of the blockers for pip (and ensurepip) excluding setuptools in new virtual environments. The latest version of pip is capable of using the build isolation when setuptools is not available within the environment, even when there’s no pyproject.toml file.

@pradyunsg
Copy link
Member Author

pradyunsg commented Jul 26, 2022

Closing this out, since #3265 implemented this. It'll be in a release soon-enough.

It still has an experimental flag on it, but it works and that's the part that I care about. I've now seen multiple people point to this issue to say that editable installs don't work in Python -- the only case that doesn't is setuptools without a setup.py, which is going to be solved once that PR reaches main. :)

@samuelcolvin
Copy link

Thanks so much @pradyunsg.

@djhoese
Copy link

djhoese commented Jul 26, 2022

which is going to be solved once that PR reaches main.

Is there a milestone or pull request for when that will happen? I see the PR was merged to the feature/pep660, but don't see anything else using that branch. I'm not familiar with the setuptools workflow so let me know if I'm missing something. I'm one of those people that would like to use pyproject.toml without a setup.py and it seems I need that PR.

@astrojuanlu
Copy link
Contributor

I couldn't find an open PR for the feature/pep660 branch either, however @abravalheri announced a month ago that they were conducting preliminary tests https://discuss.python.org/t/help-testing-pep-660-support-in-setuptools/16904?u=astrojuanlu

@abravalheri
Copy link
Contributor

@djhoese, @astrojuanlu, you can track the progress in #3488. I am considering that the round of community feedback is reaching its end, so I plan to do a release soon (in another week or so).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement help wanted Needs Discussion Issues where the implementation still needs to be discussed. Needs Implementation Issues that are ready to be implemented. Needs Investigation Issues which are likely in scope but need investigation to figure out the cause proposal task
Projects
None yet
10 participants