Skip to content

Commit 3b3e16f

Browse files
committed
Generalize package name, add -Environment for Win/Linux
1 parent ba28bbe commit 3b3e16f

File tree

8 files changed

+51
-34
lines changed

8 files changed

+51
-34
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ on: # yamllint disable-line rule:truthy
1616
# Allows you to run this workflow manually from the Actions tab
1717
workflow_dispatch:
1818

19+
env:
20+
PROJECT_NAME: "Scientific-Python"
21+
1922
jobs:
2023
# Build installers
2124
build_macos:
@@ -68,7 +71,7 @@ jobs:
6871
- uses: actions/upload-artifact@v4
6972
with:
7073
name: ${{ env.SP_INSTALLER_ARTIFACT_ID }}
71-
path: Scientific-Python-*.*
74+
path: ${{ env.PROJECT_NAME }}-*.*
7275
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
7376

7477
build_linux:
@@ -94,7 +97,7 @@ jobs:
9497
- uses: actions/upload-artifact@v4
9598
with:
9699
name: ${{ env.SP_INSTALLER_ARTIFACT_ID }}
97-
path: Scientific-Python-*.*
100+
path: ${{ env.PROJECT_NAME }}-*.*
98101
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
99102

100103
build_windows:
@@ -122,7 +125,7 @@ jobs:
122125
- uses: actions/upload-artifact@v4
123126
with:
124127
name: ${{ env.SP_INSTALLER_ARTIFACT_ID }}
125-
path: Scientific-Python-*.*
128+
path: ${{ env.PROJECT_NAME }}-*.*
126129
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
127130

128131
# Test
@@ -158,7 +161,7 @@ jobs:
158161
- uses: actions/upload-artifact@v4
159162
with:
160163
name: ${{ env.SP_INSTALLER_ARTIFACT_ID }}-json
161-
path: Scientific-Python-*.env.json
164+
path: ${{ env.PROJECT_NAME }}-*.env.json
162165
# upload just one for each installer version
163166
if: matrix.os == 'macos-13' || matrix.os == 'macos-14'
164167
- uses: pyvista/setup-headless-display-action@main
@@ -192,7 +195,7 @@ jobs:
192195
- uses: actions/upload-artifact@v4
193196
with:
194197
name: ${{ env.SP_INSTALLER_ARTIFACT_ID }}-json
195-
path: Scientific-Python-*.env.json
198+
path: ${{ env.PROJECT_NAME }}-*.env.json
196199
# upload just one for each installer version
197200
if: matrix.os == 'ubuntu-24.04'
198201
- uses: pyvista/setup-headless-display-action@main
@@ -227,7 +230,7 @@ jobs:
227230
- uses: actions/upload-artifact@v4
228231
with:
229232
name: ${{ env.SP_INSTALLER_ARTIFACT_ID }}-json
230-
path: Scientific-Python-*.env.json
233+
path: ${{ env.PROJECT_NAME}}-*.env.json
231234
# upload just one for each installer version
232235
if: matrix.os == 'windows-2022'
233236
- uses: pyvista/setup-headless-display-action@main
@@ -250,12 +253,12 @@ jobs:
250253
# These names should correspond to SP_INSTALLER_ARTIFACT_ID in tools/extract_version.sh
251254
- uses: actions/download-artifact@v4
252255
with:
253-
pattern: Scientific-Python-*
256+
pattern: ${{ env.PROJECT_NAME }}-Python-*
254257
merge-multiple: true
255258
- run: ls -al ./
256259
- uses: ncipollo/release-action@v1
257260
with:
258-
artifacts: "Scientific-Python-*.*"
261+
artifacts: "${{ env.PROJECT_NAME }}-*.*"
259262
token: ${{ secrets.GITHUB_TOKEN }}
260263
draft: true
261264
prerelease: true

Makefile

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Makefile targets for local build steps on Mac.
22
SHELL := bash
3+
ENV_EXE ?= conda
4+
PROJECT_NAME=Scientific-Python
5+
PROJECT_NAME_LOWER=$(shell echo $(PROJECT_NAME) | tr A-Z a-z)
6+
37
MENU_PKG_NAME=sp-installer-menu
48
ROOT_PREFIX=$(shell conda config --show root_prefix | cut -d ' ' -f 2)
59
ENV_PKGS=$(ROOT_PREFIX)/pkgs
@@ -23,27 +27,30 @@ menu-pkg:
2327
conda-build $(MENU_PKG_NAME) --no-anaconda-upload --croot conda-bld
2428

2529
installer:
26-
constructor recipes/scientific-python
30+
constructor recipes/$(PROJECT_NAME_LOWER)
2731

2832
install:
2933
@if [[ $(MACHINE) == "macOS" ]]; then \
30-
installer -pkg Scientific-Python-*.pkg -target CurrentUserHomeDirectory; \
34+
installer -pkg $(PROJECT_NAME)-*.pkg -target CurrentUserHomeDirectory; \
3135
elif [[ $(MACHINE) == "Linux" ]]; then \
32-
sh ./Scientific-Python-*-Linux.sh; \
36+
sh ./$(PROJECT_NAME)-*-Linux.sh; \
3337
elif [[ $(MACHINE) == "Windows" ]]; then \
3438
echo "TODO add install command for Windows"; \
3539
fi
3640

41+
env:
42+
$(ENV_EXE) env create -y -f environment.yml
43+
3744
clean:
3845
@rm -rf conda-bld
3946
@rm -rf ~/.conda/constructor/*/$(MENU_PKG_NAME)*
4047
@if [[ $(MACHINE) == "macOS" ]]; then \
41-
rm -rf ~/Applications/*Scientific*; \
48+
rm -rf ~/Applications/$(PROJECT_NAME)*; \
4249
rm -f Scientific-Python-*.pkg; \
4350
elif [[ $(MACHINE) == "Linux" ]]; then \
4451
rm -rf $(HOME)/Scientific-Python; \
4552
rm -f ./Scientific-Python-*.sh; \
46-
rm -f $(HOME)/.local/share/applications/scientific-python-*.desktop; \
53+
rm -f $(HOME)/.local/share/applications/$(PROJECT_NAME_LOWER)-*.desktop; \
4754
elif [[ $(MACHINE) == "Windows" ]]; then \
4855
echo "TODO add command to cleanup icons on Windows"; \
4956
fi

recipes/scientific-python/construct.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ conclusion_file: ../../assets/conclusion.rtf # [not win]
1818
initialize_by_default: false
1919
register_python_default: false
2020

21-
default_prefix: ${HOME}/Scientific-Python # [linux]
22-
default_prefix: "%USERPROFILE%\\Scientific-Python" # [win]
23-
default_prefix_domain_user: "%LOCALAPPDATA%\\Scientific-Python" # [win]
24-
default_prefix_all_users: "%ALLUSERSPROFILE%\\Scientific-Python" # [win]
21+
default_prefix: ${HOME}/Scientific-Python-Environment # [linux]
22+
default_prefix: "%USERPROFILE%\\Scientific-Python-Environment" # [win]
23+
default_prefix_domain_user: "%LOCALAPPDATA%\\Scientific-Python-Environment" # [win]
24+
default_prefix_all_users: "%ALLUSERSPROFILE%\\Scientific-Python-Environment" # [win]
2525
default_location_pkg: "Applications/Scientific-Python" # [osx]
2626
pkg_name: ".Scientific-Python" # [osx]
2727
progress_notifications: true # [osx]

tests/test_imports.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import argparse
22
import importlib
3-
import platform
43
from pathlib import Path
54
import re
65

@@ -44,6 +43,7 @@ def check_version_eq(package, ver):
4443
)
4544
constructs = yaml.load(construct_path.read_text(), Loader=yaml.SafeLoader)
4645
specs = constructs["specs"]
46+
menu_pkg_name = constructs['menu_packages'][0]
4747

4848
# Now do the importing and version checking
4949
# Conda packages that do not provide a Python importable module.
@@ -57,7 +57,7 @@ def check_version_eq(package, ver):
5757
"git",
5858
"make",
5959
"libffi",
60-
"sp-installer-menu",
60+
menu_pkg_name,
6161
}
6262

6363
# PyPI name to import name map.

tests/test_json_versions.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,26 @@
3131
construct_yaml_path = recipe_dir / "construct.yaml"
3232
params = yaml.safe_load(construct_yaml_path.read_text(encoding="utf-8"))
3333
installer_version = params["version"]
34+
project_name = params["name"]
3435
specs = params["specs"]
36+
menu_pkg_name = params['menu_packages'][0]
3537
del params
3638

3739
# Want versions apply to versions specific to this installer.
3840
want_versions = {}
3941
for spec in specs:
40-
if " =" not in spec or 'sp-installer-menu' not in spec:
42+
if " =" not in spec or menu_pkg_name not in spec:
4143
continue
4244
package_name, package_version_and_build = spec.split(" ")
4345
print('pkg name', package_name)
4446
package_version = package_version_and_build.split("=")[1]
4547
want_versions[package_name] = {"version": package_version}
46-
assert 'sp-installer-menu' in want_versions, \
47-
"sp-installer-menu missing from want_versions (build str error)"
48+
assert menu_pkg_name in want_versions, \
49+
f"{menu_pkg_name} missing from want_versions (build str error)"
4850
assert len(want_versions) == 1, len(want_versions) # more than just the one above
4951

5052
# Extract versions from created environment
51-
fname = dir_ / f"Scientific-Python-{installer_version}-{sys_name}{sys_ext}.env.json"
53+
fname = dir_ / f"{project_name}-{installer_version}-{sys_name}{sys_ext}.env.json"
5254
assert fname.is_file(), (fname, os.listdir(os.getcwd()))
5355
env_json = json.loads(fname.read_text(encoding="utf-8"))
5456
got_versions = dict()

tests/test_outdated.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,13 @@ def get_conda_json(package):
103103

104104
outdated = []
105105
not_found = []
106+
constructs = yaml.load(recipe, Loader=yaml.SafeLoader)
107+
menu_pkg_name = constructs['menu_packages'][0]
108+
106109
for package in packages:
107110
if package.version_spec is None:
108111
continue
109-
elif package.name == "sp-installer-menu": # locally built
112+
elif package.name == menu_pkg_name: # locally built
110113
# TODO instead of skipping, we should get the version number from the env
111114
# and test that it matches the version in `construct.yaml`
112115
continue

tools/calculate_installer_hash.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -eo pipefail
44

55
shopt -s nullglob # Fail if the following pattern yields no results
66
echo "Finding matches"
7-
matches=(Scientific-Python-*-*.*)
7+
matches=(${PROJECT_NAME}-*-*.*)
88
echo "Extracting fname"
99
installer_fname="${matches[0]}"
1010
echo "Found name: ${installer_fname}"

tools/extract_version.sh

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/bin/bash -ef
22

33
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )";
4-
export RECIPE_DIR=${SCRIPT_DIR}/../recipes/scientific-python
5-
export SP_INSTALLER_VERSION=$(grep "^version: .*$" ${RECIPE_DIR}/construct.yaml | cut -d' ' -f2)
4+
export RECIPE_DIR=$(ls -d ${SCRIPT_DIR}/../recipes/*)
5+
export CONSTRUCT_YML=${RECIPE_DIR}/construct.yaml
6+
export SP_INSTALLER_VERSION=$(grep "^version: .*$" ${CONSTRUCT_YML} | cut -d' ' -f2)
7+
export PROJECT_NAME=$(grep "^name: .*$" ${CONSTRUCT_YML} | cut -d' ' -f2)
68
export PYSHORT=$(python -c "import sys; print('.'.join(map(str, sys.version_info[:2])))")
79
UNAME="$(uname -s)"
810
if [[ "$1" != "" ]] && [[ "$1" != "--dry-run" ]]; then
@@ -40,23 +42,23 @@ fi
4042
export MACOS_ARCH=$MACOS_ARCH
4143

4244
if [[ "$MACHINE" == "macOS" ]]; then
43-
SP_INSTALL_PREFIX="/Applications/Scientific-Python/.scientific-python"
44-
SP_INSTALLER_NAME="Scientific-Python-${SP_INSTALLER_VERSION}-${MACHINE}_${MACOS_ARCH}.pkg"
45+
SP_INSTALL_PREFIX="/Applications/${PROJECT_NAME}/.scientific-python"
46+
SP_INSTALLER_NAME="${PROJECT_NAME}-${SP_INSTALLER_VERSION}-${MACHINE}_${MACOS_ARCH}.pkg"
4547
SP_ACTIVATE="$SP_INSTALL_PREFIX/bin/activate"
4648
elif [[ "$MACHINE" == "Linux" ]]; then
47-
SP_INSTALL_PREFIX="$HOME/Scientific-Python"
48-
SP_INSTALLER_NAME="Scientific-Python-${SP_INSTALLER_VERSION}-${MACHINE}.sh"
49+
SP_INSTALL_PREFIX="$HOME/${PROJECT_NAME}-Environment"
50+
SP_INSTALLER_NAME="${PROJECT_NAME}-${SP_INSTALLER_VERSION}-${MACHINE}.sh"
4951
SP_ACTIVATE="$SP_INSTALL_PREFIX/bin/activate"
5052
else
51-
SP_INSTALL_PREFIX="$HOME/Scientific-Python"
52-
SP_INSTALLER_NAME="Scientific-Python-${SP_INSTALLER_VERSION}-${MACHINE}.exe"
53+
SP_INSTALL_PREFIX="$HOME/${PROJECT_NAME}-Environment"
54+
SP_INSTALLER_NAME="${PROJECT_NAME}-${SP_INSTALLER_VERSION}-${MACHINE}.exe"
5355
SP_ACTIVATE="$SP_INSTALL_PREFIX/Scripts/activate"
5456
fi
5557

5658
export SP_INSTALL_PREFIX="$SP_INSTALL_PREFIX"
5759
export SP_INSTALLER_NAME="${SP_INSTALLER_NAME}"
5860
export SP_ACTIVATE="$SP_ACTIVATE"
59-
export SP_INSTALLER_ARTIFACT_ID="Scientific-Python-${MACHINE}-${ARTIFACT_ID_SUFFIX}"
61+
export SP_INSTALLER_ARTIFACT_ID="${PROJECT_NAME}-Python-${MACHINE}-${ARTIFACT_ID_SUFFIX}"
6062
export SP_MACHINE="$MACHINE"
6163

6264
echo "Version: ${SP_INSTALLER_VERSION}"

0 commit comments

Comments
 (0)