diff --git a/BUILD.md b/BUILD.md index 26565cff..ecd1f957 100644 --- a/BUILD.md +++ b/BUILD.md @@ -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. * 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 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.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. -* 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. +* 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`. -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 diff --git a/onionshare_gui/webapp.py b/onionshare_gui/webapp.py index db4bcc52..80f2c3f8 100644 --- a/onionshare_gui/webapp.py +++ b/onionshare_gui/webapp.py @@ -26,17 +26,7 @@ import logging log_handler = logging.FileHandler('{0}/onionshare.web.log'.format(temp_dir)) log_handler.setLevel(logging.WARNING) -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 = Flask(__name__, template_folder='./templates') app.logger.addHandler(log_handler) @app.route("/") diff --git a/setup/onionshare-launcher.py b/setup/onionshare-launcher.py index f0b9b7c0..e8b4c0f5 100644 --- a/setup/onionshare-launcher.py +++ b/setup/onionshare-launcher.py @@ -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() diff --git a/setup/onionshare-win.spec b/setup/onionshare-win.spec new file mode 100644 index 00000000..b4debd5a --- /dev/null +++ b/setup/onionshare-win.spec @@ -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') diff --git a/setup/onionshare.ico b/setup/onionshare.ico new file mode 100644 index 00000000..ee2d0f63 Binary files /dev/null and b/setup/onionshare.ico differ