-
Notifications
You must be signed in to change notification settings - Fork 2
Rename vars #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rename vars #15
Changes from all commits
2b87e3b
0319799
35e8031
4d95de9
2fe9609
ad06ec8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,13 @@ | ||
| #!/bin/bash | ||
|
|
||
| # This script must be marked +x to work correctly with the installer! | ||
| # | ||
| # Available variables are those exported in: | ||
| # https://github.com/conda/constructor/blob/main/constructor/header.sh | ||
|
|
||
| set -eo pipefail | ||
|
|
||
| logger -p 'install.info' "ℹ️ Running the custom Scientific Python post-install script." | ||
| logger -p 'install.info' "ℹ️ Running the custom ${INSTALLER_NAME} post-install script." | ||
|
|
||
| # This doesn't appear to be working: even when the installer is run through | ||
| # sudo, SUDO_USER is unset. Leave it here for reference: | ||
|
|
@@ -14,11 +17,11 @@ logger -p 'install.info' "ℹ️ Running the custom Scientific Python post-insta | |
| # ☠️ This is ugly and bound to break, but seems to do the job for now. ☠️ | ||
| # Don't name the variable USER, as this one is already set. | ||
| USER_FROM_HOMEDIR=`basename $HOME` | ||
| SPI_VERSION=`basename "$(dirname $PREFIX)"` | ||
| PKG_VERSION=`basename "$(dirname $PREFIX)"` | ||
| logger -p 'install.info' "📓 USER_FROM_HOMEDIR=$USER_FROM_HOMEDIR" | ||
| logger -p 'install.info' "📓 DSTROOT=$DSTROOT" | ||
| logger -p 'install.info' "📓 PREFIX=$PREFIX" | ||
| logger -p 'install.info' "📓 SPI_VERSION=$SPI_VERSION" | ||
| logger -p 'install.info' "📓 PKG_VERSION=$PKG_VERSION" | ||
|
|
||
| # Guess whether it's a system-wide or only-me install | ||
| if [[ "$PREFIX" == "/Applications/"* ]]; then | ||
|
|
@@ -28,22 +31,23 @@ else | |
| APP_DIR="$HOME"/Applications | ||
| PERMS="" | ||
| fi | ||
| SPI_APP_DIR="${APP_DIR}/Scientific-Python" | ||
| logger -p 'install.info' "📓 SPI_APP_DIR=$SPI_APP_DIR" | ||
| PKG_APP_DIR="${APP_DIR}/${INSTALLER_NAME}" | ||
| logger -p 'install.info' "📓 PKG_APP_DIR=$PKG_APP_DIR" | ||
|
|
||
| logger -p 'install.info' "ℹ️ Moving root SP .app bundles from $APP_DIR to $SPI_APP_DIR." | ||
| $PERMS mv "$APP_DIR"/Scientific\ Python\ *.app "$SPI_APP_DIR"/ | ||
| logger -p 'install.info' "ℹ️ Moving root project .app bundles from $APP_DIR to $PKG_APP_DIR." | ||
| # Set this to match the names generated from the menu package. | ||
| $PERMS mv "${APP_DIR}"/Scientific\ Python\ *.app "$PKG_APP_DIR"/ | ||
|
|
||
| logger -p 'install.info' "ℹ️ Fixing permissions of SP .app bundles in $SPI_APP_DIR: new owner will be ${USER_FROM_HOMEDIR}." | ||
| $PERMS chown -R "$USER_FROM_HOMEDIR" "$SPI_APP_DIR" | ||
| logger -p 'install.info' "ℹ️ Fixing permissions of project .app bundles in $PKG_APP_DIR: new owner will be ${USER_FROM_HOMEDIR}." | ||
| $PERMS chown -R "$USER_FROM_HOMEDIR" "$PKG_APP_DIR" | ||
|
|
||
| SPI_ICON_PATH="${PREFIX}/Menu/spi_mac_folder_icon.png" | ||
| logger -p 'install.info' "ℹ️ Setting custom folder icon for $SPI_APP_DIR and $SPI_APP_DIR_ROOT to $SPI_ICON_PATH." | ||
| for destPath in "$SPI_APP_DIR" "$SPI_APP_DIR_ROOT"; do | ||
| logger -p 'install.info' "ℹ️ Setting custom folder icon for $destPath to $SPI_ICON_PATH." | ||
| PKG_ICON_PATH="${PREFIX}/Menu/spi_mac_folder_icon.png" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we should genericize the image names too, to remove the |
||
| logger -p 'install.info' "ℹ️ Setting custom folder icon for $PKG_APP_DIR and $PKG_APP_DIR_ROOT to $PKG_ICON_PATH." | ||
| for destPath in "$PKG_APP_DIR" "$PKG_APP_DIR_ROOT"; do | ||
| logger -p 'install.info' "ℹ️ Setting custom folder icon for $destPath to $PKG_ICON_PATH." | ||
| osascript \ | ||
| -e 'set destPath to "'"${destPath}"'"' \ | ||
| -e 'set iconPath to "'"${SPI_ICON_PATH}"'"' \ | ||
| -e 'set iconPath to "'"${PKG_ICON_PATH}"'"' \ | ||
| -e 'use framework "Foundation"' \ | ||
| -e 'use framework "AppKit"' \ | ||
| -e "set imageData to (current application's NSImage's alloc()'s initWithContentsOfFile:iconPath)" \ | ||
|
|
@@ -76,5 +80,5 @@ chown -R "$USER_FROM_HOMEDIR" "${PREFIX}" | |
| logger -p 'install.info' "ℹ️ Running spi_sys_info." | ||
| ${DSTBIN}/conda run -p ${PREFIX} ${PREFIX}/Menu/spi_sys_info.py nohtml || true | ||
|
|
||
| logger -p 'install.info' "ℹ️ Opening in Finder ${SPI_APP_DIR}/." | ||
| open -R "${SPI_APP_DIR}/" | ||
| logger -p 'install.info' "ℹ️ Opening in Finder ${PKG_APP_DIR}/." | ||
| open -R "${PKG_APP_DIR}/" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,8 +3,8 @@ | |
| # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#grouping-log-lines | ||
|
|
||
| set -eo pipefail | ||
| echo "Running tests for SP_MACHINE=${SP_MACHINE}" | ||
| source "${SP_ACTIVATE}" | ||
| echo "Running tests for PKG_MACHINE=${PKG_MACHINE}" | ||
| source "${PKG_ACTIVATE}" | ||
|
|
||
| echo "::group::conda info" | ||
| conda info | ||
|
|
@@ -19,10 +19,10 @@ pip list | |
| echo "::endgroup::" | ||
|
|
||
| echo "::group::Platform specific tests" | ||
| if [[ "$SP_MACHINE" == "macOS" ]]; then | ||
| if [[ "$PKG_MACHINE" == "macOS" ]]; then | ||
| echo "Testing that file permissions are set correctly (owned by "$USER", not "root".)" | ||
| # https://unix.stackexchange.com/a/7733 | ||
| APP_DIR=$(dirname $SP_INSTALL_PREFIX) | ||
| APP_DIR=$(dirname $PKG_INSTALL_PREFIX) | ||
| [ `ls -ld ${APP_DIR} | awk 'NR==1 {print $3}'` == "$USER" ] || exit 1 | ||
|
|
||
| echo "Checking that the installed Python is a binary for the correct CPU architecture" | ||
|
|
@@ -37,10 +37,10 @@ if [[ "$SP_MACHINE" == "macOS" ]]; then | |
| ls -al $(APP_DIR) | ||
| echo "Checking that there are 5 directories" | ||
| test `ls -d ${APP_DIR}/*.app | wc -l` -eq 5 || exit 1 | ||
| echo "Checking that the custom icon was set on the SP folder in ${APP_DIR}" | ||
| echo "Checking that the custom icon was set on the project folder in ${APP_DIR}" | ||
| test -f ${APP_DIR}/Icon$'\r' || exit 1 | ||
| export SKIP_SP_KIT_GUI_TESTS=1 | ||
| elif [[ "$SP_MACHINE" == "Linux" ]]; then | ||
| export SKIP_PKG_KIT_GUI_TESTS=1 | ||
| elif [[ "$PKG_MACHINE" == "Linux" ]]; then | ||
| echo "Checking that menu shortcuts were created …" | ||
| pushd ~/.local/share/applications | ||
| ls -l || exit 1 | ||
|
|
@@ -66,8 +66,8 @@ fi | |
| echo "::endgroup::" | ||
|
|
||
| echo "::group::Checking for pinned file..." | ||
| test -e "$SP_INSTALL_PREFIX/conda-meta/pinned" | ||
| grep "openblas" "$SP_INSTALL_PREFIX/conda-meta/pinned" | ||
| test -e "$PKG_INSTALL_PREFIX/conda-meta/pinned" | ||
| grep "openblas" "$PKG_INSTALL_PREFIX/conda-meta/pinned" | ||
| echo "::endgroup::" | ||
|
|
||
| echo "::group::Checking permissions" | ||
|
|
@@ -78,18 +78,18 @@ echo "::endgroup::" | |
|
|
||
| echo "::group::Checking the deployed environment variables were set correctly upon environment activation" | ||
| conda env config vars list | ||
| if [[ "$SP_MACHINE" == "macOS" && "$MACOS_ARCH" == "Intel" ]]; then | ||
| if [[ "$PKG_MACHINE" == "macOS" && "$MACOS_ARCH" == "Intel" ]]; then | ||
| python -c "import os; x = os.getenv('CONDA_SUBDIR'); assert x == 'osx-64', f'CONDA_SUBDIR ({repr(x)}) != osx-64'" || exit 1 | ||
| fi | ||
| # TODO: broken on Windows! | ||
| if [[ "$SP_MACHINE" != "Windows" ]]; then | ||
| if [[ "$PKG_MACHINE" != "Windows" ]]; then | ||
| python -c "import os; x = os.getenv('PYTHONNOUSERSITE'); assert x == '1', f'PYTHONNOUSERSITE ({repr(x)}) != 1'" || exit 1 | ||
| python -c "import os; x = os.getenv('MAMBA_NO_BANNER'); assert x == '1', f'MAMBA_NO_BANNER ({repr(x)}) != 1'" || exit 1 | ||
| fi | ||
| echo "::endgroup::" | ||
|
|
||
| echo "::group::spi_sys_info" | ||
| python -u ${SP_INSTALL_PREFIX}/Menu/spi_sys_info.py nohtml | ||
| python -u ${PKG_INSTALL_PREFIX}/Menu/spi_sys_info.py nohtml | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto here re: |
||
| echo "::endgroup::" | ||
|
|
||
| echo "::group::Trying to import SP and all additional packages included in the installer" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just so I'm clear: it isn't possible to remove
Scientific\ Pythonhere too? IIUC this is for all the menu items, and there's no guarantee that they'll always have a nice clean prefix that glob-matches all of them... but in our case there is (by design). So in theory we could use a variable here for our installer, but it wouldn't generalize for use cases where the menu items have arbitrary names. Is that right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right - because we have the custom names in
construct.yamlas you've described, it would work for us, but not for any other names someone chose. We could do all this by templating and filling out the templates in a pre-build step, but perhaps we could leave that for another time.