Skip to content

stuarteberg/helloworld

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

helloworld - Build a conda package, then build an OSX app with it

This example code shows how to build an OSX .app bundle using py2apppy2app. Ideally, this would be straightforward because the py2app docs are pretty good, but there are a few sticking points addressed here:

  • We'll use conda to install the python package that implements this app. Using conda and using py2app are two orthogonal subjects, but this example should serve as a demonstration that there are no unexpected problems when using the two together, in case you had reservations for some reason.
  • There is a known bug in py2app that causes it not to work out-of-the-box any more. Here, we use a slightly tweaked build of py2app that can be easily installed using the conda package manager.

Note: The tutorial text below does not explain conda or py2app in detail, but the code in this repo is about as simple as it gets. Have a look!

  1. Prerequisites: Install Miniconda and conda-build

# Install miniconda to the prefix of your choice, e.g. /path/to/miniconda
curl https://repo.continuum.io/miniconda/Miniconda-latest-MacOSX-x86_64.sh > Miniconda-latest-MacOSX-x86_64.sh
bash Miniconda-latest-MacOSX-x86_64.sh -b -p /path/to/miniconda

# Activate the root conda environment
source /path/to/miniconda/bin/activate root

# Install `conda-build`
conda install conda-build
  1. Clone this repo

git clone http://github.com/stuarteberg/helloworld
  1. Build the recipe

This step isn't strictly necessary for the purposes of building the app, but since we're covering both conda and py2app in this tutorial, let's build the conda package.

cd helloworld
conda build conda-recipe 
  1. Create a build environment

Before we can build the app, we'll need an environment with all the app's dependencies already installed. The easiest way to do this is to simply install the package we just built, since it lists the dependencies it needs.

conda create -n app-env --use-local helloworld

Of course, in addition to the dependencies, we'll also need py2app. Unfortunately, there's a known bug in the currently released version of py2app (v0.9). The bug is teeny-tiny (a typo, basically). Here, we install a special build of py2app, in which that bug has been fixed already.

conda install -n app-env -c stuarteberg py2app
  1. Build the app

Before we generate the app, let's verify that our python code here actually works.

source activate app-env
PYTHONPATH=. python helloworld/main.py

You should see something like this:

screenshot

Now let's build the app!

python setup.py py2app

The app was placed in the dist folder. Does it work? Let's try it...

open dist/helloworld.app

You can send helloworld.app to your friends, and they can start enjoying it immediately. No further installation required.

About

A simple greeting using pyqt

Resources

Stars

Watchers

Forks

Packages

No packages published