mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-24 14:59:42 -05:00
made pyinstaller work for OSX (#43)
This commit is contained in:
parent
8011472dee
commit
9db3ca59c8
6
BUILD.md
6
BUILD.md
@ -42,9 +42,7 @@ brew install qt4 pyqt
|
||||
sudo pip install virtualenv
|
||||
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
|
||||
pip install flask stem pyinstaller
|
||||
```
|
||||
|
||||
Each time you start work:
|
||||
@ -56,7 +54,7 @@ Each time you start work:
|
||||
Build the .app:
|
||||
|
||||
```sh
|
||||
python setup.py py2app
|
||||
pyinstaller -w -y setup/onionshare-osx.spec
|
||||
```
|
||||
|
||||
Now you should have `dist/OnionShare.app`.
|
||||
|
@ -14,6 +14,12 @@ def random_string(num_bytes):
|
||||
b = os.urandom(num_bytes)
|
||||
return base64.b32encode(b).lower().replace('=','')
|
||||
|
||||
def get_platform():
|
||||
p = platform.system()
|
||||
if p == 'Linux' and platform.uname()[0:2] == ('Linux', 'amnesia'):
|
||||
p = 'Tails'
|
||||
return p
|
||||
|
||||
# information about the file
|
||||
filename = filesize = filehash = None
|
||||
def set_file_info(new_filename, new_filehash, new_filesize):
|
||||
@ -24,8 +30,13 @@ def set_file_info(new_filename, new_filehash, new_filesize):
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
# get path of onioshare directory
|
||||
if get_platform() == 'Darwin':
|
||||
onionshare_dir = os.path.dirname(__file__)
|
||||
else:
|
||||
onionshare_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||
|
||||
strings = {}
|
||||
onionshare_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||
slug = random_string(16)
|
||||
download_count = 0
|
||||
stay_open = False
|
||||
@ -130,12 +141,6 @@ def page_not_found(e):
|
||||
add_request(REQUEST_OTHER, request.path)
|
||||
return render_template_string(open('{0}/404.html'.format(onionshare_dir)).read())
|
||||
|
||||
def get_platform():
|
||||
p = platform.system()
|
||||
if p == 'Linux' and platform.uname()[0:2] == ('Linux', 'amnesia'):
|
||||
p = 'Tails'
|
||||
return p
|
||||
|
||||
def is_root():
|
||||
return os.geteuid() == 0
|
||||
|
||||
|
@ -1,9 +1,12 @@
|
||||
import os, sys, subprocess, inspect
|
||||
import os, sys, subprocess, inspect, platform
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtWebKit import *
|
||||
|
||||
onionshare_gui_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||
if platform.system() == 'Darwin':
|
||||
onionshare_gui_dir = os.path.dirname(__file__)
|
||||
else:
|
||||
onionshare_gui_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||
|
||||
try:
|
||||
import onionshare
|
||||
|
19
setup.py
19
setup.py
@ -19,25 +19,6 @@ def file_list(path):
|
||||
version = open('version').read().strip()
|
||||
args = {}
|
||||
|
||||
if platform.system() == 'Darwin':
|
||||
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',
|
||||
'qt_plugins': 'imageformats',
|
||||
'site_packages': True,
|
||||
'plist': {
|
||||
'CFBundleName': 'OnionShare',
|
||||
}
|
||||
}
|
||||
}
|
||||
args['setup_requires'] = 'py2app'
|
||||
|
||||
else:
|
||||
args['packages'] = ['onionshare', 'onionshare_gui']
|
||||
args['include_package_data'] = True
|
||||
|
45
setup/onionshare-osx.spec
Normal file
45
setup/onionshare-osx.spec
Normal file
@ -0,0 +1,45 @@
|
||||
# -*- mode: python -*-
|
||||
a = Analysis(['setup/onionshare-launcher.py'],
|
||||
pathex=['.'],
|
||||
hiddenimports=['onionshare', 'onionshare_gui'],
|
||||
hookspath=None,
|
||||
runtime_hooks=None)
|
||||
a.datas += [
|
||||
('onionshare/strings.json', 'onionshare/strings.json', 'DATA'),
|
||||
('onionshare/index.html', 'onionshare/index.html', 'DATA'),
|
||||
('onionshare/404.html', 'onionshare/404.html', 'DATA'),
|
||||
('onionshare_gui/onionshare-icon.png', 'onionshare_gui/onionshare-icon.png', 'DATA'),
|
||||
('onionshare_gui/static/jquery-1.11.1.min.js', 'onionshare_gui/static/jquery-1.11.1.min.js', 'DATA'),
|
||||
('onionshare_gui/static/helpers.js', 'onionshare_gui/static/helpers.js', 'DATA'),
|
||||
('onionshare_gui/static/onionshare.js', 'onionshare_gui/static/onionshare.js', 'DATA'),
|
||||
('onionshare_gui/static/style.css', 'onionshare_gui/static/style.css', 'DATA'),
|
||||
('onionshare_gui/static/loader.gif', 'onionshare_gui/static/loader.gif', 'DATA'),
|
||||
('onionshare_gui/static/logo.png', 'onionshare_gui/static/logo.png', 'DATA'),
|
||||
('onionshare_gui/templates/index.html', 'onionshare_gui/templates/index.html', 'DATA'),
|
||||
]
|
||||
pyz = PYZ(a.pure)
|
||||
exe = EXE(pyz,
|
||||
a.scripts,
|
||||
exclude_binaries=True,
|
||||
name='onionshare-launcher',
|
||||
debug=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
console=False )
|
||||
coll = COLLECT(exe,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
strip=False,
|
||||
upx=True,
|
||||
name='onionshare')
|
||||
app = BUNDLE(exe,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
strip=False,
|
||||
upx=True,
|
||||
name='OnionShare.app',
|
||||
appname='OnionShare',
|
||||
icon='setup/onionshare.icns',
|
||||
version=open('version').read().strip())
|
@ -1,12 +0,0 @@
|
||||
--- 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)
|
Loading…
Reference in New Issue
Block a user