coherent-oss / coherent.build

A zero-config Python project build backend
5 stars 0 forks source link

Implement support for editable installs #2

Closed jaraco closed 2 weeks ago

jaraco commented 1 month ago

PEP 660 describes a protocol for a build backend to implement an editable install.

I'd like for coherent.build to implement such a hook.

Note that the editables and setuptools projects implement this PEP, but neither in a way that coherent.build can. Because coherent.build is based on the essential layout, there's no good root to link into site-packages (or to add to sys.path) to make imports possible.

Instead, we'll need to devise another technique to make the name of the project visible to the import system.

The PEP describes what to put in the wheel, including mentioning that editables uses the "proxy module" technique. I'm thinking that proxy module technique could be used for the "essential layout" as well. An example wheel might contain:

.
└── coherent
    └── build.py

Where build.py is a proxy module to the package at the repo root. It's possible that proxy module will need to instead be coherent/build/__init__.py.

It may be desirable to adapt or extend the editables project to implement the hook or maybe not.

Out of scope is to actually support installation. There's a known issue where projects under the Coherent Software Development System aren't installable by pip. You can test the viability by cp system.toml pyproject.toml and then pip install -e that.

jaraco commented 2 weeks ago

I've started investigating how this might work. After reviewing the editables project, I can see how the RedirectingFinder might be re-usable for this project's purposes. In fact, it seems to work great for simple, top-level packages. For namespace packages, however, it doesn't work, as there's no target for the top-level (namespace) package to redirect to (e.g. no place for the package coherent to point), so I've started work on adding such support.