Skip to content

Commit

Permalink
MAINT: Use bundle_tools_3 and fix various bugs (#195)
Browse files Browse the repository at this point in the history
Co-authored-by: Richard Höchenberger <[email protected]>
  • Loading branch information
larsoner and hoechenberger authored Sep 6, 2023
1 parent c798d5f commit 98d7873
Show file tree
Hide file tree
Showing 17 changed files with 185 additions and 291 deletions.
100 changes: 53 additions & 47 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,13 @@ jobs:
- uses: actions/checkout@v3

- name: Install Micromamba
uses: mamba-org/provision-with-micromamba@main
uses: mamba-org/setup-micromamba@v1
with:
condarc: |
channels:
- conda-forge
channel_priority: strict
environment-file: environment.yml
micromamba-version: latest

- name: Hotfix for NSIS
run: |
mamba install nsis=3.01 conda=4.12a "pydantic<2.0a0"
if: ${{ runner.os == 'Windows' }}

- name: Extract version information
env:
Expand All @@ -135,45 +133,41 @@ jobs:
echo "MNE_INSTALLER_NAME=${MNE_INSTALLER_NAME}" >> $GITHUB_ENV
echo "MNE_INSTALLER_ARTIFACT_ID=${MNE_INSTALLER_ARTIFACT_ID}" >> $GITHUB_ENV
echo "RECIPE_DIR=${RECIPE_DIR}" >> $GITHUB_ENV
echo "CONDA_SOLVER=libmamba" >> $GITHUB_ENV
if [[ "$MNE_CROSSCOMPILE_ARCH" == "arm64" ]]; then
echo "PLATFORM_ARG=--platform=osx-arm64" >> $GITHUB_ENV
echo "EXE_ARG=--conda-exe=${CONDA_PREFIX}/standalone_conda/conda.exe" >> $GITHUB_ENV
fi
- name: Patch constructor
run: |
./tools/patch_constructor.sh
- name: Add macOS M1 support
if: ${{ matrix.arch == 'arm64' }}
run: |
source ./tools/setup_m1_crosscompile.sh
echo "EXE_ARG=${EXE_ARG}" >> $GITHUB_ENV
echo "PLATFORM_ARG=${PLATFORM_ARG}" >> $GITHUB_ENV
- name: Patch config (macOS pull request)
- name: Patch config (macOS non-PR)
if: ${{ runner.os == 'macOS' && github.event_name != 'pull_request' }}
run: |
sed -i "" "s/_name: *# \[osx\]/_name: 9779L28NP8 # \[osx\]/" ${RECIPE_DIR}/construct.yaml
- name: Build installer
# As of 2022/03/14, ~7 min on 20.04 (fastest) and ~11 min on windows-2019 (slowest).
# As of 2022/08/31, < 10 min on all platforms thanks to libmamba solver.
# So let's set this to a reasonable limit that will tell us more quickly
# if something has gone wrong with dependency resolution.
#
# Update 2022/06/03: Bump timeout as we're seeing sporadic issues on
# Linux
timeout-minutes: 50
timeout-minutes: 20
run: |
./tools/run_constructor.sh
- name: Check installer signature (macOS)
if: ${{ runner.os == 'macOS' && github.event_name != 'pull_request' }}
run: |
# Installer package
set -eo pipefail
pkgutil --check-signature ${MNE_INSTALLER_NAME}
# Now extract the package and check that the _conde.exe binary is
# Now extract the package and check that the conda.exe binary is
# properly signed as well
pkgutil --expand-full ${MNE_INSTALLER_NAME} ./mne-extracted
codesign -vd ./mne-extracted/main.pkg/Payload/.mne-python/_conda.exe
# Check entitlements of _conda.exe binary
codesign --display --entitlements - ./mne-extracted/main.pkg/Payload/.mne-python/_conda.exe
BINARY="./mne-extracted/main.pkg/Payload${MNE_INSTALL_PREFIX}/conda.exe"
echo "Checking ${BINARY} exists"
test -e "${BINARY}"
echo "Checking ${BINARY} is signed"
codesign -vd "${BINARY}"
echo "Checking entitlements of ${BINARY}"
codesign --display --entitlements - "${BINARY}"
rm -rf ./mne-extracted
- name: Notarize installer (macOS)
Expand Down Expand Up @@ -310,6 +304,8 @@ jobs:
echo "MNE_INSTALLER_VERSION=${MNE_INSTALLER_VERSION}"
echo "MNE_ACTIVATE=${MNE_ACTIVATE}" >> $GITHUB_ENV
echo "MNE_ACTIVATE=${MNE_ACTIVATE}"
echo "MNE_INSTALL_PREFIX=$MNE_INSTALL_PREFIX" >> $GITHUB_ENV
echo "NSIS_SCRIPTS_RAISE_ERRORS=1" >> $GITHUB_ENV
- name: Download appropriate installer
uses: actions/download-artifact@v3
Expand All @@ -325,10 +321,7 @@ jobs:
- name: Run installer (macOS Intel)
if: ${{ runner.os == 'macOS' && matrix.arch == 'x86_64' }}
run: |
sudo installer \
-verbose \
-pkg ${MNE_INSTALLER_NAME} \
-target / \
sudo installer -verbose -pkg ${MNE_INSTALLER_NAME} -target / \
|| ( tail -n 30 /var/log/install.log && exit 1 ) # display last log messages on error
- name: Run installer (Linux)
Expand All @@ -340,7 +333,7 @@ jobs:
# https://docs.anaconda.com/anaconda/install/silent-mode.html#windows
- name: Run installer (Windows)
if: ${{ runner.os == 'Windows' }}
timeout-minutes: 20
timeout-minutes: 30
shell: cmd
run: |
.\%MNE_INSTALLER_NAME% /S /InstallationType=JustMe /AddToPath=1
Expand Down Expand Up @@ -376,43 +369,56 @@ jobs:
- name: Check installation
if: ${{ matrix.arch == 'x86_64' }}
run: |
set -eo pipefail
source "${MNE_ACTIVATE}"
conda info
mamba list
if [[ "${{ runner.os }}" == "macOS" ]]; then
echo "Testing that file permissions are set correctly (owned by "runner", not "root".)"
echo "Testing that file permissions are set correctly (owned by "$USER", not "root".)"
# https://unix.stackexchange.com/a/7733
[ `ls -ld /Applications/MNE-Python/.mne-python | awk 'NR==1 {print $3}'` == "runner" ] || exit 1
# Check that the installed Python is, in fact, an Intel binary
APP_DIR=/Applications/MNE-Python/${MNE_INSTALLER_VERSION}
[ `ls -ld ${APP_DIR} | awk 'NR==1 {print $3}'` == "$USER" ] || exit 1
echo "Check that the installed Python is, in fact, an Intel binary"
python -c "import platform; assert platform.machine() == 'x86_64'" || exit 1
echo "Checking we have all .app bundles in /Applications/MNE-Python:"
ls -d /Applications/MNE-Python/*.app || exit 1
test `ls -d /Applications/MNE-Python/*.app | wc -l` -eq 5 || exit 1
echo "Checking that the custom icon was set on the MNE folder in /Applications/MNE-Python"
echo "Checking we have all .app bundles in ${APP_DIR}:"
ls -al /Applications/
ls -al /Applications/MNE-Python
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 MNE folder in ${APP_DIR}"
test -f /Applications/MNE-Python/Icon$'\r' || exit 1
elif [[ "${{ runner.os }}" == "Linux" ]]; then
echo "Checking that menu shortcuts were created …"
pushd ~/.local/share/applications
ls -l || exit 1
echo "Checking for existence of .desktop files:"
ls MNE-Python*.desktop || exit 1
test `ls MNE-Python*.desktop | wc -l` -eq 5 || exit 1
ls mne-python*.desktop || exit 1
test `ls mne-python*.desktop | wc -l` -eq 5 || exit 1
echo ""
# … and patched to work around a bug in menuinst
echo "Checking that incorrect Terminal entries have been removed"
test `grep "Terminal=True" MNE-Python*.desktop | wc -l` -eq 0 || exit 1
test `grep "Terminal=False" MNE-Python*.desktop | wc -l` -eq 0 || exit 1
test `grep "Terminal=True" mne-python*.desktop | wc -l` -eq 0 || exit 1
test `grep "Terminal=False" mne-python*.desktop | wc -l` -eq 0 || exit 1
echo ""
echo "Checking that Terminal entries are correct…"
test `grep "Terminal=true" MNE-Python*.desktop | wc -l` -ge 1 || exit 1
test `grep "Terminal=false" MNE-Python*.desktop | wc -l` -ge 1 || exit 1
test `grep "Terminal=true" mne-python*.desktop | wc -l` -ge 1 || exit 1
test `grep "Terminal=false" mne-python*.desktop | wc -l` -ge 1 || exit 1
# Display their contents
for f in MNE-Python*.desktop; do echo "📂 $f:"; cat "$f"; echo; done
for f in mne-python*.desktop; do echo "📂 $f:"; cat "$f"; echo; done
popd
fi
echo "Checking for pinned file..."
test -e "$MNE_INSTALL_PREFIX/conda-meta/pinned"
grep "openblas" "$MNE_INSTALL_PREFIX/conda-meta/pinned"
echo "Checking permissions..."
OWNER=`ls -ld "$(which python)" | awk '{print $3}'`
echo "Got OWNER=$OWNER, should be $(whoami)"
test "$OWNER" == "$(whoami)"
echo "Checking whether (Py)Qt is working"
LD_DEBUG=libs python -c "from PyQt5.QtWidgets import QApplication, QWidget; app = QApplication([])"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ tests/test.png
.vscode
.pytest_cache
.DS_Store
__pycache__
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Locally, installers can be built using `tools/build_local.sh`. Steps:
$ conda env create -f environment.yml
$ conda activate constructor-env
```
2. If you want to build an arm64 (M1) package on a macOS Intel machine, run `source ./tools/setup_m1_crosscompile.sh`.
3. Run `./tools/build_local.sh` (which will patch the constructor on macOS if needed).
4. Install the environment for your platform.
5. Test it using the `tests/`.
2. Run `./tools/build_local.sh`.
3. Install the environment for your platform.
4. Test it using the `tests/`.
12 changes: 0 additions & 12 deletions assets/constructor_macOS_arm64.patch

This file was deleted.

101 changes: 0 additions & 101 deletions assets/constructor_macOS_common.patch

This file was deleted.

12 changes: 0 additions & 12 deletions assets/constructor_macOS_i386.patch

This file was deleted.

18 changes: 5 additions & 13 deletions assets/post_install_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,18 @@

# This script must be marked +x to work correctly with the installer!

# It works around a bug in menuinst.

set -e

echo "ℹ️ Fixing menu shortcuts."

cd "$HOME/.local/share/applications"
for f in ./MNE-Python*.desktop
do
sed -i "s/Terminal=True/Terminal=true/" $f
sed -i "s/Terminal=False/Terminal=false/" $f
done
set -eo pipefail

echo "ℹ️ Configuring Python to ignore user-installed local packages."
${PREFIX}/bin/conda env config vars set PYTHONNOUSERSITE=1

echo "ℹ️ Disabling mamba package manager banner."
${PREFIX}/bin/conda env config vars set MAMBA_NO_BANNER=1

echo "ℹ️ Pinning BLAS implementation to OpenBLAS"
echo "ℹ️ Setting libmama as the conda solver."
${PREFIX}/bin/conda config --set solver libmamba

echo "ℹ️ Pinning BLAS implementation to OpenBLAS."
echo "libblas=*=*openblas" >>${PREFIX}/conda-meta/pinned

echo "ℹ️ Running mne sys_info."
Expand Down
Loading

0 comments on commit 98d7873

Please sign in to comment.