Skip to content

RHEL8 bugfix for unavailability of python.#14252

Merged
tgamblin merged 3 commits intospack:developfrom
s-sajid-ali:python3_env_fix
Dec 21, 2019
Merged

RHEL8 bugfix for unavailability of python.#14252
tgamblin merged 3 commits intospack:developfrom
s-sajid-ali:python3_env_fix

Conversation

@s-sajid-ali
Copy link
Copy Markdown
Contributor

@s-sajid-ali s-sajid-ali commented Dec 20, 2019

Since there is no python on RHEL/CentOS-8. Alternatively, one could query the OS version and use that for an if-else clause.

	modified:   lib/spack/spack/util/environment.py
Copy link
Copy Markdown
Member

@greenc-FNAL greenc-FNAL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we be using sys.executable here anyway?
Also, not strictly relevant to your PR but this function fails miserably for embedded spaces in paths. It should be using Executable with arguments as an array rather than squashing them to a single string and invoking shell().

@s-sajid-ali
Copy link
Copy Markdown
Contributor Author

Changed to sys.executable which gives a string output.

Copy link
Copy Markdown
Member

@greenc-FNAL greenc-FNAL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the job.

@tgamblin tgamblin merged commit 96063f9 into spack:develop Dec 21, 2019
@s-sajid-ali s-sajid-ali deleted the python3_env_fix branch December 21, 2019 14:01
@zzotta
Copy link
Copy Markdown
Contributor

zzotta commented Jan 7, 2020

Using sys.executable in EnvironmentModifications does not work if the package depends on a specific python package, since in this case the PYTHONHOME environment variable is set in the build environment, and it is not the correct python home when using the sys.executable interpreter, which is the one used for the spack command itself.
For instance consider the following package (we use the spack source url only to have a downloadable package):

import os
import tempfile

from spack import *
from spack.util.environment import EnvironmentModifications

class SourceBug(Package):
    homepage = "https://github.com/spack"
    url      = "https://github.com/spack/spack/releases/download/v0.13.3/spack-0.13.3.tar.gz"

    version('0.13.3', sha256='dc6f4d6b89d72f1713324e6fd7d4eba8534ba731c680c848d4169d94e76ef85e')
    version('0.13.2', sha256='30c1a3eb42429344107acdea132be34ed7529489a8dafac9640fbcc86bee0ce1')

    depends_on('python@3.6.8', when='@0.13.3')

    def install(self, spec, prefix):
        with tempfile.NamedTemporaryFile() as source_me:
            source_me.write("MYDIR=/my/dir\n")
            source_me.flush()
            EnvironmentModifications.from_sourcing_file(source_me.name).apply_modifications()
        touch(os.path.join(spec.prefix, 'readme'))

In this case installing source-bug@0.13.2 works, while installing source-bug@0.13.3 fails:

==> Error: ProcessError: Command exited with status 1:
    '/bin/bash' '-c' 'source /tmp/tmpOePPWf &> /dev/null && /usr/bin/python -c "import os, json; print(json.dumps(dict(os.environ)))"'
See build log for details:
  .../spack/var/spack/stage/spack-stage-source-bug-0.13.3-wux6dhmj5htnxqhxqyqsykzdc2lptjto/spack-build-out.txt

The error is:

==> [2020-01-07-09:47:11.939684] '/bin/bash' '-c' 'source /tmp/tmpOePPWf &> /dev/null && /usr/bin/python -c "import os, json; print(json.dumps(dict(os.environ)))"'
ImportError: No module named site

@alalazo
Copy link
Copy Markdown
Member

alalazo commented Jan 9, 2020

@zzotta Can you file a separate bug report out of that comment?

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.

6 participants