Skip to content
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
19 changes: 11 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
10 changes: 5 additions & 5 deletions recipes/scientific-python/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/test_imports.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import argparse
import importlib
import platform
from pathlib import Path
import re

Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
10 changes: 6 additions & 4 deletions tests/test_json_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 4 additions & 1 deletion tests/test_outdated.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tools/calculate_installer_hash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
20 changes: 11 additions & 9 deletions tools/extract_version.sh
Original file line number Diff line number Diff line change
@@ -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 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])))")
UNAME="$(uname -s)"
if [[ "$1" != "" ]] && [[ "$1" != "--dry-run" ]]; then
Expand Down Expand Up @@ -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}-${MACHINE}-${ARTIFACT_ID_SUFFIX}"
export SP_MACHINE="$MACHINE"

echo "Version: ${SP_INSTALLER_VERSION}"
Expand Down