diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0e012b56b..b2cb1783b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -116,7 +116,7 @@ jobs: source $CONDA/etc/profile.d/conda.sh conda activate constructor mkdir -p examples_artifacts/ - python scripts/run_examples.py --keep-artifacts=examples_artifacts/ + python -u scripts/run_examples.py --keep-artifacts=examples_artifacts/ - name: Upload the example installers as artifacts if: github.event_name == 'pull_request' && matrix.pyver == '3.9' uses: actions/upload-artifact@v3 diff --git a/CONSTRUCT.md b/CONSTRUCT.md index 0d0b3e493..0ec1ed1bd 100644 --- a/CONSTRUCT.md +++ b/CONSTRUCT.md @@ -557,8 +557,11 @@ Read notes about the particularities of Windows silent mode `/S` in the _required:_ no
_type:_ boolean
-Check if the path where the distribution is installed contains spaces and show a warning -if any spaces are found. Default is True. (Windows only). +Check if the path where the distribution is installed contains spaces. Default is True. +To allow installations with spaces, change to False. Note that: + +- A recent conda-standalone (>=22.11.1) or equivalent is needed for full support. +- `conda` cannot be present in the `base` environment Read notes about the particularities of Windows silent mode `/S` in the `installer_type` documentation. diff --git a/constructor/construct.py b/constructor/construct.py index 0bd1a7f36..e37b77eb0 100644 --- a/constructor/construct.py +++ b/constructor/construct.py @@ -444,8 +444,11 @@ '''), ('check_path_spaces', False, bool, ''' -Check if the path where the distribution is installed contains spaces and show a warning -if any spaces are found. Default is True. (Windows only). +Check if the path where the distribution is installed contains spaces. Default is True. +To allow installations with spaces, change to False. Note that: + +- A recent conda-standalone (>=22.11.1) or equivalent is needed for full support. +- `conda` cannot be present in the `base` environment Read notes about the particularities of Windows silent mode `/S` in the `installer_type` documentation. diff --git a/constructor/fcp.py b/constructor/fcp.py index b1f834e13..737e9fc51 100644 --- a/constructor/fcp.py +++ b/constructor/fcp.py @@ -367,19 +367,28 @@ def _fetch_precs(precs, download_dir, transmute_file_type=''): def _main(name, version, download_dir, platform, channel_urls=(), channels_remap=(), specs=(), exclude=(), menu_packages=(), ignore_duplicate_files=True, environment=None, environment_file=None, verbose=True, dry_run=False, conda_exe="conda.exe", - transmute_file_type='', extra_envs=None): + transmute_file_type='', extra_envs=None, check_path_spaces=True): precs = _solve_precs( name, version, download_dir, platform, channel_urls=channel_urls, channels_remap=channels_remap, specs=specs, exclude=exclude, menu_packages=menu_packages, environment=environment, environment_file=environment_file, verbose=verbose, conda_exe=conda_exe ) + extra_envs = extra_envs or {} + conda_in_base: PackageCacheRecord = next((prec for prec in precs if prec.name == "conda"), None) + if conda_in_base: + if not check_path_spaces and platform.startswith(("linux-", "osx-")): + raise RuntimeError( + "'check_path_spaces=False' cannot be used on Linux and macOS installers " + "if 'conda' is present in the 'base' environment." + ) + elif extra_envs: + raise RuntimeError( + "conda needs to be present in 'base' environment for 'extra_envs' to work" + ) extra_envs_precs = {} - for env_name, env_config in (extra_envs or {}).items(): - if not any(prec.name == "conda" for prec in precs): - raise RuntimeError("conda needs to be present in `base` environment for extra_envs to work") - + for env_name, env_config in extra_envs.items(): if verbose: print("Solving extra environment:", env_name) extra_envs_precs[env_name] = _solve_precs( @@ -445,6 +454,7 @@ def main(info, verbose=True, dry_run=False, conda_exe="conda.exe"): environment_file = info.get("environment_file", None) transmute_file_type = info.get("transmute_file_type", "") extra_envs = info.get("extra_envs", {}) + check_path_spaces = info.get("check_path_spaces", True) if not channel_urls and not channels_remap: sys.exit("Error: at least one entry in 'channels' or 'channels_remap' is required") @@ -467,7 +477,7 @@ def main(info, verbose=True, dry_run=False, conda_exe="conda.exe"): has_conda, extra_envs_info) = _main( name, version, download_dir, platform, channel_urls, channels_remap, specs, exclude, menu_packages, ignore_duplicate_files, environment, environment_file, - verbose, dry_run, conda_exe, transmute_file_type, extra_envs + verbose, dry_run, conda_exe, transmute_file_type, extra_envs, check_path_spaces ) info["_all_pkg_records"] = pkg_records # full PackageRecord objects diff --git a/constructor/header.sh b/constructor/header.sh index 87ea8e489..b5d8859d9 100644 --- a/constructor/header.sh +++ b/constructor/header.sh @@ -27,7 +27,7 @@ export INSTALLER_TYPE="SH" THIS_DIR=$(DIRNAME=$(dirname "$0"); cd "$DIRNAME"; pwd) THIS_FILE=$(basename "$0") THIS_PATH="$THIS_DIR/$THIS_FILE" -PREFIX=__DEFAULT_PREFIX__ +PREFIX="__DEFAULT_PREFIX__" #if batch_mode BATCH=1 #else @@ -58,7 +58,11 @@ Installs __NAME__ __VERSION__ #if not keep_pkgs -k do not clear the package cache after installation #endif +#if check_path_spaces -p PREFIX install prefix, defaults to $PREFIX, must not contain spaces. +#else +-p PREFIX install prefix, defaults to $PREFIX +#endif -s skip running pre/post-link/install scripts -u update an existing installation #if has_conda @@ -66,106 +70,48 @@ Installs __NAME__ __VERSION__ #endif " -if which getopt > /dev/null 2>&1; then - OPTS=$(getopt bifhkp:sut "$*" 2>/dev/null) - if [ ! $? ]; then - printf "%s\\n" "$USAGE" - exit 2 - fi - - eval set -- "$OPTS" - - while true; do - case "$1" in - -h) - printf "%s\\n" "$USAGE" - exit 2 - ;; - -b) - BATCH=1 - shift - ;; - -i) - BATCH=0 - shift - ;; - -f) - FORCE=1 - shift - ;; - -k) - KEEP_PKGS=1 - shift - ;; - -p) - PREFIX="$2" - shift - shift - ;; - -s) - SKIP_SCRIPTS=1 - shift - ;; - -u) - FORCE=1 - shift - ;; -#if has_conda - -t) - TEST=1 - shift - ;; -#endif - --) - shift - break - ;; - *) - printf "ERROR: did not recognize option '%s', please try -h\\n" "$1" - exit 1 - ;; - esac - done -else - while getopts "bifhkp:sut" x; do - case "$x" in - h) - printf "%s\\n" "$USAGE" - exit 2 +# We used to have a getopt version here, falling back to getopts if needed +# However getopt is not standardized and the version on Mac has different +# behaviour. getopts is good enough for what we need :) +# More info: https://unix.stackexchange.com/questions/62950/ +while getopts "bifhkp:sut" x; do + case "$x" in + h) + printf "%s\\n" "$USAGE" + exit 2 + ;; + b) + BATCH=1 + ;; + i) + BATCH=0 + ;; + f) + FORCE=1 + ;; + k) + KEEP_PKGS=1 + ;; + p) + PREFIX="$OPTARG" + ;; + s) + SKIP_SCRIPTS=1 + ;; + u) + FORCE=1 ;; - b) - BATCH=1 - ;; - i) - BATCH=0 - ;; - f) - FORCE=1 - ;; - k) - KEEP_PKGS=1 - ;; - p) - PREFIX="$OPTARG" - ;; - s) - SKIP_SCRIPTS=1 - ;; - u) - FORCE=1 - ;; #if has_conda - t) - TEST=1 - ;; + t) + TEST=1 + ;; #endif - ?) - printf "ERROR: did not recognize option '%s', please try -h\\n" "$x" - exit 1 - ;; - esac - done -fi + ?) + printf "ERROR: did not recognize option '%s', please try -h\\n" "$x" + exit 1 + ;; + esac +done # For testing, keep the package cache around longer CLEAR_AFTER_TEST=0 @@ -343,6 +289,7 @@ EOF printf "[%s] >>> " "$PREFIX" read -r user_prefix if [ "$user_prefix" != "" ]; then +#if check_path_spaces is True case "$user_prefix" in *\ * ) printf "ERROR: Cannot install into directories with spaces\\n" >&2 @@ -352,15 +299,20 @@ EOF eval PREFIX="$user_prefix" ;; esac +#else + PREFIX="$user_prefix" +#endif fi fi # !BATCH +#if check_path_spaces is True case "$PREFIX" in *\ * ) printf "ERROR: Cannot install into directories with spaces\\n" >&2 exit 1 ;; esac +#endif if [ "$FORCE" = "0" ] && [ -e "$PREFIX" ]; then printf "ERROR: File or directory already exists: '%s'\\n" "$PREFIX" >&2 @@ -370,7 +322,6 @@ elif [ "$FORCE" = "1" ] && [ -e "$PREFIX" ]; then REINSTALL=1 fi - if ! mkdir -p "$PREFIX"; then printf "ERROR: Could not create directory: '%s'\\n" "$PREFIX" >&2 exit 1 @@ -438,8 +389,8 @@ extract_range $boundary0 $boundary1 > "$CONDA_EXEC" chmod +x "$CONDA_EXEC" export TMP_BACKUP="$TMP" -export TMP=$PREFIX/install_tmp -mkdir -p $TMP +export TMP="$PREFIX/install_tmp" +mkdir -p "$TMP" # the second binary payload: the tarball of packages printf "Unpacking payload ...\n" @@ -473,7 +424,6 @@ else fi #endif -PYTHON="$PREFIX/bin/python" MSGS="$PREFIX/.messages.txt" touch "$MSGS" export FORCE @@ -494,9 +444,9 @@ CONDA_PKGS_DIRS="$PREFIX/pkgs" \ rm -f "$PREFIX/pkgs/env.txt" #if has_conda -mkdir -p $PREFIX/envs -for env_pkgs in ${PREFIX}/pkgs/envs/*/; do - env_name=$(basename ${env_pkgs}) +mkdir -p "$PREFIX/envs" +for env_pkgs in "${PREFIX}"/pkgs/envs/*/; do + env_name=$(basename "${env_pkgs}") if [ "$env_name" = "*" ]; then continue fi @@ -526,9 +476,9 @@ POSTCONDA="$PREFIX/postconda.tar.bz2" "$CONDA_EXEC" constructor --prefix "$PREFIX" --extract-tarball < "$POSTCONDA" || exit 1 rm -f "$POSTCONDA" -rm -f $PREFIX/conda.exe +rm -f "$CONDA_EXEC" -rm -rf $PREFIX/install_tmp +rm -rf "$PREFIX/install_tmp" export TMP="$TMP_BACKUP" @@ -560,7 +510,7 @@ if [ "$KEEP_PKGS" = "0" ]; then else # Attempt to delete the empty temporary directories in the package cache # These are artifacts of the constructor --extract-conda-pkgs - find $PREFIX/pkgs -type d -empty -exec rmdir {} \; 2>/dev/null || : + find "$PREFIX/pkgs" -type d -empty -exec rmdir {} \; 2>/dev/null || : fi cat <$PREFIX/.condarc' + yield 'cat <"$PREFIX/.condarc"' for line in condarc.splitlines(): yield line yield 'EOF' diff --git a/examples/extra_envs/construct.yaml b/examples/extra_envs/construct.yaml index a10da6117..ecec305e4 100644 --- a/examples/extra_envs/construct.yaml +++ b/examples/extra_envs/construct.yaml @@ -4,15 +4,15 @@ installer_type: all channels: - http://repo.anaconda.com/pkgs/main/ specs: - - python=3.7 + - python=3.9 - conda # conda is required for extra_envs - console_shortcut # [win] exclude: # [unix] - tk # [unix] extra_envs: - py38: + py310: specs: - - python=3.8 + - python=3.10 - pip channels: - conda-forge @@ -27,5 +27,5 @@ build_outputs: - info.json - pkgs_list - pkgs_list: - env: py38 + env: py310 - licenses diff --git a/examples/extra_envs/test_install.bat b/examples/extra_envs/test_install.bat index 2d70efb1a..3e90cc473 100644 --- a/examples/extra_envs/test_install.bat +++ b/examples/extra_envs/test_install.bat @@ -1,10 +1,10 @@ -:: base env +:: base env has python 3.9 if not exist "%PREFIX%\conda-meta\history" exit 1 -"%PREFIX%\python.exe" -c "from sys import version_info; assert version_info[:2] == (3, 7)" || goto :error +"%PREFIX%\python.exe" -c "from sys import version_info; assert version_info[:2] == (3, 9)" || goto :error -:: extra env named 'py38' -if not exist "%PREFIX%\envs\py38\conda-meta\history" exit 1 -"%PREFIX%\envs\py38\python.exe" -c "from sys import version_info; assert version_info[:2] == (3, 8)" || goto :error +:: extra env named 'py310' has python 3.10 +if not exist "%PREFIX%\envs\py310\conda-meta\history" exit 1 +"%PREFIX%\envs\py310\python.exe" -c "from sys import version_info; assert version_info[:2] == (3, 10)" || goto :error :: extra env named 'dav1d' only contains dav1d, no python if not exist "%PREFIX%\envs\dav1d\conda-meta\history" exit 1 diff --git a/examples/extra_envs/test_install.sh b/examples/extra_envs/test_install.sh index 58544320b..a024c1d3e 100644 --- a/examples/extra_envs/test_install.sh +++ b/examples/extra_envs/test_install.sh @@ -2,20 +2,24 @@ set -ex # tests -# base environment uses python 3.7 and excludes tk +# base environment uses python 3.9 and excludes tk test -f "$PREFIX/conda-meta/history" -"$PREFIX/bin/python" -c "from sys import version_info; assert version_info[:2] == (3, 7)" -"$PREFIX/bin/pip" -V +"$PREFIX/bin/python" -c "from sys import version_info; assert version_info[:2] == (3, 9)" +# we use python -m pip instead of the pip entry point +# because the spaces break the shebang - this will be fixed +# with a new conda release, but for now this is the workaround +# we need. same with conda in the block below! +"$PREFIX/bin/python" -m pip -V # tk(inter) shouldn't be listed by conda! -"$PREFIX/bin/conda" list -p "$PREFIX" | jq -e '.[] | select(.name == "tk")' && exit 1 +"$PREFIX/bin/python" -m conda list -p "$PREFIX" | jq -e '.[] | select(.name == "tk")' && exit 1 echo "Previous test failed as expected" -# extra env named 'py38' uses python 3.8, has tk, but we removed setuptools -test -f "$PREFIX/envs/py38/conda-meta/history" -"$PREFIX/envs/py38/bin/python" -c "from sys import version_info; assert version_info[:2] == (3, 8)" +# extra env named 'py310' uses python 3.10, has tk, but we removed setuptools +test -f "$PREFIX/envs/py310/conda-meta/history" +"$PREFIX/envs/py310/bin/python" -c "from sys import version_info; assert version_info[:2] == (3, 10)" # setuptools shouldn't be listed by conda! -"$PREFIX/bin/conda" list -p "$PREFIX/envs/py38" | jq -e '.[] | select(.name == "setuptools")' && exit 1 -"$PREFIX/envs/py38/bin/python" -c "import setuptools" && exit 1 +"$PREFIX/bin/python" -m conda list -p "$PREFIX/envs/py310" | jq -e '.[] | select(.name == "setuptools")' && exit 1 +"$PREFIX/envs/py310/bin/python" -c "import setuptools" && exit 1 echo "Previous test failed as expected" # this env only contains dav1d, no python; it should have been created with no errors, diff --git a/examples/extra_files/construct.yaml b/examples/extra_files/construct.yaml index 80cc1fc5b..1d248235e 100644 --- a/examples/extra_files/construct.yaml +++ b/examples/extra_files/construct.yaml @@ -1,6 +1,8 @@ name: ExtraFiles version: X installer_type: all +check_path_spaces: False +check_path_length: False channels: - http://repo.anaconda.com/pkgs/main/ specs: diff --git a/examples/grin/construct.yaml b/examples/grin/construct.yaml index 5b70d958b..2bb45f6aa 100644 --- a/examples/grin/construct.yaml +++ b/examples/grin/construct.yaml @@ -58,3 +58,6 @@ license_file: eula.txt #header_image_text: |- # multi-line # header-text + +check_path_spaces: False +check_path_length: False diff --git a/examples/newchan/construct.yaml b/examples/newchan/construct.yaml index 622d0fe04..05a1b668b 100644 --- a/examples/newchan/construct.yaml +++ b/examples/newchan/construct.yaml @@ -13,3 +13,5 @@ specs: license_file: eula.txt +check_path_spaces: False +check_path_length: False diff --git a/examples/noconda/construct.yaml b/examples/noconda/construct.yaml index 5c0c9014a..5a522cea2 100644 --- a/examples/noconda/construct.yaml +++ b/examples/noconda/construct.yaml @@ -12,3 +12,6 @@ conclusion_text: | You are now ready to run your Python installation. This is a second line and should appear as such on the installer UI. This would be the third one. + +check_path_spaces: False +check_path_length: False diff --git a/examples/osxpkg/construct.yaml b/examples/osxpkg/construct.yaml index b3b82e3b8..e39618677 100644 --- a/examples/osxpkg/construct.yaml +++ b/examples/osxpkg/construct.yaml @@ -2,9 +2,9 @@ name: osxpkgtest version: 1.2.3 # This config will result in a default install path: -# ~/Library/osx-pkg-test +# "~/Library/osx-pkg-test" (spaces not allowed because 'conda' is in 'specs') default_location_pkg: Library -pkg_name: osx-pkg-test +pkg_name: "osx-pkg-test" channels: - http://repo.anaconda.com/pkgs/main/ diff --git a/examples/osxpkg/test_install.sh b/examples/osxpkg/test_install.sh index f2dbb6cb7..ce7abf0fd 100644 --- a/examples/osxpkg/test_install.sh +++ b/examples/osxpkg/test_install.sh @@ -1,11 +1,11 @@ -#!/bin/bash +#!/bin/sh set -ex -echo '## Hello from Post_install script ' > $HOME/postinstall.txt -printenv >> $HOME/postinstall.txt +echo '## Hello from Post_install script ' > "$HOME/postinstall.txt" +printenv >> "$HOME/postinstall.txt" # Some tests # default_location_pkg -[[ $(basename $(dirname $PREFIX)) == "Library" ]] || exit 1 +[ "$(basename "$(dirname "$PREFIX")")" = "Library" ] || exit 1 # pkg_name -[[ $(basename $PREFIX) == "osx-pkg-test" ]] || exit 1 +[ "$(basename "$PREFIX")" = "osx-pkg-test" ] || exit 1 diff --git a/examples/scripts/construct.yaml b/examples/scripts/construct.yaml index 187fba4b1..97d64e197 100644 --- a/examples/scripts/construct.yaml +++ b/examples/scripts/construct.yaml @@ -11,3 +11,5 @@ pre_install_desc: "Adding this description makes the script selectable in the UI post_install: post_install.sh # [unix] post_install: post_install.bat # [win] post_install_desc: "Adding this description makes the script selectable in the UI" +check_path_spaces: False +check_path_length: False diff --git a/examples/shortcuts/construct.yaml b/examples/shortcuts/construct.yaml index 21ab4eaa7..238b5503f 100644 --- a/examples/shortcuts/construct.yaml +++ b/examples/shortcuts/construct.yaml @@ -9,3 +9,4 @@ specs: - python - conda - console_shortcut # [win] + diff --git a/examples/signing/construct.yaml b/examples/signing/construct.yaml index f4453b415..e8bd13380 100644 --- a/examples/signing/construct.yaml +++ b/examples/signing/construct.yaml @@ -8,3 +8,4 @@ specs: # This certificate is generated an copied over on the spot during CI # See scripts/create_self_signed_certificate.ps1 for more info signing_certificate: certificate.pfx # [win] +check_path_spaces: False diff --git a/news/449-allow-spaces-in-prefix b/news/449-allow-spaces-in-prefix new file mode 100644 index 000000000..5f0c40066 --- /dev/null +++ b/news/449-allow-spaces-in-prefix @@ -0,0 +1,22 @@ +### Enhancements: + +* Installers support spaces in `PREFIX` now. + Old behaviour (reject chosen path if it contained spaces) is still default. + Opt-in by setting `check_path_spaces` to `False`. (#449) + +### Bug fixes: + +* + +### Deprecations: + +* + +### Docs: + +* + +### Other: + +* + diff --git a/scripts/run_examples.py b/scripts/run_examples.py index a174d2af5..88fa39ba4 100644 --- a/scripts/run_examples.py +++ b/scripts/run_examples.py @@ -29,15 +29,22 @@ PY3 = sys.version_info[0] == 3 WHITELIST = ['grin', 'jetsonconda', 'miniconda', 'newchan'] BLACKLIST = [] +WITH_SPACES = {"extra_files", "noconda", "signing", "scripts"} def _execute(cmd): print(' '.join(cmd)) t0 = time.time() p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) - stdout, stderr = p.communicate() + try: + stdout, stderr = p.communicate(timeout=420) + errored = p.returncode != 0 + except subprocess.TimeoutExpired: + p.kill() + stdout, stderr = p.communicate() + print('--- TEST TIMEOUT ---') + errored = True t1 = time.time() - errored = p.returncode != 0 if errored: if stdout: print('--- STDOUT ---') @@ -97,6 +104,8 @@ def run_examples(keep_artifacts=None): output_dir = tempfile.mkdtemp(dir=parent_output) # resolve path to avoid some issues with TEMPDIR on Windows output_dir = str(Path(output_dir).resolve()) + example_name = Path(example_path).parent.name + test_with_spaces = example_name in WITH_SPACES cmd = COV_CMD + ['constructor', '-v', example_path, '--output-dir', output_dir] creation_errored = _execute(cmd) errored += creation_errored @@ -105,7 +114,8 @@ def run_examples(keep_artifacts=None): if fpath in tested_files or ext not in ('sh', 'exe', 'pkg'): continue tested_files.add(fpath) - env_dir = tempfile.mkdtemp(dir=output_dir) + test_suffix = "s p a c e s" if test_with_spaces else None + env_dir = tempfile.mkdtemp(suffix=test_suffix, dir=output_dir) rm_rf(env_dir) print('--- Testing %s' % fpath) fpath = os.path.join(output_dir, fpath) @@ -169,8 +179,10 @@ def run_examples(keep_artifacts=None): print('--- LOGS ---') print("Tip: Debug locally and check the full logs in the Installer UI") print(" or check /var/log/install.log if run from the CLI.") - elif ext == "exe": + elif ext == "exe" and not test_with_spaces: # The installer succeeded, test the uninstaller on Windows + # The un-installers are only tested when testing without spaces, as they hang during + # testing but work in UI mode. uninstaller = next((p for p in os.listdir(env_dir) if p.startswith("Uninstall-")), None) if uninstaller: cmd = [ @@ -182,7 +194,12 @@ def run_examples(keep_artifacts=None): # the tempdir cleanup later f"/S _?={env_dir}" ] - _execute(cmd) + test_errored = _execute(cmd) + errored += test_errored + if test_errored: + which_errored.setdefault(example_path, []).append( + "Wrong uninstall exit code or timeout." + ) paths_after_uninstall = os.listdir(env_dir) if len(paths_after_uninstall) > 2: # The debug installer writes to install.log too, which will only diff --git a/tests/test_header.py b/tests/test_header.py index 9d972056b..343363a99 100644 --- a/tests/test_header.py +++ b/tests/test_header.py @@ -1,6 +1,11 @@ -from constructor.shar import read_header_template, preprocess +import os + import pytest +from constructor.shar import read_header_template +from constructor.utils import preprocess +from constructor.osxpkg import OSX_DIR + @pytest.mark.parametrize('osx', [False, True]) @pytest.mark.parametrize('direct_execute_post_install', [False, True]) @@ -13,11 +18,12 @@ @pytest.mark.parametrize('initialize_by_default', [False, True]) @pytest.mark.parametrize('has_post_install', [False, True]) @pytest.mark.parametrize('has_pre_install', [False, True]) +@pytest.mark.parametrize('check_path_spaces', [False, True]) @pytest.mark.parametrize('arch', ['x86', 'x86_64', ' ppc64le', 's390x', 'aarch64']) def test_linux_template_processing( osx, arch, has_pre_install, has_post_install, initialize_conda, initialize_by_default, has_license, has_conda, keep_pkgs, batch_mode, - direct_execute_pre_install, direct_execute_post_install): + direct_execute_pre_install, direct_execute_post_install, check_path_spaces): template = read_header_template() processed = preprocess(template, { 'has_license': has_license, @@ -37,7 +43,31 @@ def test_linux_template_processing( 'direct_execute_post_install': direct_execute_post_install, 'initialize_conda': initialize_conda, 'initialize_by_default': initialize_by_default, + 'check_path_spaces': check_path_spaces, + }) assert '#if' not in processed assert '#else' not in processed assert '#endif' not in processed + + +@pytest.mark.parametrize("arch", ["x86_64", "arm64"]) +@pytest.mark.parametrize("check_path_spaces", [False, True]) +@pytest.mark.parametrize( + "script", + [ + "checks_before_install.sh", + "prepare_installation.sh", + "run_installation.sh", + "update_path.sh", + "clean_cache.sh", + "run_user_script.sh", + ] +) +def test_osxpkg_template_processing(arch, check_path_spaces, script): + with open(os.path.join(OSX_DIR, script)) as f: + data = f.read() + processed = preprocess(data, {"arch": arch, "check_path_spaces": check_path_spaces}) + assert "#if" not in processed + assert "#else" not in processed + assert "#endif" not in processed \ No newline at end of file