Skip to content

Commit

Permalink
Packaging: Fix PyInstaller spec to import local-packages
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosperate committed May 6, 2017
1 parent 4eea904 commit 1de2cfe
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ before_install:
- pip3 install coveralls
#- pip3 install pydocstyle
- pip3 install mkdocs
- pip3 install pyinstaller
# We need a newer unreleased version of PyInstaller for Python 3.5
- pip3 install https://github.com/pyinstaller/pyinstaller/archive/964547cd92cabe28150d52c2ca809de74a5ddbaa.zip

# Check Python, pip and package versions
- python -c "import sys; print(sys.executable)"
Expand Down
4 changes: 3 additions & 1 deletion ardublockly/ardublockly.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ Ardublockly.init = function() {
Ardublockly.bindBlocklyEventListeners();

// Hackish way to check if not running locally
if (document.location.hostname != '127.0.0.1') {
if (document.location.hostname != 'localhost') {
Ardublockly.openNotConnectedModal();
console.log('Offline app modal opened as non localhost host name found: ' +
document.location.hostname)
}
};

Expand Down
4 changes: 1 addition & 3 deletions package/build_pyinstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
os.path.dirname( # going up 1 level
os.path.dirname(os.path.realpath(__file__))) # folder dir of this
sys.path.append(project_root_dir)
# Add the local-packages to sys path
from ardublocklyserver import local_packages_path
sys.path.insert(0, local_packages_path)


spec_coll_name = "server"
exec_folder_name = "arduexec"
Expand Down
19 changes: 17 additions & 2 deletions package/pyinstaller.spec
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
# -*- mode: python -*-

# This spec file counts on the PyInstaller script being executed from the
# project root directory, otherwise the start_cef.py file path will have to
# project root directory, otherwise the start.py file path will have to
# be updated.

# We have a 'local-packages' folder with modules, need to expand sys.path
import os
import sys
project_root = os.path.realpath('')
print('PyInstaller defined project root: %s' % project_root)
local_packages = os.path.join(
project_root, 'ardublocklyserver', 'local-packages')
sys.path.insert(0, project_root)
sys.path.insert(0, local_packages)

# Import required modules, ensures PyInstaller fails if it cannot find them
import ardublockly
import six, configparser, serial, waitress, bottle


block_cipher = None

a = Analysis(['../start.py'],
pathex=None,
hiddenimports=["ardublocklyserver"],
hiddenimports=['ardublocklyserver', 'waitress'],
hookspath=None,
runtime_hooks=None,
excludes=None)
Expand Down
5 changes: 4 additions & 1 deletion start.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ def main():
"""
print('Running Python %s (%s bit) on %s' % (platform.python_version(),
(struct.calcsize('P') * 8), platform.platform()))
print('Local packages path: %s' % ardublocklyserver.local_packages_path)
if os.path.isdir(ardublocklyserver.local_packages_path):
print('Local packages: %s' % ardublocklyserver.local_packages_path)
else:
print('Not using local-packages.')

print('\n======= Parsing Command line arguments =======')
find_project_root, launch_browser, server_root = parsing_cl_args()
Expand Down

0 comments on commit 1de2cfe

Please sign in to comment.