From b4373c8148cd58e13760b637946b013cf03fb834 Mon Sep 17 00:00:00 2001 From: Georgios Kafanas Date: Wed, 20 Nov 2024 18:33:27 +0100 Subject: [PATCH] [bugfix] Set an etc path for scripts in the python module installation The `pythonpath` variable was used to store python scripts in a temporary location and later copy them in the installation path. The scripts were stored in the path were log files are stored, `log_path()`, in both the build and installation directories. - Rename `pythonpath` to `python_script_dir_relative_path`. - Use the more appropriate location `etc/python` to store the python scripts in the build and then installation directories. Note that all functions handling the python script path accept relative paths only. Currently, only the `sitecustomize.py` python environment initialization script is stored in script directory. Issue: https://github.com/easybuilders/easybuild-easyconfigs/issues/21078 --- easybuild/easyblocks/p/python.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/easybuild/easyblocks/p/python.py b/easybuild/easyblocks/p/python.py index 01355b23e5..7637a16738 100644 --- a/easybuild/easyblocks/p/python.py +++ b/easybuild/easyblocks/p/python.py @@ -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 @@ -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. @@ -504,7 +504,7 @@ 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 @@ -641,6 +641,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