-
Notifications
You must be signed in to change notification settings - Fork 203
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
broken installation of 'cffi' extension in Python 2 easyconfig when running EasyBuild with Python 3 and using --rpath #3421
Comments
I am 95% sure this will also solve easybuilders/easybuild-easyconfigs#6113 (after 2.5 years XD). I agree that |
Ah, no wait... it won't solve easybuilders/easybuild-easyconfigs#6113... there, the issue is with
Or something... But that might have other consequences (e.g. what if EB is not being run with system Python...). Probably best we discuss that part in #6113 and not here, the issues are complicated enough without mixing them... |
Hm, same question applies here: what happens if we add I guess there is no way really to solve that scenario, since if |
@casparvl The Let's follow up on the One option could be trying to run |
…un rpath_args.py (fixes easybuilders#3421)
--rpath
I ran into this weird problem when installing the
cffi
extension inPython-2.7.18-GCCcore-9.3.0.eb
:(relevant) details about the environment:
python3
(by setting$EB_PYTHON
topython3
)eb --rpath
)setuptools
andenum34
are also installed as extensions inPython-2.7.18-GCCcore-9.3.0.eb
, beforecffi
python
command is actually Python 3 (but I don't think that's relevant here)It took me a looong time to figure out what is actually going wrong here, so I'm documenting this for eternity...
When installing Python extensions,
PythonPackage.install_step
makes sure that the installation prefix is prepended to the$PYTHONPATH
environment variable; in this case, that's$EBROOTPREFIXlib/python2.7/site-packages
.Installing
cffi
from source (withpip install
) kicks of a Cython installation, which involves compiling stuff from source usinggcc
.The first
gcc
in$PATH
is our RPATH wrapper script, which is a bash script that runs therpath_args.py
Python script:easybuild-framework/easybuild/scripts/rpath_wrapper_template.sh.in
Line 50 in 0da2122
rpath_args.py
is run using the samepython
command as used by EasyBuild itself (sopython3
). But$PYTHONPATH
is set up for Python 2 (since we're installing Python packages as extensions for Python 2), and that's where the problem lies:pip install
triggers a a compilation withgcc
;gcc
is our RPATH wrapper script, which runspython3 rpath_args.py ...
;rpath_args.py
script triggers animport site
;site
is imported from$EBROOTPREFIXlib/python2.7/site-packages/site.py
, since that location is listed first in$PYTHONPATH
(so it wins over the standard library locations forpython3
, uh-oh Typos #1);site.py
was installed by our dear friendsetuptools
(which is installed as an extension beforecffi
)site.py
does animport imp
, in atry
-catch
:imp
module in Python 2).In this case however the
import imp
actually works, since it's being done in a Python 3 environment (since therpath_args.py
script is being run withpython3
).import imp
leads toimport tokenize
, which leads toimport re
, which are all imported from the Python 3 standard library;import re
triggers animport enum
, which is resolved by theenum34
extension that is installed in$EBROOTPREFIXlib/python2.7/site-packages
(uh-oh 1226 mr bayes #2);AttributeError
because theenum
package provided byenum34
is not what Python 3 expects (it expects theenum
included in Python 3 standard library), and so things go boom 💥 ...And this is why friends don't let friends combine Python 2 and 3 in the same environment.
This is easy to fix: we just need to make sure that the
rpaths_args.py
script is run usingpython -E
(to ignore$PYTHONPATH
) orpython -S
(to skip theimport site
). Doing both is probably the best way forward, to make the RPATH wrapper scripts more robust... Therpaths_args.py
script is pretty basic, doesn't need anything special (Python 2/3 standard library is sufficient), so it's fine to limit what it has access to.edit: side note: pypa/pip#8214 looks very similar, but it really a different problem (this bug has nothing to do with
pip
perse)The text was updated successfully, but these errors were encountered: