Determine the default plugin path at configure time, rather than runtime #1782
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.
DNF currently gets the default plugin path using
sysconfig.get_path()
.This function can be used to determine where files should be installed, but it doesn't necessarily tell you where they have been installed.
For DNF specifically, installing system packages (RPMs) might use different locations than packages installed by tools like pip, setuptools and distutils.
DNF works now (we've ben careful not to break it), but there will likely be larger changes in this area (see a discuss.python.org thread). It would be nice to get ready for that ahead of time.
Here is one way to set the default plugin path to the location DNF will install the plugin to, using CMake interpolation.
Another way would be to see where
dnf
is imported from, and look fordnf-plugins
next to that directory.Yet another would be to treat
dnf-plugins
as a "normal" package and import it using.e.g.importlib.import_module('dnf-plugins')
– but there might be security concerns since the Python package path can be easily changed.