Skip to content

Commit

Permalink
Add some sanity checking for building the wheel
Browse files Browse the repository at this point in the history
Check that replacement actually happens and wheel files are created.
Also change config values for following install step(s).
  • Loading branch information
Flamefire committed Jan 17, 2024
1 parent 3960106 commit 3b1123c
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions easybuild/easyblocks/generic/pythonpackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
@author: Jens Timmerman (Ghent University)
@author: Alexander Grund (TU Dresden)
"""
import glob
import json
import os
import re
Expand Down Expand Up @@ -784,22 +785,29 @@ def build_step(self):
build_cmd = 'build' # Default value for setup.py
build_cmd = '%(python)s setup.py ' + build_cmd

out = ''
if build_cmd:
build_cmd = build_cmd % {'python': self.python_cmd}
cmd = ' '.join([self.cfg['prebuildopts'], build_cmd, self.cfg['buildopts']])
(out, _) = run_cmd(cmd, log_all=True, simple=False)
elif self.cfg.get('use_pip') == 'wheel':
wheel_dir = tempfile.mkdtemp(prefix=self.name+'_wheel-')
cmd = self.compose_install_command(
prefix=wheel_dir,
preinstallopts=self.cfg['prebuildopts'],
installopts=self.cfg['buildopts'])
cmd = cmd.replace("install --prefix=", "wheel --wheel-dir=")

if self.install_cmd == PIP_INSTALL_CMD:
self.install_cmd = PIP_INSTALL_CMD.replace('%(loc)s', os.path.join(wheel_dir, '*.whl'))
else:
return
(out, _) = run_cmd(cmd, log_all=True, simple=False)
orig_cmd = cmd
for src, repl in ((' install ', ' wheel '), (' --prefix=', ' --wheel-dir=')):
if src not in cmd:
raise EasyBuildError("Error adjusting install command `%s` for building wheel: '%s' not found!",
orig_cmd, cmd)
cmd = cmd.replace(src, repl)
(out, _) = run_cmd(cmd, log_all=True, simple=False)
wheels = glob.glob(os.path.join(wheel_dir, '*.whl'))
if not wheels:
raise EasyBuildError('Build failed: No wheel files found in %s after running %s', wheel_dir, cmd)
self.log.info('Build created wheel files ' + ', '.join(wheels))
self.cfg['install_src'] = ' '.join(wheels)

# keep track of all output, so we can check for auto-downloaded dependencies;
# take into account that build/install steps may be run multiple times
Expand Down

0 comments on commit 3b1123c

Please sign in to comment.