Skip to content

Instantly share code, notes, and snippets.

@stuarteberg
Created June 13, 2020 18:21
Show Gist options
  • Save stuarteberg/1d36281667e4888c1d9f776168166be9 to your computer and use it in GitHub Desktop.
Save stuarteberg/1d36281667e4888c1d9f776168166be9 to your computer and use it in GitHub Desktop.
How to create a macOS app bundle from a conda environment with py2app in "alias mode"
Normally, if you create an app bundle with py2app, it will copy the files from your
conda environment into the app bundle, but it will completely reorganize the
directory structure that you started with. That has various downsides.
But there's a way to avoid that: You can exploit py2app's "alias mode" to create an
app bundle that doesn't actually change the directory structure of your conda environment.
Just place the environment inside the app bundle, wholesale! Instructions below,
with links to a real project that uses this method.
---
Since a .app is just a directory with special contents, copy the entire conda environment INTO the .app.
The procedure is: 1. Use py2app to create an "alias mode" .app directory:
https://github.com/ilastik/ilastik-conda-recipes/blob/master/recipes/osx-packages/create-osx-app.sh#L121
2. Then copy the conda environment into it.
https://github.com/ilastik/ilastik-conda-recipes/blob/master/recipes/osx-packages/create-osx-app.sh#L147-L150
3. Do some special fixups and replacements to turn the "alias app" into a self-contained app:
https://github.com/ilastik/ilastik-conda-recipes/blob/master/recipes/osx-packages/create-osx-app.sh#L152-L178
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment