aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2016-02-12 15:45:26 -0800
committerMicah Lee <micah@micahflee.com>2016-02-12 15:45:26 -0800
commitdeac54db92bcabacaa50016e8f37ca1a5d10b3a2 (patch)
tree70e339e4273522422b91230d291048c33312fdaf
parent62c69c4c0b2b9be0f273303c4326279ff56cd011 (diff)
downloadonionshare-deac54db92bcabacaa50016e8f37ca1a5d10b3a2.tar.gz
onionshare-deac54db92bcabacaa50016e8f37ca1a5d10b3a2.zip
Made sure switch to python3 and Qt5 works in OSX (#261). Updated OSX instructions in BUILD.md.
-rw-r--r--.gitignore1
-rw-r--r--BUILD.md38
-rwxr-xr-xinstall/build_osx.sh4
-rwxr-xr-xinstall/osx_scripts/onionshare2
-rwxr-xr-xinstall/osx_scripts/onionshare-gui1
-rw-r--r--install/prepare_for_codesign.py6
-rw-r--r--onionshare/helpers.py4
-rw-r--r--onionshare/strings.py3
-rw-r--r--onionshare_gui/onionshare_gui.py16
-rw-r--r--setup.py16
10 files changed, 54 insertions, 37 deletions
diff --git a/.gitignore b/.gitignore
index 7f30a5a0..20342555 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@
# Packages
*.egg
*.egg-info
+*.eggs
dist
deb_dist
build
diff --git a/BUILD.md b/BUILD.md
index 4604a6e2..e3c79f2c 100644
--- a/BUILD.md
+++ b/BUILD.md
@@ -33,19 +33,43 @@ There is a PKBUILD available [here](https://aur.archlinux.org/packages/onionshar
## Mac OS X
-Install the [latest python 2.x](https://www.python.org/downloads/) from python.org. If you use the built-in version of python that comes with OS X, your .app might not run on other people's computers.
+Install Xcode from the Mac App Store. Once it's installed, run it for the first time to set it up.
-To install the right dependencies, you need homebrew and pip installed on your Mac. Follow instructions at http://brew.sh/ to install homebrew, and run `sudo easy_install pip` to install pip.
+Install the [latest Python 3.x from python.org](https://www.python.org/downloads/). If you use the built-in version of python that comes with OS X, your .app might not run on other people's computers.
-The first time you're setting up your dev environment:
+Download and install Qt5 from https://www.qt.io/download-open-source/. I downloaded `qt-unified-mac-x64-2.0.2-2-online.dmg`. There's no need to login to a Qt account during installation. Make sure you install the latest Qt 5.x for clang.
+
+Download the source code for [SIP](http://www.riverbankcomputing.co.uk/software/sip/download) and [PyQt](http://www.riverbankcomputing.co.uk/software/pyqt/download5). I downloaded `sip-4.17.tar.gz` and `PyQt-gpl-5.5.1.tar.gz`.
+
+Now extract the source code:
+
+```sh
+tar xvf sip-4.17.tar.gz
+tar xvf PyQt-gpl-5.5.1.tar.gz
+```
+
+Compile SIP:
```sh
-echo export PYTHONPATH=\$PYTHONPATH:/usr/local/lib/python2.7/site-packages/ >> ~/.profile
-source ~/.profile
-brew install qt4 pyqt
-sudo pip install py2app flask stem
+cd sip-4.17
+python3 configure.py --arch x86_64
+make
+sudo make install
+sudo make clean
```
+Compile PyQt:
+
+```sh
+cd ../PyQt-gpl-5.5.1
+python3 configure.py --qmake ~/Qt/5.5/clang_64/bin/qmake --sip /Library/Frameworks/Python.framework/Versions/3.5/bin/sip --disable=QtPositioning
+make
+sudo make install
+sudo make clean
+```
+
+Finally, install some dependencies using pip3: `sudo pip3 install py2app flask stem`
+
Get the source code:
```sh
diff --git a/install/build_osx.sh b/install/build_osx.sh
index a1acda51..10cf2609 100755
--- a/install/build_osx.sh
+++ b/install/build_osx.sh
@@ -9,14 +9,14 @@ rm -rf $ROOT/dist &>/dev/null 2>&1
# build the .app
echo Building OnionShare.app
-python setup.py py2app
+python3 setup.py py2app
if [ "$1" = "--sign" ]; then
SIGNING_IDENTITY_APP="Developer ID Application: Micah Lee"
SIGNING_IDENTITY_INSTALLER="Developer ID Installer: Micah Lee"
# codesign the .app
- python $ROOT/install/prepare_for_codesign.py
+ python3 $ROOT/install/prepare_for_codesign.py
cd dist
# for some reason --deep fails, so sign each binary individually
diff --git a/install/osx_scripts/onionshare b/install/osx_scripts/onionshare
index fd374db8..d270b5af 100755
--- a/install/osx_scripts/onionshare
+++ b/install/osx_scripts/onionshare
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
OnionShare | https://onionshare.org/
diff --git a/install/osx_scripts/onionshare-gui b/install/osx_scripts/onionshare-gui
index 333ffb56..99eb9dc2 100755
--- a/install/osx_scripts/onionshare-gui
+++ b/install/osx_scripts/onionshare-gui
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
OnionShare | https://onionshare.org/
diff --git a/install/prepare_for_codesign.py b/install/prepare_for_codesign.py
index 3e99eece..e210cc20 100644
--- a/install/prepare_for_codesign.py
+++ b/install/prepare_for_codesign.py
@@ -10,11 +10,11 @@ import shutil
path_to_app = "dist/OnionShare.app"
def move_func(file):
- print "moving %s to %s " % (os.path.join(dir_name, file), os.path.join(dir_name, 'Versions', "Current"))
+ print("moving %s to %s " % (os.path.join(dir_name, file), os.path.join(dir_name, 'Versions', "Current")))
try:
shutil.move(os.path.join(dir_name, file), os.path.join(dir_name, 'Versions', "Current"))
except Exception as e:
- print e
+ print(e)
return file
def filter_func(x):
@@ -29,7 +29,7 @@ for dir_name, subdir_list, file_list in os.walk(dir):
if p.match(dir_name_short):
print('Found directory: %s' % dir_name_short)
- print file_list
+ print(file_list)
if os.path.islink(os.path.join(dir_name, file_list[0])):
os.unlink(os.path.join(dir_name, file_list[0]))
list(map(move_func, file_list[1:]))
diff --git a/onionshare/helpers.py b/onionshare/helpers.py
index 58c9a8da..c6cccb3b 100644
--- a/onionshare/helpers.py
+++ b/onionshare/helpers.py
@@ -66,9 +66,9 @@ def get_version():
if p == 'Linux':
version_filename = os.path.join(sys.prefix, 'share/onionshare/version')
elif p == 'Darwin':
- version_filename = os.path.join(helpers.osx_resources_dir, 'version')
+ version_filename = os.path.join(osx_resources_dir, 'version')
else:
- version_filename = os.path.join(os.path.dirname(helpers.get_onionshare_dir()), 'version')
+ version_filename = os.path.join(os.path.dirname(get_onionshare_dir()), 'version')
return open(version_filename).read().strip()
diff --git a/onionshare/strings.py b/onionshare/strings.py
index c211668b..3dff2b5c 100644
--- a/onionshare/strings.py
+++ b/onionshare/strings.py
@@ -46,7 +46,8 @@ def load_strings(default="en"):
abs_filename = os.path.join(locale_dir, filename)
lang, ext = os.path.splitext(filename)
if abs_filename.endswith('.json'):
- translations[lang] = json.loads(open(abs_filename).read())
+ lang_json = open(abs_filename, encoding='utf-8').read()
+ translations[lang] = json.loads(lang_json)
strings = translations[default]
lc, enc = locale.getdefaultlocale()
diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py
index 4ddacd23..52aaf882 100644
--- a/onionshare_gui/onionshare_gui.py
+++ b/onionshare_gui/onionshare_gui.py
@@ -23,11 +23,7 @@ from PyQt5 import QtCore, QtWidgets, QtGui
from . import common
-try:
- import onionshare
-except ImportError:
- sys.path.append(os.path.abspath(common.onionshare_gui_dir + "/.."))
- import onionshare
+import onionshare
from onionshare import strings, helpers, web
from .file_selection import FileSelection
@@ -56,7 +52,7 @@ class Application(QtWidgets.QApplication):
return False
-class OnionShareGui(QtWidgets.QWidget):
+class OnionShareGui(QtWidgets.QMainWindow):
"""
OnionShareGui is the main window for the GUI that contains all of the
GUI elements.
@@ -112,8 +108,9 @@ class OnionShareGui(QtWidgets.QWidget):
self.status_bar = QtWidgets.QStatusBar()
self.status_bar.setSizeGripEnabled(False)
version_label = QtWidgets.QLabel('v{0:s}'.format(helpers.get_version()))
- version_label.setStyleSheet('color: #666666;')
+ version_label.setStyleSheet('color: #666666; padding: 0 10px;')
self.status_bar.addPermanentWidget(version_label)
+ self.setStatusBar(self.status_bar)
# main layout
self.layout = QtWidgets.QVBoxLayout()
@@ -122,8 +119,9 @@ class OnionShareGui(QtWidgets.QWidget):
self.layout.addWidget(self.filesize_warning)
self.layout.addLayout(self.downloads)
self.layout.addLayout(self.options)
- self.layout.addWidget(self.status_bar)
- self.setLayout(self.layout)
+ central_widget = QtWidgets.QWidget()
+ central_widget.setLayout(self.layout)
+ self.setCentralWidget(central_widget)
self.show()
# check for requests frequently
diff --git a/setup.py b/setup.py
index ab1d990c..9ad89b47 100644
--- a/setup.py
+++ b/setup.py
@@ -106,7 +106,8 @@ elif system == 'Darwin':
data_files=[
('images', images),
('locale', locale),
- ('html', ['onionshare/index.html', 'onionshare/404.html'])
+ ('html', ['onionshare/index.html', 'onionshare/404.html']),
+ ('', ['version'])
],
options={
'py2app': {
@@ -114,17 +115,8 @@ elif system == 'Darwin':
'iconfile': 'install/onionshare.icns',
'extra_scripts': ['install/osx_scripts/onionshare'],
'includes': [
- 'PyQt4', 'PyQt4.QtCore', 'PyQt4.QtGui',
- 'jinja2', 'jinja2.ext', 'jinja2.ext.autoescape'],
- 'excludes': [
- 'PyQt4.QtDesigner', 'PyQt4.QtNetwork',
- 'PyQt4.QtOpenGL', 'PyQt4.QtScript',
- 'PyQt4.QtSql', 'PyQt4.QtTest',
- 'PyQt4.QtWebKit', 'PyQt4.QtXml',
- 'PyQt4.phonon', 'PyQt4.QtDeclarative',
- 'PyQt4.QtHelp', 'PyQt4.QtMultimedia',
- 'PyQt4.QtScript', 'PyQt4.QtScriptTools',
- 'PyQt4.QtSvg', 'PyQt4.QtXmlPatterns']
+ 'PyQt5', 'PyQt5.QtCore', 'PyQt5.QtGui', 'PyQt5.QtWidgets',
+ 'jinja2', 'jinja2.ext', 'jinja2.ext.autoescape', 'sip']
}
},
setup_requires=['py2app', 'flask', 'stem'],