Skip to content

Commit

Permalink
[bugfix] Set an etc path for scripts in the python module installation
Browse files Browse the repository at this point in the history
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: easybuilders/easybuild-easyconfigs#21078
  • Loading branch information
gkaf89 committed Nov 23, 2024
1 parent b9b242a commit b4373c8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 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,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
Expand Down Expand Up @@ -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

0 comments on commit b4373c8

Please sign in to comment.