diff --git a/BUILD.md b/BUILD.md index 668e386a..69bb4db5 100644 --- a/BUILD.md +++ b/BUILD.md @@ -20,8 +20,8 @@ sudo apt-get install -y python3-flask python3-stem python3-pyqt5 python-nautilus After that you can try both the CLI and the GUI version of OnionShare: ```sh -./install/scripts/onionshare -./install/scripts/onionshare-gui +./dev_scripts/onionshare +./dev_scripts/onionshare-gui ``` A script to build a .deb package and install OnionShare easily is also provided for your convenience: diff --git a/dev_scripts/onionshare b/dev_scripts/onionshare new file mode 100755 index 00000000..b94d1139 --- /dev/null +++ b/dev_scripts/onionshare @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +OnionShare | https://onionshare.org/ + +Copyright (C) 2016 Micah Lee + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +""" + +# Load onionshare module and resources from the source code tree +import os, sys +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +sys.onionshare_dev_mode = True + +import onionshare +onionshare.main() diff --git a/dev_scripts/onionshare-gui b/dev_scripts/onionshare-gui new file mode 100755 index 00000000..6d610bb6 --- /dev/null +++ b/dev_scripts/onionshare-gui @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +OnionShare | https://onionshare.org/ + +Copyright (C) 2016 Micah Lee + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +""" + +# Load onionshare module and resources from the source code tree +import os, sys +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +sys.onionshare_dev_mode = True + +import onionshare_gui +onionshare_gui.main() diff --git a/onionshare/helpers.py b/onionshare/helpers.py index 6ad8f80d..5d321c0b 100644 --- a/onionshare/helpers.py +++ b/onionshare/helpers.py @@ -34,14 +34,17 @@ def get_resource_path(filename): systemwide, and whether regardless of platform """ p = get_platform() - if p == 'Linux' and sys.argv and sys.argv[0].startswith(sys.prefix): + + if getattr(sys, 'onionshare_dev_mode', False): + # Look for resources directory relative to python file + resources_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))), 'resources') + + elif p == 'Linux' and sys.argv and sys.argv[0].startswith(sys.prefix): # OnionShare is installed systemwide in Linux resources_dir = os.path.join(sys.prefix, 'share/onionshare') elif getattr(sys, 'frozen', False): # Check if app is "frozen" with cx_Freeze # http://cx-freeze.readthedocs.io/en/latest/faq.html#using-data-files resources_dir = os.path.join(os.path.dirname(sys.executable), 'resources') - else: # Look for resources directory relative to python file - resources_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))), 'resources') return os.path.join(resources_dir, filename)