made pyinstaller work for windows (#35)

This commit is contained in:
Micah Lee 2014-06-24 17:23:10 -04:00
parent fc13ef5707
commit cf7d04099e
5 changed files with 35 additions and 17 deletions

View File

@ -69,14 +69,13 @@ The first time you're setting up your dev environment:
* Right click on Computer, go to Properties. Click "Advanced system settings". Click Environment Variables. Under "System variables" double-click on Path to edit it. Add `;C:\Python27;C:\Python27\Scripts` to the end. Now you can just type `python` to run python scripts in the command prompt. * Right click on Computer, go to Properties. Click "Advanced system settings". Click Environment Variables. Under "System variables" double-click on Path to edit it. Add `;C:\Python27;C:\Python27\Scripts` to the end. Now you can just type `python` to run python scripts in the command prompt.
* Go to https://pip.pypa.io/en/latest/installing.html. Right-click on `get-pip.py` and Save Link As, and save it to your home folder. * Go to https://pip.pypa.io/en/latest/installing.html. Right-click on `get-pip.py` and Save Link As, and save it to your home folder.
* Open `cmd.exe` as an administrator. Type: `python get-pip.py`. Now you can use `pip` to install packages. * Open `cmd.exe` as an administrator. Type: `python get-pip.py`. Now you can use `pip` to install packages.
* Open a command prompt and type: `pip install flask stem pyinstaller`
* Go to http://www.riverbankcomputing.com/software/pyqt/download and download the latest PyQt4 for Windows for python 2.7, 32-bit (I downloaded `PyQt4-4.11-gpl-Py2.7-Qt4.8.6-x32.exe`), then install it. * Go to http://www.riverbankcomputing.com/software/pyqt/download and download the latest PyQt4 for Windows for python 2.7, 32-bit (I downloaded `PyQt4-4.11-gpl-Py2.7-Qt4.8.6-x32.exe`), then install it.
* Go to http://www.py2exe.org/ and download the latest py2exe for python 2.7, 32-bit (I downloaded `py2exe-0.6.9.win32-py2.7.exe`), then install it. * Go to http://sourceforge.net/projects/pywin32/ and download and install the latest 32-bit pywin32 binary for python 2.7. I downloaded `pywin32-219.win32-py2.7.exe`.
* Open a command prompt and type: `pip install flask stem`
* Go to `C:\Python27\Lib\site-packages\flask\` and delete the folder `testsuite`. This is necessary to work around a py2exe bug.
To make an exe: To make a .exe:
* Open a command prompt, cd to the onionshare folder, and type: `python setup.py py2exe`. This will create a ton of files in `dist`, including `onionshare.exe`. * Open a command prompt, cd into the onionshare directory, and type: `pyinstaller -y setup\onionshare-win.spec`. Inside the `dist` folder there will be a folder called `onionshare` with `onionshare.exe` in it.
## Tests ## Tests

View File

@ -26,17 +26,7 @@ import logging
log_handler = logging.FileHandler('{0}/onionshare.web.log'.format(temp_dir)) log_handler = logging.FileHandler('{0}/onionshare.web.log'.format(temp_dir))
log_handler.setLevel(logging.WARNING) log_handler.setLevel(logging.WARNING)
template_folder = './templates' app = Flask(__name__, template_folder='./templates')
if platform.system() == 'Windows':
# pyinstaller sets sys.frozen=1 on run
application_path = ""
if getattr(sys, "frozen", False):
application_path = os.path.dirname(sys.executable)
elif __file__:
application_path = os.path.dirname(__file__)
template_path = os.path.join(application_path, "templates")
app = Flask(__name__, template_folder=template_path)
app.logger.addHandler(log_handler) app.logger.addHandler(log_handler)
@app.route("/") @app.route("/")

View File

@ -1,2 +1,7 @@
import onionshare_gui # import stuff for pyinstaller to find
import os, sys, subprocess, time, hashlib, platform, json, locale, socket, argparse, Queue, inspect, base64, random, functools
import PyQt4.QtCore, PyQt4.QtGui, PyQt4.QtWebKit
import stem, stem.control, flask
import onionshare, onionshare_gui
onionshare_gui.main() onionshare_gui.main()

24
setup/onionshare-win.spec Normal file
View File

@ -0,0 +1,24 @@
# -*- mode: python -*-
a = Analysis(['setup/onionshare-launcher.py'],
hiddenimports=['onionshare', 'onionshare_gui'],
hookspath=None,
runtime_hooks=None)
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='onionshare.exe',
debug=False,
strip=False,
upx=True,
icon='setup/onionshare.ico',
console=False )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
Tree('onionshare', prefix='onionshare'),
Tree('onionshare_gui', prefix='onionshare_gui'),
strip=False,
upx=True,
name='onionshare')

BIN
setup/onionshare.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB