Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better debuggability #910

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions constructor/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def get_output_filename(info):
def main_build(dir_path, output_dir='.', platform=cc_platform,
verbose=True, cache_dir=DEFAULT_CACHE_DIR,
dry_run=False, conda_exe="conda.exe",
config_filename="construct.yaml"):
config_filename="construct.yaml", debug=False):
logger.info('platform: %s', platform)
if not os.path.isfile(conda_exe):
sys.exit("Error: Conda executable '%s' does not exist!" % conda_exe)
Expand All @@ -88,6 +88,7 @@ def main_build(dir_path, output_dir='.', platform=cc_platform,
info['_platform'] = platform
info['_download_dir'] = join(cache_dir, platform)
info['_conda_exe'] = abspath(conda_exe)
info['_debug'] = debug
itypes = get_installer_type(info)

if platform != cc_platform and 'pkg' in itypes and not cc_platform.startswith('osx-'):
Expand Down Expand Up @@ -467,7 +468,7 @@ def main():
main_build(dir_path, output_dir=out_dir, platform=args.platform,
verbose=args.verbose, cache_dir=args.cache_dir,
dry_run=args.dry_run, conda_exe=conda_exe,
config_filename=args.config_filename)
config_filename=args.config_filename, debug=args.debug)


if __name__ == '__main__':
Expand Down
3 changes: 2 additions & 1 deletion constructor/osxpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,8 @@ def pkgbuild_script(name, info, src, dst='postinstall', **kwargs):
identifier=info.get("reverse_domain_identifier"),
install_location=info.get("default_location_pkg"),
)
rm_rf(SCRIPTS_DIR)
if not info.get('_debug'):
rm_rf(SCRIPTS_DIR)


def create(info, verbose=False):
Expand Down
3 changes: 2 additions & 1 deletion constructor/shar.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,5 @@ def create(info, verbose=False):

os.unlink(tarball)
os.chmod(shar_path, 0o755)
shutil.rmtree(tmp_dir)
if not info.get('_debug'):
shutil.rmtree(tmp_dir)
3 changes: 2 additions & 1 deletion constructor/winexe.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,8 @@ def create(info, verbose=False):
if signing_tool:
signing_tool.verify_signature(info['_outpath'])

shutil.rmtree(tmp_dir)
if not info.get('_debug'):
shutil.rmtree(tmp_dir)


if __name__ == '__main__':
Expand Down
19 changes: 19 additions & 0 deletions news/910-debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* When `--debug` is used, do not delete temporary workspaces to facilitate inspection. (#910)

### Bug fixes

* <news item>

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* Run SH tests in `-x` mode if `CONSTRUCTOR_DEBUG=1` is set. (#910)
7 changes: 5 additions & 2 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
CONDA_EXE, CONDA_EXE_VERSION = identify_conda_exe(CONSTRUCTOR_CONDA_EXE)
if CONDA_EXE_VERSION is not None:
CONDA_EXE_VERSION = Version(CONDA_EXE_VERSION)
CONSTRUCTOR_DEBUG = bool(os.environ.get("CONSTRUCTOR_DEBUG"))
CONSTRUCTOR_DEBUG = os.environ.get("CONSTRUCTOR_DEBUG", "").lower() in ("1", "true", "yes")
if artifacts_path := os.environ.get("CONSTRUCTOR_EXAMPLES_KEEP_ARTIFACTS"):
KEEP_ARTIFACTS_PATH = Path(artifacts_path)
KEEP_ARTIFACTS_PATH.mkdir(parents=True, exist_ok=True)
Expand Down Expand Up @@ -189,7 +189,10 @@ def _run_installer_sh(installer, install_dir, installer_input=None, timeout=420,
if installer_input:
cmd = ["/bin/sh", installer]
else:
cmd = ["/bin/sh", installer, "-b", "-p", install_dir]
cmd = ["/bin/sh"]
if CONSTRUCTOR_DEBUG:
cmd.append("-x")
cmd += [installer, "-b", "-p", install_dir]
return _execute(cmd, installer_input=installer_input, timeout=timeout, check=check)


Expand Down
Loading