add compatibility for editable wheels and src layout #20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
When using an src layout project structure together with the common
pip install -e .pattern to populate a virtual environment, plux plugins would not be resolved correctly. This is because the editable wheel creates a.dist-infodirectory withinsite-packagesfor the distribution, in which plux has a hard time creating theentry_points.txtfile because of the way pip isolates the build context (details aren't so important).This PR adds functionality for both build time and run time to resolve entry points from editable installs, even when a source layout is used.
Explanation
The main idea is to hook into the procedure that creates the editable install (in setuptools, this is the
editable_wheelcommand), and in the resulting.dist-infodirectory that is part of thesite-packages, leave behind a link to the.egg-infoof the source that contains the realentry_points.txt.In the case of localstack when using a src layout, the result of
pip install -e .will moving forward look as follows (simplified):where
entry_points_editable.txtwill contain one line:/tmp/localstack/localstack-core/localstack_core.egg-info/entry_points.txt.This is both very easy to create during build time, and also fairly easy to resolve during runtime. However, getting this logic into stevedore was too complicated, so I re-wrote the entry points resolution mechanism natively in plux, but borrowed a lot of their ideas. It's vastly simplified but works well. Performance (cold start without cache, cold start reading a cache from file, and warm in-memory cache) is basically unchanged.
Testing
You can test this in localstack:
move-source-codebranchmake clean installpip install -e ../plux(with this PR checked out)requires = ['setuptools', 'wheel', 'plux @ file:///home/thomas/workspace/localstack/plux'](update to your path accordinglypip instal -e .again (this way your local plux version will be used to build the editable wheel, which will correctly create theentry_points_editable.txtpython -m localstack.cli.plugins list --namespace "localstack.packages"should show all the packagesChanges
python -m plux resolveto test resolution of entrypoints from the current path using aPluginManager- mostly for debugging