Skip to content

Commit

Permalink
Merge pull request #3080 from boegel/pythonpackage_installopts
Browse files Browse the repository at this point in the history
don't change `installopts` easyconfig parameter value in-place in `PythonPackage` easyblock
  • Loading branch information
branfosj committed Jan 18, 2024
2 parents 4e63956 + 21e0786 commit 7bc2b57
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 31 deletions.
4 changes: 3 additions & 1 deletion easybuild/easyblocks/d/dm_reverb.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ def install_step(self, *args, **kwargs):
whl_file = '%s-%s-cp%s*.whl' % (self.name.replace('-', '_'), self.version, pymajmin)
whl_path = os.path.join(self.builddir, whl_file)

installopts = ' '.join([self.cfg['installopts']] + self.py_installopts)

self.install_cmd = PIP_INSTALL_CMD % {
'installopts': self.cfg['installopts'],
'installopts': installopts,
'loc': whl_path,
'prefix': self.installdir,
'python': self.python_cmd,
Expand Down
19 changes: 10 additions & 9 deletions easybuild/easyblocks/generic/pythonpackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ def __init__(self, *args, **kwargs):
self.pylibdir = UNKNOWN
self.all_pylibdirs = [UNKNOWN]

self.py_installopts = []
self.install_cmd_output = ''

# make sure there's no site.cfg in $HOME, because setup.py will find it and use it
Expand Down Expand Up @@ -431,26 +432,26 @@ def determine_install_command(self):

pip_verbose = self.cfg.get('pip_verbose', None)
if pip_verbose or (pip_verbose is None and build_option('debug')):
self.cfg.update('installopts', '--verbose')
self.py_installopts.append('--verbose')

# don't auto-install dependencies with pip unless use_pip_for_deps=True
# the default is use_pip_for_deps=False
if self.cfg.get('use_pip_for_deps'):
self.log.info("Using pip to also install the dependencies")
else:
self.log.info("Using pip with --no-deps option")
self.cfg.update('installopts', '--no-deps')
self.py_installopts.append('--no-deps')

if self.cfg.get('pip_ignore_installed', True):
# don't (try to) uninstall already availale versions of the package being installed
self.cfg.update('installopts', '--ignore-installed')
self.py_installopts.append('--ignore-installed')

if self.cfg.get('zipped_egg', False):
self.cfg.update('installopts', '--egg')
self.py_installopts.append('--egg')

pip_no_index = self.cfg.get('pip_no_index', None)
if pip_no_index or (pip_no_index is None and self.cfg.get('download_dep_fail')):
self.cfg.update('installopts', '--no-index')
self.py_installopts.append('--no-index')

# avoid that pip (ab)uses $HOME/.cache/pip
# cfr. https://pip.pypa.io/en/stable/reference/pip_install/#caching
Expand All @@ -463,10 +464,10 @@ def determine_install_command(self):

if self.cfg['install_target'] == EASY_INSTALL_TARGET:
self.install_cmd += " %(loc)s"
self.cfg.update('installopts', '--no-deps')
self.py_installopts.append('--no-deps')
if self.cfg.get('zipped_egg', False):
if self.cfg['install_target'] == EASY_INSTALL_TARGET:
self.cfg.update('installopts', '--zip-ok')
self.py_installopts.append('--zip-ok')
else:
raise EasyBuildError("Installing zipped eggs requires using easy_install or pip")

Expand Down Expand Up @@ -612,7 +613,7 @@ def compose_install_command(self, prefix, extrapath=None, installopts=None):
# since we provide all required dependencies already, we disable this via --no-build-isolation
if LooseVersion(pip_version) >= LooseVersion('10.0'):
if '--no-build-isolation' not in self.cfg['installopts']:
self.cfg.update('installopts', '--no-build-isolation')
self.py_installopts.append('--no-build-isolation')

elif not self.dry_run:
raise EasyBuildError("Failed to determine pip version!")
Expand All @@ -639,7 +640,7 @@ def compose_install_command(self, prefix, extrapath=None, installopts=None):
loc += '[%s]' % extras

if installopts is None:
installopts = self.cfg['installopts']
installopts = ' '.join([self.cfg['installopts']] + self.py_installopts)

if self.cfg.get('use_pip_editable', False):
# add --editable option when requested, in the right place (i.e. right before the location specification)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def install_step(self):
'--record %s' % os.path.join(self.builddir, 'record'),
'--no-compile',
]
self.cfg.update('installopts', ' '.join(extra_installopts))
self.py_installopts.extend(extra_installopts)
else:
# using easy_install or pip always results in installation that is specific to Python version
eb_name = self.__class__.__name__
Expand Down
2 changes: 0 additions & 2 deletions easybuild/easyblocks/p/pybind11.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ def install_step(self):
build_dir = change_dir(self.cfg['start_dir'])
PythonPackage.install_step(self)

# Reset installopts (set by PythonPackage)
self.cfg['installopts'] = ''
change_dir(build_dir)
CMakeMake.install_step(self)

Expand Down
19 changes: 3 additions & 16 deletions easybuild/easyblocks/s/scipy.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,10 @@ def __init__(self, *args, **kwargs):
PythonPackage.__init__(self, *args, **kwargs)
self.testinstall = True

if LooseVersion(self.version) >= LooseVersion('1.9'):
self.use_meson = True

# enforce scipy test suite results if not explicitly disabled for scipy >= 1.9
# strip inherited PythonPackage installopts
installopts = self.cfg['installopts']
pythonpackage_installopts = ['--no-deps', '--ignore-installed', '--no-index', '--egg',
'--zip-ok', '--no-index']
self.log.info("Stripping inherited PythonPackage installopts %s from installopts %s",
pythonpackage_installopts, installopts)
for i in pythonpackage_installopts:
installopts = installopts.replace(i, '')
self.cfg['installopts'] = installopts

else:
self.use_meson = False
# use Meson/Ninja install procedure for scipy >= 1.9
self.use_meson = LooseVersion(self.version) >= LooseVersion('1.9')

# enforce scipy test suite results if not explicitly disabled for scipy >= 1.9
if self.cfg['ignore_test_result'] is None:
# automatically ignore scipy test suite results for scipy < 1.9, as we did in older easyconfigs
self.cfg['ignore_test_result'] = LooseVersion(self.version) < '1.9'
Expand Down
5 changes: 4 additions & 1 deletion easybuild/easyblocks/t/tensorrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,14 @@ def extensions_step(self):
os.path.join('uff', 'uff-*-py2.py3-none-any.whl'),
os.path.join('python', 'tensorrt-%s-cp%s-*-linux_x86_64.whl' % (self.version, pyver)),
]

installopts = ' '.join([self.cfg['installopts']] + self.py_installopts)

for whl in whls:
whl_paths = glob.glob(os.path.join(self.installdir, whl))
if len(whl_paths) == 1:
cmd = PIP_INSTALL_CMD % {
'installopts': self.cfg['installopts'],
'installopts': installopts,
'loc': whl_paths[0],
'prefix': self.installdir,
'python': self.python_cmd,
Expand Down
4 changes: 3 additions & 1 deletion easybuild/easyblocks/w/wxpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ def install_step(self):
pyver = det_python_version(self.python_cmd)
pyver = pyver[0] + pyver[2]

cmd = "pip install --no-deps --prefix=%(prefix)s dist/wxPython-%(version)s-cp%(pyver)s*.whl" % {
installopts = ' '.join([self.cfg['installopts']] + self.py_installopts)
cmd = "pip install %(installopts)s --prefix=%(prefix)s dist/wxPython-%(version)s-cp%(pyver)s*.whl" % {
'installopts': installopts,
'prefix': self.installdir,
'version': self.version,
'pyver': pyver
Expand Down

0 comments on commit 7bc2b57

Please sign in to comment.