Add a provider for libraries in environmental folders #632
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.
Overview
The main addition in this PR is
fusesoc.providers.env.Env, which is meant to represent a library in a (not necessarily fixed) location in the environment. Specifically, included in this PR is a provider for Poetry that looks for the virtual environment set up by Poetry and adds it as a searchable location. An examplefusesoc.confwould be:This would invoke Poetry to find the active virtual environment each time it's needed. This would be added to the configuration with the command
fusesoc library add --sync-type env my-venv poetry.This provider can also be used to automatically produce a
localprovider by passing--no-auto-sync.I've tried to make this general enough that it's straightforward to add other targets that follow the general theme of:
The main intention here is to make it easier to distribute FuseSoC cores (or bundles of cores) through a Python package manager.
Related changes
As well as that main change, this PR includes the following related changes that support this new provider:
In
fusesoc.config.add_library, the call toinit_libraryis moved to before the updates to thefusesoc.conffile to allow the new provider to check that it can resolve the environmental folder and to allow it to provide a resolved location if neededIn
fusesoc.utils.Launcher, theLauncher.runmethod is adjusted to return asubprocess.Popenand to accept**kwargs(but otherwise should be compatible), which allows theEnvprovider to capture output from its invocation of PoetryIn
fusesoc.coremanager.find_cores, a call toEnv.resolveis added before directory walking takes place; this lets us avoid having the concrete location infusesoc.confas explicitly these types of folders may not have a fixed location