mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-12 07:49:39 -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
|
sudo pip install virtualenv
|
||||||
virtualenv env
|
virtualenv env
|
||||||
. env/bin/activate
|
. env/bin/activate
|
||||||
pip install flask stem py2app
|
pip install flask stem pyinstaller
|
||||||
# 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
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Each time you start work:
|
Each time you start work:
|
||||||
@ -56,7 +54,7 @@ Each time you start work:
|
|||||||
Build the .app:
|
Build the .app:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
python setup.py py2app
|
pyinstaller -w -y setup/onionshare-osx.spec
|
||||||
```
|
```
|
||||||
|
|
||||||
Now you should have `dist/OnionShare.app`.
|
Now you should have `dist/OnionShare.app`.
|
||||||
|
@ -14,6 +14,12 @@ def random_string(num_bytes):
|
|||||||
b = os.urandom(num_bytes)
|
b = os.urandom(num_bytes)
|
||||||
return base64.b32encode(b).lower().replace('=','')
|
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
|
# information about the file
|
||||||
filename = filesize = filehash = None
|
filename = filesize = filehash = None
|
||||||
def set_file_info(new_filename, new_filehash, new_filesize):
|
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__)
|
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 = {}
|
strings = {}
|
||||||
onionshare_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
|
||||||
slug = random_string(16)
|
slug = random_string(16)
|
||||||
download_count = 0
|
download_count = 0
|
||||||
stay_open = False
|
stay_open = False
|
||||||
@ -130,12 +141,6 @@ def page_not_found(e):
|
|||||||
add_request(REQUEST_OTHER, request.path)
|
add_request(REQUEST_OTHER, request.path)
|
||||||
return render_template_string(open('{0}/404.html'.format(onionshare_dir)).read())
|
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():
|
def is_root():
|
||||||
return os.geteuid() == 0
|
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.QtCore import *
|
||||||
from PyQt4.QtGui import *
|
from PyQt4.QtGui import *
|
||||||
from PyQt4.QtWebKit 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:
|
try:
|
||||||
import onionshare
|
import onionshare
|
||||||
|
19
setup.py
19
setup.py
@ -19,25 +19,6 @@ def file_list(path):
|
|||||||
version = open('version').read().strip()
|
version = open('version').read().strip()
|
||||||
args = {}
|
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:
|
else:
|
||||||
args['packages'] = ['onionshare', 'onionshare_gui']
|
args['packages'] = ['onionshare', 'onionshare_gui']
|
||||||
args['include_package_data'] = True
|
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