Skip to content

Instantly share code, notes, and snippets.

@justinfx
Created October 12, 2012 00:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save justinfx/3876496 to your computer and use it in GitHub Desktop.
Save justinfx/3876496 to your computer and use it in GitHub Desktop.
py2app setup.py script for creating a PyQt4 semi-standalone application. PyQt4 is bundled, while Maya's installation location is referenced for the Python framework
"""
setup.py
py2app setup script for creating a semi-standalone .app
around a Maya API based PyQt4 application.
Only bundled PyQt4 with the app, and references the Maya install
location for the python environment.
Allows for a portable GUI application that does not require
a PyQt4 dependency on the system. Only a Maya installation.
"""
import os
from setuptools import setup
ROOT = '/Applications/Autodesk/maya2012/Maya.app/Contents'
PYTHONHOME = os.path.join(ROOT, 'Frameworks/Python.framework/Versions/Current')
PYTHONPATH = os.path.join(PYTHONHOME, 'lib/python2.6/site-packages')
ENV = {
'MAYA_LOCATION' : ROOT,
'PYTHONHOME' : PYTHONHOME,
'PYTHONPATH' : PYTHONPATH,
'DYLD_LIBRARY_PATH' : os.path.join(ROOT, 'MacOS'),
'DYLD_FRAMEWORK_PATH' : os.path.join(ROOT, 'Frameworks'),
}
APP = ['myApp.py']
OPTIONS = {
'excludes': [
'PyQt4.QtDBus',
'PyQt4.QtDeclarative',
'PyQt4.QtDesigner',
'PyQt4.QtHelp',
'PyQt4.QtScript',
'PyQt4.QtScriptTools',
'PyQt4.QtTest',
'PyQt4.QtXml',
'PyQt4.QtXmlPatterns',
'PyQt4.QtOpenGL',
],
'semi_standalone' : True,
'site_packages' : True,
'use_pythonpath' : True,
'strip' : True,
'plist':{
'LSEnvironment': ENV
},
}
#
# Build .app
#
setup(
app=APP,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment