Third try on editable installs

So I took a look at flit. It has two kinds of editable installs. One uses symlinks to link the install into site-packages. The other adds a .pth entry, more like how setuptools does it and more compatible with Windows.

I don’t think it would be practical to do the symlink option with enscons. It’s more like a set of tools to make it easy to build wheels than a fixed system. The files that wind up inside the wheel could come from all over, or be generated directly into the wheel and come from nowhere at all. It does have the concept of src_root, where you put your code, usually “.” or “src”.

For enscons a decent installer-driven develop() would be required to emit a dist-info directory in src_root, and it would return src_root as an absolute path, or as a relative path from pyproject.toml. The installer would maintain the .pth file or whatever mechanism it used to add us to PYTHONPATH.

A develop() hook could return different keys in a dict depending on what kind of editable install the back end was able to support.

I think we agreed on how editable install should work at last PyCon on the packaging summit. Someone needs to implement a POC of it, give it a test run and then we can formulate a PEP on is.

Where things are blocked now is packaging tools need to implement it, give it a dry run:

I know there’s some very broad strokes, but I likely missed the MO if there’s actionable direction on what exactly to implement. I think I voiced this in another thread somewhere as well. I don’t know what to do, I hear people saying they know what to do, but never anyone explaining what exactly they want to do. (Edit: except @dholth, of course, and every attempt he made thus far was shut down with someone saying “we know what to do” without explaining what that is.)

1 Like

@pganssle knows the exact details, but AFAIK he got held up with trying to detangle setuptools and distutils. Basically someone needs to:

  • propose a PEP-517 extension point for editable installs (we have a summary from last pycon summit with the expectation of this hook) via a PEP,
  • implement it inside a builder (setuptools, poetry, flit)
  • implement the usage of this within pip.

Given these three items we’re good to go.

1 Like

Digging up the notes from the packaging summit so others don’t need to (the link should take you directly to the comment containing the notes; you don’t need to read the thread from the beginning)

Quasi-summary with thoughts for people to act on directly:

  • I think we should use symlinks if possible, .pth otherwise. Everyone likes to hate .pth, but that’s the best thing we have and standardising something else for this purpose is in yak-shaving territory IMO. We can discuss replacing it after editable is done.
  • Regarding symlinks, Windows does support it somehow, and virtualenv contains logic to detect it. Maybe it’d be a good idea to split this into a support lib so we can share implementation? I’ll just tag @bernatgabor since you’re in this thread already :stuck_out_tongue:
  • Both code and metadata should be linked in. File exclusion (have files in the source tree but not included in the installation) is not worth the effort, let’s not consider it (i.e. everything in the source tree will be editable-installed, ignoring metadata definition).
  • Similar applies to inclusion update, it’s unreasonable to magically add new links when metadata changes. Accept this and require the user to re-install.
2 Likes

This is the bit I keep getting stuck on, because I can’t find the details.

Can someone confirm, as a standalone post in this thread, not a link back to the previous discussion, exactly what the proposal is that needs to be written up as a PEP? I’m not bothered about a full PEP write-up, just a spec that’s clear and explicit enough to be implementable.

If there isn’t a spec to that level of detail yet, then isn’t that where we’re stalled, rather than at the “someone needs to implement a POC” stage?

@sumanah do you have the meeting notes from the packaging summit?

I’ve remembered that pkg_resources requires an .egg-link file to look for metadata, develop installs add one of those and add a path to the editable source code to easy-install.pth. So instead of putting .dist-info in the editable distribution,

Use the existing pep517 prepare_metadata_for_build_wheel to get .dist-info

Have develop() hook do the in-place build, return where a .pth should point to (or a tree of symlinks, but do .pth first, it is easier). Return a dictionary with a { "src_root" : } key.

Install as if the new .dist-info and .pth were in a wheel. No special uninstall logic required.

Suppose you create a tree of symlinks in site-packages and you want an editable install for spam/ham and a second package spam/jam. What would the installer do?

Sorry I couldn’t make it to the packaging summit. Was at the conference but couldn’t make it to that bit.

The way I remember we agreed on an API that’s very declarative, does not contain any of the implementation details you’ve been proposing here. Basically the interface would specify explicitly which (and all) files would need to be made available within the site packages folder. Was initially proposed the way I remember by @ncoghlan and then acceppted; @pganssle probably know better the details.

The details are certainly available in the editable installs thread. @pradyunsg also has some notes I believe. I have not been particularly motivated to try and recap anything because every time I read one of these threads, the hostile tone puts me off and I end up closing the window.

Lately I’ve found this forum and open source in general to be less stressful than dealing with COVID-19. Seriously. It’s a good distraction.

I don’t think the recap is necessary. The problem should be better understood after another year of experience.

@bernatgabor It’s as @uranusjr mentioned. Here are the notes on the future of editable installs from the Packaging Summit at PyCon North America 2019. They were previously in this Google Doc section and I moved them to that packaging-problems issue comment.

There were also discussions in Pip 19.1 and installing in editable mode with pyproject.toml (mostly before the summit) and in Specification of editable installation - #40 by pganssle – that is a direct link to a comment where @pganssle indicates why he thinks there ought to be a proof of concept before we work to standardize stuff with a PEP.

Am also pinging @techalchemy since he was planning to be part of the effort as well, and @takluyver since Daniel mentioned Flit.

Currently @uranusjr @pradyunsg and @pf_moore are committed to spending a fair amount of time on the pip resolver project, which I am the project manager on. Tzu-Ping and Paul will be done with that commitment in probably June, but Pradyun will still have some committed time on this project till the end of December (not going to go into complicated “we have 2 funders and different timelines for different parts of the project” details now). So that’s going to affect their ability to volunteer to work on editable installs. If there’s a specific deadline someone is trying to meet to ship better editable installs, then it would be good to know that.

If anyone knows a company who would like to sponsor this work, please speak up and talk with them (see the entry about editable installs on the Fundable Packaging Projects page).

And if anyone would like to help write some grant proposals to get funding through the Packaging Working Group for a proper push on this work, I’d love that! Message me - I can help you get started. In about two months, for instance, the Chan Zuckerberg Initiative’s next Essential Open Source Software for Science funding opens for applications. And applications for Mozilla Open Source Support funding can be submitted at any time.

Here is the current specification that I am suggesting we build a PoC for: Specification of editable installation

Presumably with Bernat’s additional suggestion of adding a version number.

It’s pretty dead-simple, and I don’t know that it’s worth going into much more detail until we know what’s feasible and what problems could come up, but I think it’s the minimal specification that meets the requirements of:

  1. Back-ends don’t need to know anything about how to install files.
  2. Front-ends handle entry point generation and installation.
  3. Front-ends have the option of “installing” only the files that will be visible in a non-editable install.

There will certainly need to be more details fleshed out, but I still think that the next step is a proof of concept in pip and setuptools, since those are the most widely used tools and the tools most likely to run into backwards compatibility problems that will need to be addressed in the PEP.

3 Likes

Thanks @pganssle. I have a somewhat-theoretical1 interest in this subject, and might be willing to work on a pip POC. However, as @sumanah pointed out, I am committed to other work for a while yet, so it would have to wait until that’s done.

However, from my experience implementing PEP 517, I can say with some certainty that work like this goes far better if there’s a good backend implementation available before starting work on a frontend. So I think the initial priority would be a proof of concept in either setuptools, or another backend that’s simple enough to make adding tests into pip relatively straightforward.

1 i.e., I don’t use editables much, but I find the mechanisms for implementing them interesting in the abstract.

The older thread concludes it is not convenient to implement the new feature “#3 Front-ends have the option of “installing” only the files that will be visible in a non-editable install.” While features #1 and #2 are less likely to restrict how build systems work, just moving some of what setup.py develop already does into pip.

I should be able to produce my own POC.

When I did take a crack at it before, the major issue was that distutils (and by extension setuptools ) doesn’t have a clean separation between “figure out all the stuff that needs to go into the package” and “put the stuff into the package”, it just sort of assembles the package as it goes.

Do you have a link to this?

Can you detail on these?

Earlier in this thread

  1. Back-ends don’t need to know anything about how to install files.
  2. Front-ends handle entry point generation and installation.
  3. Front-ends have the option of “installing” only the files that will be visible in a non-editable install.

I meant why you think those statements apply to those points :smile:

I mean, it requires a refactoring, but one that I think is important anyway, because it would allow for the deprecation and removal of setup.py install. AFAIK the way wheel works is that it will just run setup.py install into a workspace location and then zip up the results.

If we refactor this now into a “build package manifest” step and an “install package from manifest” step, then both bdist_wheel and develop can invoke the “build package manifest” step.

In any case, I think in this situation it’s more important to get the hook right than it is to get it right now. Paul Moore and I are both busy working on higher priority things right now, but if you look in the thread, I’ve been suggesting a timeline that involves me trying to take a crack at it after the Python 3.9 feature freeze for months now.

You mean a PoC for setuptools or a PoC for something else? A setuptools PoC would, I think, be very useful. Creating a PoC for something like flit would be pretty easy and would make a pip PoC easier to do and so might be worth it, but I think we definitely do need a setuptools PoC before we can move forward here.

I’ll try to do a setuptools + pip protoype of a “simple” proposal in the next week.

1 Like