Skip to content

Commit

Permalink
Fix osx distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
tpeulen committed Sep 25, 2024
1 parent cad18c0 commit 6fc8346
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 25 deletions.
4 changes: 4 additions & 0 deletions build_tools/BUILD_INSTRUCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ for the ChiSurf.app. Unnecessary folders and file listed in `remove_list.txt`
are stripped from the ChiSurf.app folder. Finally, the ChiSurf.app is bundeled
in a .dmg image that is placed in the ``dist`` folder.

```
./osx/build-osx-app.sh -f=../env_osx.yml -i=../chisurf/gui/resources/icons/cs_logo.png -n=ChiSurf -m=chisurf -p=.. -o=../dist
```

## Windows

The Windows installation of ChiSurf is effectively a conda environment with
Expand Down
66 changes: 41 additions & 25 deletions build_tools/osx/build-osx-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ get_abs_filename() {
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
}


export ICON_FILE=icon.png
export CONDA_ENVIRONMENT_YAML=environment.yml
export CONDA_ENVIRONMENT_YAML=env_osx.yml

# The directory of the build-osx-app.sh script
export SCRIPT_DIR="."
SCRIPT_DIR=$("pwd")
echo $SCRIPT_DIR
export SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"

function print_usage() {
echo "build-osx-app.sh [-i] [--template] $APP_NAME.app
Expand Down Expand Up @@ -85,26 +85,47 @@ case $i in
shift
done


# The target directory of the .app
mkdir "$OUTPUT_PATH"
OUTPUT_PATH=$(cd "$OUTPUT_PATH" && pwd)
PYTHON_MODULE_PATH=$(cd "$PYTHON_MODULE_PATH" && pwd)

export APP_FOLDER=${1:-$OUTPUT_PATH/$APP_NAME.app}
APP_FOLDER="$(cd "$(dirname "$APP_FOLDER")" && pwd)/$(basename "$APP_FOLDER")"
echo "App folder: $APP_FOLDER"
mkdir "$APP_FOLDER"
mkdir -p "$APP_FOLDER"
APP_FOLDER=$(cd "$APP_FOLDER" && pwd)

source $CONDA_PREFIX/etc/profile.d/conda.sh
mamba env create -f $CONDA_ENVIRONMENT_YAML --prefix "$APP_FOLDER/Contents" --force
conda activate "$APP_FOLDER/Contents"
mamba install -y nomkl jinja2
mkdir "$APP_FOLDER/Contents/MacOS"
mkdir "$APP_FOLDER/Contents/Resources"
mkdir -p "$APP_FOLDER/Contents/MacOS"
mkdir -p "$APP_FOLDER/Contents/Resources"

cd $PYTHON_MODULE_PATH
cp -R $PYTHON_MODULE "$APP_FOLDER/Contents"
export SITE_PACKAGE_PATH=`$APP_FOLDER/Contents/bin/python -c 'import site; print(site.getsitepackages()[0])'`
cp -R $PYTHON_MODULE $SITE_PACKAGE_PATH

function print_values() {
echo "Input values:"
echo "-----------------------"
echo "Conda Environment YAML: $CONDA_ENVIRONMENT_YAML"
echo "Icon File: $ICON_FILE"
echo "Python Module: $PYTHON_MODULE"
echo "App Name: $APP_NAME"
echo "Output Path: $OUTPUT_PATH"
echo "Python Module Path: $PYTHON_MODULE_PATH"
echo "Site package Path: $SITE_PACKAGE_PATH"
echo "App folder: $APP_FOLDER"
echo "-----------------------"
}
print_values


# generate icns file
# generate icons file
cd $SCRIPT_DIR
python generate-iconset.py $SCRIPT_DIR/resources/AppIcon.png
python generate-iconset.py resources/VolumeIcon.png

# also update the icon with fileicon
$SCRIPT_DIR/fileicon set "$APP_FOLDER" "$SCRIPT_DIR/resources/AppIcon.icns"

Expand All @@ -117,26 +138,21 @@ $SCRIPT_DIR/create_app_plist.py \
-i $SCRIPT_DIR/resources/AppIcon.icns \
-p $SCRIPT_DIR/plist_template \
-t $SCRIPT_DIR/launch_template
cd $SCRIPT_DIR
cd $APP_FOLDER/Contents
./bin/python -m compileall .

echo Remove files and folders from content folder: "$CONTENT_FOLDER"
while read p; do
echo "removing: $APP_FOLDER/Contents/$p"
rm -rf $CONTENT_FOLDER$p
done <"$SCRIPT_DIR/remove_list.txt"

test -f ../dist/$APP_NAME-Installer.dmg && rm ../dist/$APP_NAME-Installer.dmg
python generate-iconset.py resources/VolumeIcon.png
cd $SCRIPT_DIR
./create-dmg/create-dmg \
--volname "$APP_NAME Installer" \
--volicon "./resources/VolumeIcon.icns" \
--window-pos 200 120 \
--window-size 800 400 \
--icon-size 100 \
--icon "$APP_NAME.app" 200 190 \
--hide-extension "$APP_NAME.app" \
--app-drop-link 600 185 \
--volicon resources/VolumeIcon.icns \
--skip-jenkins \
--sandbox-safe \
--no-internet-enable \
"$OUTPUT_PATH/$APP_NAME-Installer.dmg" \
"$OUTPUT_PATH"
./fileicon set "$OUTPUT_PATH/$APP_NAME-Installer.dmg" ./resources/VolumeIcon.icns
rm -rf $OUTPUT_PATH/$APP_NAME.app
"$APP_FOLDER/.."
41 changes: 41 additions & 0 deletions env_osx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: chisurf

channels:
- conda-forge
- tpeulen
- defaults

dependencies:
- python =3.10
- numpy <=1.23
- pyyaml
- pyqtgraph
- matplotlib
- deprecation
- scikit-fluorescence
- typing_extensions 4.2.*
- typing-extensions 4.2
- typing_utils 0.1.*
- scipy 1.11.*
- numba 0.57.*
- tttrlib
- imp
- mdtraj
- pdb2pqr 3.6.1
- propka
- ipython 7.*.*
- chinet >=0.0.8
- labellib
- pyopencl 2023.*
- pytools 2023.*
- emcee 3.1.*
- pyopengl 3.1.*
- pymol-open-source 2.5.*
- tttrconvert
- qscintilla2
- k2dist
- python-docx 1.0.*
- qtconsole 5.*
- ndxplorer
- clsmview
- pyqtwebengine

0 comments on commit 6fc8346

Please sign in to comment.