Print a warning when mixing $EBPYTHONPREFIXES and $PYTHONPATH modules #3521
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.
$PYTHONPATH takes precedence which might lead to unexpected or wrong packages being used especially when a dependency includes a newer package than another dependency.
As it is very hard to find this as the cause print a warning when this situation is found.
I ran into this while building
scipy
of theSciPy-bundle
which includes patches that require a newerCython
as the build dependency then what is available in thePython-bundle-PyPI
module. As only Python-bundle used$PYTHONPATH
the package from theCython
module was ignored even thoughwhich cython
points to the right binary.The error wasn't helpful:
The least we can do is to detect such issues and warn the user.
The check is triggered for direct dependencies when both
$PYTHONPATH
and$EBPYTHONPREFIXES
are set and the Python module is loaded.I only check for modules that have a
lib/python*/site-packages
folder and specifically exclude the Python module which sets$PYTHONPATH
for thesite-customize.py
This should catch most false positives while still catching enough real issues