Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print a warning when mixing $EBPYTHONPREFIXES and $PYTHONPATH modules #3521

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Flamefire
Copy link
Contributor

$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 the SciPy-bundle which includes patches that require a newer Cython as the build dependency then what is available in the Python-bundle-PyPI module. As only Python-bundle used $PYTHONPATH the package from the Cython module was ignored even though which cython points to the right binary.

The error wasn't helpful:

Error compiling Cython file:
------------------------------------------------------------
...
    cdef __Pyx_memviewslice memslice
    cdef Py_ssize_t itemsize
    cdef bint dtype_signed
    cdef char kind
    itemsize = -1
    cdef bint ___pyx_const int8_is_signed
                          ^
------------------------------------------------------------

(tree fragment):16:27: Syntax error in C variable declaration

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 the site-customize.py
This should catch most false positives while still catching enough real issues

$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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant