Skip to content

Commit 7ba107b

Browse files
committed
Fix building PyTorch when using setup.py as the build command
When changing `use_pip` after `PythonPackage.__init__` called `determine_install_command` the change is not honored. Call it again after the change. This also requires to make it idempotent so all member variables changed in that function need to be set in all cases. Fixes #3570
1 parent e0de69f commit 7ba107b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

easybuild/easyblocks/generic/pythonpackage.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,6 @@ def __init__(self, *args, **kwargs):
474474
self.pylibdir = UNKNOWN
475475
self.all_pylibdirs = [UNKNOWN]
476476

477-
self.py_installopts = []
478477
self.install_cmd_output = ''
479478

480479
# make sure there's no site.cfg in $HOME, because setup.py will find it and use it
@@ -499,8 +498,6 @@ def __init__(self, *args, **kwargs):
499498
# figure out whether this Python package is being installed for multiple Python versions
500499
self.multi_python = 'Python' in self.cfg['multi_deps']
501500

502-
# determine install command
503-
self.use_setup_py = False
504501
self.determine_install_command()
505502

506503
# avoid that pip (ab)uses $HOME/.cache/pip
@@ -517,7 +514,9 @@ def determine_install_command(self):
517514
"""
518515
Determine install command to use.
519516
"""
517+
self.py_installopts = []
520518
if self.cfg.get('use_pip', True) or self.cfg.get('use_pip_editable', False):
519+
self.use_setup_py = False
521520
self.install_cmd = PIP_INSTALL_CMD
522521

523522
pip_verbose = self.cfg.get('pip_verbose', None)
@@ -546,8 +545,8 @@ def determine_install_command(self):
546545
else:
547546
self.use_setup_py = True
548547
self.install_cmd = SETUP_PY_INSTALL_CMD
549-
install_target = self.cfg.get_ref('install_target')
550548

549+
install_target = self.cfg.get_ref('install_target')
551550
if install_target == EASY_INSTALL_TARGET:
552551
self.install_cmd += " %(loc)s"
553552
self.py_installopts.append('--no-deps')

easybuild/easyblocks/p/pytorch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ def __init__(self, *args, **kwargs):
240240
if self.cfg['use_pip'] is None and pytorch_version >= '2.0':
241241
self.log.info("Auto-enabling use of pip to install PyTorch >= 2.0, since 'use_pip' is not set")
242242
self.cfg['use_pip'] = True
243+
self.determine_install_command()
243244

244245
def fetch_step(self, skip_checksums=False):
245246
"""Fetch sources for installing PyTorch, including those for tests."""

0 commit comments

Comments
 (0)