From 3b3e16f638b9144df0bd896f15617d54222cc891 Mon Sep 17 00:00:00 2001 From: Matthew Brett Date: Sat, 31 May 2025 18:19:46 +0100 Subject: [PATCH 1/4] Generalize package name, add -Environment for Win/Linux --- .github/workflows/build.yml | 19 +++++++++++-------- Makefile | 17 ++++++++++++----- recipes/scientific-python/construct.yaml | 8 ++++---- tests/test_imports.py | 4 ++-- tests/test_json_versions.py | 10 ++++++---- tests/test_outdated.py | 5 ++++- tools/calculate_installer_hash.sh | 2 +- tools/extract_version.sh | 20 +++++++++++--------- 8 files changed, 51 insertions(+), 34 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b84c311..268abaa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,6 +16,9 @@ on: # yamllint disable-line rule:truthy # Allows you to run this workflow manually from the Actions tab workflow_dispatch: +env: + PROJECT_NAME: "Scientific-Python" + jobs: # Build installers build_macos: @@ -68,7 +71,7 @@ jobs: - uses: actions/upload-artifact@v4 with: name: ${{ env.SP_INSTALLER_ARTIFACT_ID }} - path: Scientific-Python-*.* + path: ${{ env.PROJECT_NAME }}-*.* retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }} build_linux: @@ -94,7 +97,7 @@ jobs: - uses: actions/upload-artifact@v4 with: name: ${{ env.SP_INSTALLER_ARTIFACT_ID }} - path: Scientific-Python-*.* + path: ${{ env.PROJECT_NAME }}-*.* retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }} build_windows: @@ -122,7 +125,7 @@ jobs: - uses: actions/upload-artifact@v4 with: name: ${{ env.SP_INSTALLER_ARTIFACT_ID }} - path: Scientific-Python-*.* + path: ${{ env.PROJECT_NAME }}-*.* retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }} # Test @@ -158,7 +161,7 @@ jobs: - uses: actions/upload-artifact@v4 with: name: ${{ env.SP_INSTALLER_ARTIFACT_ID }}-json - path: Scientific-Python-*.env.json + path: ${{ env.PROJECT_NAME }}-*.env.json # upload just one for each installer version if: matrix.os == 'macos-13' || matrix.os == 'macos-14' - uses: pyvista/setup-headless-display-action@main @@ -192,7 +195,7 @@ jobs: - uses: actions/upload-artifact@v4 with: name: ${{ env.SP_INSTALLER_ARTIFACT_ID }}-json - path: Scientific-Python-*.env.json + path: ${{ env.PROJECT_NAME }}-*.env.json # upload just one for each installer version if: matrix.os == 'ubuntu-24.04' - uses: pyvista/setup-headless-display-action@main @@ -227,7 +230,7 @@ jobs: - uses: actions/upload-artifact@v4 with: name: ${{ env.SP_INSTALLER_ARTIFACT_ID }}-json - path: Scientific-Python-*.env.json + path: ${{ env.PROJECT_NAME}}-*.env.json # upload just one for each installer version if: matrix.os == 'windows-2022' - uses: pyvista/setup-headless-display-action@main @@ -250,12 +253,12 @@ jobs: # These names should correspond to SP_INSTALLER_ARTIFACT_ID in tools/extract_version.sh - uses: actions/download-artifact@v4 with: - pattern: Scientific-Python-* + pattern: ${{ env.PROJECT_NAME }}-Python-* merge-multiple: true - run: ls -al ./ - uses: ncipollo/release-action@v1 with: - artifacts: "Scientific-Python-*.*" + artifacts: "${{ env.PROJECT_NAME }}-*.*" token: ${{ secrets.GITHUB_TOKEN }} draft: true prerelease: true diff --git a/Makefile b/Makefile index d8f71a6..5d51fa4 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,9 @@ # Makefile targets for local build steps on Mac. SHELL := bash +ENV_EXE ?= conda +PROJECT_NAME=Scientific-Python +PROJECT_NAME_LOWER=$(shell echo $(PROJECT_NAME) | tr A-Z a-z) + MENU_PKG_NAME=sp-installer-menu ROOT_PREFIX=$(shell conda config --show root_prefix | cut -d ' ' -f 2) ENV_PKGS=$(ROOT_PREFIX)/pkgs @@ -23,27 +27,30 @@ menu-pkg: conda-build $(MENU_PKG_NAME) --no-anaconda-upload --croot conda-bld installer: - constructor recipes/scientific-python + constructor recipes/$(PROJECT_NAME_LOWER) install: @if [[ $(MACHINE) == "macOS" ]]; then \ - installer -pkg Scientific-Python-*.pkg -target CurrentUserHomeDirectory; \ + installer -pkg $(PROJECT_NAME)-*.pkg -target CurrentUserHomeDirectory; \ elif [[ $(MACHINE) == "Linux" ]]; then \ - sh ./Scientific-Python-*-Linux.sh; \ + sh ./$(PROJECT_NAME)-*-Linux.sh; \ elif [[ $(MACHINE) == "Windows" ]]; then \ echo "TODO add install command for Windows"; \ fi +env: + $(ENV_EXE) env create -y -f environment.yml + clean: @rm -rf conda-bld @rm -rf ~/.conda/constructor/*/$(MENU_PKG_NAME)* @if [[ $(MACHINE) == "macOS" ]]; then \ - rm -rf ~/Applications/*Scientific*; \ + rm -rf ~/Applications/$(PROJECT_NAME)*; \ rm -f Scientific-Python-*.pkg; \ elif [[ $(MACHINE) == "Linux" ]]; then \ rm -rf $(HOME)/Scientific-Python; \ rm -f ./Scientific-Python-*.sh; \ - rm -f $(HOME)/.local/share/applications/scientific-python-*.desktop; \ + rm -f $(HOME)/.local/share/applications/$(PROJECT_NAME_LOWER)-*.desktop; \ elif [[ $(MACHINE) == "Windows" ]]; then \ echo "TODO add command to cleanup icons on Windows"; \ fi diff --git a/recipes/scientific-python/construct.yaml b/recipes/scientific-python/construct.yaml index b2bc25e..8120c10 100644 --- a/recipes/scientific-python/construct.yaml +++ b/recipes/scientific-python/construct.yaml @@ -18,10 +18,10 @@ conclusion_file: ../../assets/conclusion.rtf # [not win] initialize_by_default: false register_python_default: false -default_prefix: ${HOME}/Scientific-Python # [linux] -default_prefix: "%USERPROFILE%\\Scientific-Python" # [win] -default_prefix_domain_user: "%LOCALAPPDATA%\\Scientific-Python" # [win] -default_prefix_all_users: "%ALLUSERSPROFILE%\\Scientific-Python" # [win] +default_prefix: ${HOME}/Scientific-Python-Environment # [linux] +default_prefix: "%USERPROFILE%\\Scientific-Python-Environment" # [win] +default_prefix_domain_user: "%LOCALAPPDATA%\\Scientific-Python-Environment" # [win] +default_prefix_all_users: "%ALLUSERSPROFILE%\\Scientific-Python-Environment" # [win] default_location_pkg: "Applications/Scientific-Python" # [osx] pkg_name: ".Scientific-Python" # [osx] progress_notifications: true # [osx] diff --git a/tests/test_imports.py b/tests/test_imports.py index a745da2..c221da0 100644 --- a/tests/test_imports.py +++ b/tests/test_imports.py @@ -1,6 +1,5 @@ import argparse import importlib -import platform from pathlib import Path import re @@ -44,6 +43,7 @@ def check_version_eq(package, ver): ) constructs = yaml.load(construct_path.read_text(), Loader=yaml.SafeLoader) specs = constructs["specs"] +menu_pkg_name = constructs['menu_packages'][0] # Now do the importing and version checking # Conda packages that do not provide a Python importable module. @@ -57,7 +57,7 @@ def check_version_eq(package, ver): "git", "make", "libffi", - "sp-installer-menu", + menu_pkg_name, } # PyPI name to import name map. diff --git a/tests/test_json_versions.py b/tests/test_json_versions.py index 135005a..ef7d953 100644 --- a/tests/test_json_versions.py +++ b/tests/test_json_versions.py @@ -31,24 +31,26 @@ construct_yaml_path = recipe_dir / "construct.yaml" params = yaml.safe_load(construct_yaml_path.read_text(encoding="utf-8")) installer_version = params["version"] +project_name = params["name"] specs = params["specs"] +menu_pkg_name = params['menu_packages'][0] del params # Want versions apply to versions specific to this installer. want_versions = {} for spec in specs: - if " =" not in spec or 'sp-installer-menu' not in spec: + if " =" not in spec or menu_pkg_name not in spec: continue package_name, package_version_and_build = spec.split(" ") print('pkg name', package_name) package_version = package_version_and_build.split("=")[1] want_versions[package_name] = {"version": package_version} -assert 'sp-installer-menu' in want_versions, \ - "sp-installer-menu missing from want_versions (build str error)" +assert menu_pkg_name in want_versions, \ + f"{menu_pkg_name} missing from want_versions (build str error)" assert len(want_versions) == 1, len(want_versions) # more than just the one above # Extract versions from created environment -fname = dir_ / f"Scientific-Python-{installer_version}-{sys_name}{sys_ext}.env.json" +fname = dir_ / f"{project_name}-{installer_version}-{sys_name}{sys_ext}.env.json" assert fname.is_file(), (fname, os.listdir(os.getcwd())) env_json = json.loads(fname.read_text(encoding="utf-8")) got_versions = dict() diff --git a/tests/test_outdated.py b/tests/test_outdated.py index 46609f1..b43cb7f 100644 --- a/tests/test_outdated.py +++ b/tests/test_outdated.py @@ -103,10 +103,13 @@ def get_conda_json(package): outdated = [] not_found = [] +constructs = yaml.load(recipe, Loader=yaml.SafeLoader) +menu_pkg_name = constructs['menu_packages'][0] + for package in packages: if package.version_spec is None: continue - elif package.name == "sp-installer-menu": # locally built + elif package.name == menu_pkg_name: # locally built # TODO instead of skipping, we should get the version number from the env # and test that it matches the version in `construct.yaml` continue diff --git a/tools/calculate_installer_hash.sh b/tools/calculate_installer_hash.sh index 69a2755..59e3d9b 100755 --- a/tools/calculate_installer_hash.sh +++ b/tools/calculate_installer_hash.sh @@ -4,7 +4,7 @@ set -eo pipefail shopt -s nullglob # Fail if the following pattern yields no results echo "Finding matches" -matches=(Scientific-Python-*-*.*) +matches=(${PROJECT_NAME}-*-*.*) echo "Extracting fname" installer_fname="${matches[0]}" echo "Found name: ${installer_fname}" diff --git a/tools/extract_version.sh b/tools/extract_version.sh index ce04dad..a490e87 100755 --- a/tools/extract_version.sh +++ b/tools/extract_version.sh @@ -1,8 +1,10 @@ #!/bin/bash -ef SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )"; -export RECIPE_DIR=${SCRIPT_DIR}/../recipes/scientific-python -export SP_INSTALLER_VERSION=$(grep "^version: .*$" ${RECIPE_DIR}/construct.yaml | cut -d' ' -f2) +export RECIPE_DIR=$(ls -d ${SCRIPT_DIR}/../recipes/*) +export CONSTRUCT_YML=${RECIPE_DIR}/construct.yaml +export SP_INSTALLER_VERSION=$(grep "^version: .*$" ${CONSTRUCT_YML} | cut -d' ' -f2) +export PROJECT_NAME=$(grep "^name: .*$" ${CONSTRUCT_YML} | cut -d' ' -f2) export PYSHORT=$(python -c "import sys; print('.'.join(map(str, sys.version_info[:2])))") UNAME="$(uname -s)" if [[ "$1" != "" ]] && [[ "$1" != "--dry-run" ]]; then @@ -40,23 +42,23 @@ fi export MACOS_ARCH=$MACOS_ARCH if [[ "$MACHINE" == "macOS" ]]; then - SP_INSTALL_PREFIX="/Applications/Scientific-Python/.scientific-python" - SP_INSTALLER_NAME="Scientific-Python-${SP_INSTALLER_VERSION}-${MACHINE}_${MACOS_ARCH}.pkg" + SP_INSTALL_PREFIX="/Applications/${PROJECT_NAME}/.scientific-python" + SP_INSTALLER_NAME="${PROJECT_NAME}-${SP_INSTALLER_VERSION}-${MACHINE}_${MACOS_ARCH}.pkg" SP_ACTIVATE="$SP_INSTALL_PREFIX/bin/activate" elif [[ "$MACHINE" == "Linux" ]]; then - SP_INSTALL_PREFIX="$HOME/Scientific-Python" - SP_INSTALLER_NAME="Scientific-Python-${SP_INSTALLER_VERSION}-${MACHINE}.sh" + SP_INSTALL_PREFIX="$HOME/${PROJECT_NAME}-Environment" + SP_INSTALLER_NAME="${PROJECT_NAME}-${SP_INSTALLER_VERSION}-${MACHINE}.sh" SP_ACTIVATE="$SP_INSTALL_PREFIX/bin/activate" else - SP_INSTALL_PREFIX="$HOME/Scientific-Python" - SP_INSTALLER_NAME="Scientific-Python-${SP_INSTALLER_VERSION}-${MACHINE}.exe" + SP_INSTALL_PREFIX="$HOME/${PROJECT_NAME}-Environment" + SP_INSTALLER_NAME="${PROJECT_NAME}-${SP_INSTALLER_VERSION}-${MACHINE}.exe" SP_ACTIVATE="$SP_INSTALL_PREFIX/Scripts/activate" fi export SP_INSTALL_PREFIX="$SP_INSTALL_PREFIX" export SP_INSTALLER_NAME="${SP_INSTALLER_NAME}" export SP_ACTIVATE="$SP_ACTIVATE" -export SP_INSTALLER_ARTIFACT_ID="Scientific-Python-${MACHINE}-${ARTIFACT_ID_SUFFIX}" +export SP_INSTALLER_ARTIFACT_ID="${PROJECT_NAME}-Python-${MACHINE}-${ARTIFACT_ID_SUFFIX}" export SP_MACHINE="$MACHINE" echo "Version: ${SP_INSTALLER_VERSION}" From c2df2b134696422f38ab8c235940056f2ed904c3 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Sat, 31 May 2025 17:48:31 +0000 Subject: [PATCH 2/4] [autofix.ci] apply automated fixes --- recipes/scientific-python/construct.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/scientific-python/construct.yaml b/recipes/scientific-python/construct.yaml index 8120c10..a223497 100644 --- a/recipes/scientific-python/construct.yaml +++ b/recipes/scientific-python/construct.yaml @@ -105,7 +105,7 @@ specs: - pytest-timeout =2.4.0 - pre-commit =4.2.0 - ruff =0.11.12 - - uv =0.7.8 + - uv =0.7.9 # Doc building - numpydoc =1.8.0 # OS-specific From 67dfce3b67510e15c3edaf69534ffe80f10156b9 Mon Sep 17 00:00:00 2001 From: Matthew Brett Date: Sat, 31 May 2025 19:11:11 +0100 Subject: [PATCH 3/4] Fix search for recipes --- tools/extract_version.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/extract_version.sh b/tools/extract_version.sh index a490e87..a164278 100755 --- a/tools/extract_version.sh +++ b/tools/extract_version.sh @@ -1,8 +1,8 @@ #!/bin/bash -ef SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )"; -export RECIPE_DIR=$(ls -d ${SCRIPT_DIR}/../recipes/*) -export CONSTRUCT_YML=${RECIPE_DIR}/construct.yaml +export CONSTRUCT_YML=$(find ${SCRIPT_DIR}/../recipes -name construct.yaml) +export RECIPE_DIR=$(dirname $CONSTRUCT_YML) export SP_INSTALLER_VERSION=$(grep "^version: .*$" ${CONSTRUCT_YML} | cut -d' ' -f2) export PROJECT_NAME=$(grep "^name: .*$" ${CONSTRUCT_YML} | cut -d' ' -f2) export PYSHORT=$(python -c "import sys; print('.'.join(map(str, sys.version_info[:2])))") From 7bc6239eaffd8f7f33568f3939e07b3e01517c8e Mon Sep 17 00:00:00 2001 From: Daniel McCloy Date: Mon, 2 Jun 2025 09:52:38 -0500 Subject: [PATCH 4/4] fix SP_INSTALLER_ARTIFACT_ID --- tools/extract_version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/extract_version.sh b/tools/extract_version.sh index a164278..304b7da 100755 --- a/tools/extract_version.sh +++ b/tools/extract_version.sh @@ -58,7 +58,7 @@ fi export SP_INSTALL_PREFIX="$SP_INSTALL_PREFIX" export SP_INSTALLER_NAME="${SP_INSTALLER_NAME}" export SP_ACTIVATE="$SP_ACTIVATE" -export SP_INSTALLER_ARTIFACT_ID="${PROJECT_NAME}-Python-${MACHINE}-${ARTIFACT_ID_SUFFIX}" +export SP_INSTALLER_ARTIFACT_ID="${PROJECT_NAME}-${MACHINE}-${ARTIFACT_ID_SUFFIX}" export SP_MACHINE="$MACHINE" echo "Version: ${SP_INSTALLER_VERSION}"