From 832ac6f63bc93652b63d8e9cf24714b8b7402efa Mon Sep 17 00:00:00 2001 From: Ferris <3579192+code-ape@users.noreply.github.com> Date: Thu, 21 Dec 2023 11:47:50 -0500 Subject: [PATCH] Isolated issue case and fixed script --- .github/workflows/nexe-ci.yml | 6 +++-- bin/build_nexe | 44 ++++++++++++++++++++++++----------- bin/install_dependencies | 18 ++++++++------ 3 files changed, 46 insertions(+), 22 deletions(-) diff --git a/.github/workflows/nexe-ci.yml b/.github/workflows/nexe-ci.yml index 2bc29e8..cefa4c3 100644 --- a/.github/workflows/nexe-ci.yml +++ b/.github/workflows/nexe-ci.yml @@ -20,8 +20,10 @@ jobs: matrix: # TODO: Bump to windows-latest once it can be solved how to install Python2 # such that the Node.js build system can detect it. - os: [ubuntu-latest, windows-2019, macos-latest] - node_version: ['14.16.0', '14.18.0', '14.18.1', '16.11.0', '16.13.0', '16.13.1', '16.19.0', '18.14.0', '18.19.0'] + #os: [ubuntu-latest, windows-2019, macos-latest] + os: [macos-latest] + #node_version: ['14.16.0', '14.18.0', '14.18.1', '16.11.0', '16.13.0', '16.13.1', '16.19.0', '18.14.0', '18.19.0'] + node_version: ['18.19.0'] steps: - uses: actions/checkout@v3 diff --git a/bin/build_nexe b/bin/build_nexe index 4990c24..3d19638 100755 --- a/bin/build_nexe +++ b/bin/build_nexe @@ -100,28 +100,46 @@ function main(){ cpu_core_count="$(sysctl -n hw.ncpu)" ;; esac + echo "cpu_core_count=$cpu_core_count" - python2_path="$(which python2)" - python3_path="$(which python3)" + # Get Python installation details + if command -v python2 &> /dev/null; then + python2_path="$(which python2)" + fi + if command -v python3 &> /dev/null; then + python3_path="$(which python3)" + fi echo "python2_path=$python2_path" echo "python3_path=$python3_path" + if [ "$python2_path" = "" ] && [ "$python3_path" = "" ]; then + echo "Could NOT find python2 or python3 installation. Exiting!" + exit 1 + fi + nexe_part_1_cmd="nexe --build --verbose --no-mangle --target=$nexe_target --make=-j$cpu_core_count" nexe_part_3_cmd="-o $nexe_no_mangle_path '$repo_dir/index.js'" echo "console.log('TEST NEXE SCRIPT'); console.log(process.version); var os = require('os'); console.log('os.userInfo() =', os.userInfo());" > "$repo_dir/index.js" - echo "Building $nexe_no_mangle_name (python 3)" - nexe_cmd="$nexe_part_1_cmd --python=$python3_path $nexe_part_3_cmd" - echo " $nexe_cmd" - set +e - time npx $nexe_cmd || build_failed="true" - set -e - if [ "$build_failed" = "true" ]; then - echo "Trying fallback to python2 ..." - echo "Building $nexe_no_mangle_name (python 2)" - nexe_cmd="$nexe_part_1_cmd --python=$python2_path $nexe_part_3_cmd" + + if [ "$python3_path" != "" ]; then + echo "Building $nexe_no_mangle_name (python 3)" + nexe_cmd="$nexe_part_1_cmd --python=$python3_path $nexe_part_3_cmd" echo " $nexe_cmd" - time npx $nexe_cmd + set +e + time npx $nexe_cmd || build_failed="true" + set -e fi + if [ "$build_failed" = "true" ] && [ "$python2_path" = "" ]; then + echo "No python2 installation found to try. Exiting with error." + exit 1 + fi + + echo "Trying fallback to python2 ..." + echo "Building $nexe_no_mangle_name (python 2)" + nexe_cmd="$nexe_part_1_cmd --python=$python2_path $nexe_part_3_cmd" + echo " $nexe_cmd" + time npx $nexe_cmd + echo "Build finished." rm "$repo_dir/index.js" # Not compressing right now because nexe currently doesn't support downloading diff --git a/bin/install_dependencies b/bin/install_dependencies index c4ff97e..4c457ad 100755 --- a/bin/install_dependencies +++ b/bin/install_dependencies @@ -20,13 +20,17 @@ case "$os_env" in "linux") echo "Dependencies installed via container (skipping)" ;; - # Temporarily disabling as it was causing build to fail for unknown reasons - #"mac") - # echo "Installing macos dependencies ..." - # set -x - # brew install ccache - # set +x - # ;; + "mac") + echo "Installing macos dependencies ..." + set -x + # Temporarily disabling as it was causing build to fail for unknown reasons + #brew install ccache + brew install pyenv + pyenv install 2.7.18 + export PATH="$(pyenv root)/shims:${PATH}" + which python2 + set +x + ;; *) echo "No dependencies to install for '$os_env'" ;;