From a464b6fe1dc3302e675a6496c44988737b7eb29d Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Thu, 19 Jun 2014 22:05:56 -0700 Subject: [PATCH] OSX version still needs a bit of work, but completely works now (#43) --- .gitignore | 1 + BUILD.md | 24 +++++++++++-------- setup.py | 9 ++++--- ...ionshare_osx.py => onionshare-launcher.py} | 0 setup/py2app.patch | 12 ++++++++++ 5 files changed, 33 insertions(+), 13 deletions(-) rename setup/{onionshare_osx.py => onionshare-launcher.py} (100%) create mode 100644 setup/py2app.patch diff --git a/.gitignore b/.gitignore index 946449ad..6d3f1d6e 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ sdist develop-eggs .installed.cfg MANIFEST +env # Installer logs pip-log.txt diff --git a/BUILD.md b/BUILD.md index 1295686e..8ee66ed0 100644 --- a/BUILD.md +++ b/BUILD.md @@ -23,24 +23,28 @@ Note that python-stem appears in Debian wheezy and newer (so by extension Tails ## Mac OS X -*Note: This is a work-in-progress. The OnionShare GUI doesn't yet work in Mac OS X. See https://github.com/micahflee/onionshare/issues/43 for progress.* +The first time you're setting up your dev environment: -Get a copy of the source code: + echo export PYTHONPATH=\$PYTHONPATH:/usr/local/lib/python2.7/site-packages/ >> ~/.profile + source ~/.profile + brew install qt4 pyqt + virtualenv env + . env/bin/activate + pip install flask stem py2app + # fixes a silly bug https://bitbucket.org/ronaldoussoren/py2app/issue/143/resulting-app-mistakenly-looks-for-pyside + patch env/lib/python2.7/site-packages/py2app/util.py < setup/py2app.patch - git clone https://github.com/micahflee/onionshare.git - cd onionshare +Each time you start work: -Install py2app (if you don't have pip installed, you can `sudo easy_install pip`): + . env/bin/activate - sudo pip install py2app - -Then build the .app: +Build the .app: python setup.py py2app -Now you'll see `dist/OnionShare.app` with a nice icon. However, it won't run yet. +Now you should have `dist/OnionShare.app`. ## Windows -*Note: Haven't started figuring this out yet.* +*Coming soon.* diff --git a/setup.py b/setup.py index f5be7729..33451191 100644 --- a/setup.py +++ b/setup.py @@ -20,19 +20,22 @@ version = open('version').read().strip() args = {} if platform.system() == 'Darwin': - args['data_files'] = ['LICENSE', 'README.md', 'BUILD.md', 'version', 'onionshare', 'onionshare_gui'] - args['app'] = ['setup/onionshare_osx.py'] + args['data_files'] = ['LICENSE', 'README.md', 'version'] + args['app'] = ['setup/onionshare-launcher.py'] args['options'] = { 'py2app': { 'argv_emulation': True, + 'packages': ['flask', 'stem', 'jinja2', 'onionshare_gui', 'onionshare'], + 'includes': ['PyQt4'], + 'excludes': ['PyQt4.QtDesigner', 'PyQt4.QtOpenGL', 'PyQt4.QtScript', 'PyQt4.QtSql', 'PyQt4.QtTest', 'PyQt4.QtXml', 'PyQt4.phonon'], 'iconfile': 'setup/onionshare.icns', - 'packages': ['flask', 'stem'], 'site_packages': True, 'plist': { 'CFBundleName': 'OnionShare', } } } + args['setup_requires'] = 'py2app' elif platform.system() == 'Windows': pass diff --git a/setup/onionshare_osx.py b/setup/onionshare-launcher.py similarity index 100% rename from setup/onionshare_osx.py rename to setup/onionshare-launcher.py diff --git a/setup/py2app.patch b/setup/py2app.patch new file mode 100644 index 00000000..23a7039c --- /dev/null +++ b/setup/py2app.patch @@ -0,0 +1,12 @@ +--- original-util.py 2014-06-17 12:50:15.000000000 -0700 ++++ util.py 2014-06-17 12:51:33.000000000 -0700 +@@ -148,6 +148,9 @@ + log.info("copying file %s -> %s", source, destination) + with zipio.open(source, 'rb') as fp_in: + if not dry_run: ++ if os.path.exists(destination): ++ os.unlink(destination) ++ + with open(destination, 'wb') as fp_out: + data = fp_in.read() + fp_out.write(data)