Conversation
To overcome the limitation of current concretiser in spack. See spack#7926
ohm314
left a comment
There was a problem hiding this comment.
sorry, neither the PR description nor the comments were clear enough for me on what this PR does. I'm happy to approve it, but I'd be glad if you could explain why the environment variables have to be unset and what you mean by your PR comment.
|
@ohm314 : sorry, my mistake. I was trying to avoid long explanation. please have a look. |
| run_env.set('PETSC_DIR', self.prefix) | ||
| run_env.unset('PETSC_ARCH') | ||
|
|
||
| # Petsc build will use python2 internaly |
There was a problem hiding this comment.
Could you please detail a little bit this comment? It is not very clear to me.
If I understand correctly, this patch allows this package to depends on Python 3 but in reality, Python 2 is always used, right?
There was a problem hiding this comment.
If you look at this, this is what happens :
-import sys
+import sys, os
if not type(sys.version_info) is tuple and sys.version_info.major > 2:
- print('Configure does not support Python 3 yet, please run as')
+ if os.path.basename(sys.executable) == 'python2':
+ # Exit to prevent an infinite loop in case the environment is corrupted such
+ # that "python2" in PATH is actually a Python 3 interpreter.
+ print('Executable not a valid Python 2 interpreter: ' + sys.executable)
+ sys.exit(1)
+ print('Configure does not support Python 3 yet, attempting to run as')
print(' python2 ' + ' '.join(["'" + a + "'" for a in sys.argv]))
- sys.exit(1)
+ os.execlp('python2', 'python2', *sys.argv)
This is hack but currently there is no other way to have Python3 in the dependency tree when PETSc is involved as one of the dependency .
Currently PETSc can be built with only Python2. This means, if package like STEPs need to be built with Python3 then we get :
This is because PETSc package has:
At the moment Spack doesn't allow to have two python version in the dependency tree i.e. python2 for PETSc and python3 for STEPs. See this PR for more details. This is current limitation of Spack concretiser algorithm. This limitation will be addressed in the next release (in coming month/months).
PETSc >=3.9 version allow to launch configure with python3 (see comment). In this case PETSc will internally check for python2 executable and if found, will continue build with python2. In this case we assume that python2 exist.
When user does
spack install petsc^python@3then Spack will set PYTHONPATH & PYTHONHOME to python3 install prefix. But PETSc is internally going to launch python2 executable. This will result in import error. And hence we unset those env variables.