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

change custom easyblock for Python to set pythonpath class variable to a fixed location relative to build path #3400

Open
wants to merge 1 commit into
base: 5.0.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions easybuild/easyblocks/p/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
from easybuild.framework.easyconfig import CUSTOM
from easybuild.framework.easyconfig.templates import PYPI_SOURCE
from easybuild.tools.build_log import EasyBuildError, print_warning
from easybuild.tools.config import build_option, ERROR, log_path, PYTHONPATH, EBPYTHONPREFIXES
from easybuild.tools.config import build_option, ERROR, PYTHONPATH, EBPYTHONPREFIXES
from easybuild.tools.modules import get_software_libdir, get_software_root, get_software_version
from easybuild.tools.filetools import apply_regex_substitutions, change_dir, mkdir
from easybuild.tools.filetools import read_file, remove_dir, symlink, write_file
Expand Down Expand Up @@ -142,8 +142,8 @@ def __init__(self, *args, **kwargs):

self.pyshortver = '.'.join(self.version.split('.')[:2])

# Used for EBPYTHONPREFIXES handler script
self.pythonpath = os.path.join(log_path(), 'python')
# Path of the directory used to store the EBPYTHONPREFIXES handler script, relative to the install directory
self.python_script_dir_relative_path = os.path.join('etc', 'python')

ext_defaults = {
# Use PYPI_SOURCE as the default for source_urls of extensions.
Expand Down Expand Up @@ -504,7 +504,8 @@ def install_step(self):
symlink('pip' + self.pyshortver, pip_binary_path, use_abspath_source=False)

if self.cfg.get('ebpythonprefixes'):
write_file(os.path.join(self.installdir, self.pythonpath, 'sitecustomize.py'), SITECUSTOMIZE)
write_file(os.path.join(self.installdir, self.python_script_dir_relative_path, 'sitecustomize.py'),
SITECUSTOMIZE)

# symlink lib/python*/lib-dynload to lib64/python*/lib-dynload if it doesn't exist;
# see https://github.com/easybuilders/easybuild-easyblocks/issues/1957
Expand Down Expand Up @@ -641,6 +642,6 @@ def make_module_extra(self, *args, **kwargs):
txt = super(EB_Python, self).make_module_extra()

if self.cfg.get('ebpythonprefixes'):
txt += self.module_generator.prepend_paths(PYTHONPATH, self.pythonpath)
txt += self.module_generator.prepend_paths(PYTHONPATH, self.python_script_dir_relative_path)

return txt