Skip to content

Commit 1de2cfe

Browse files
committed
Packaging: Fix PyInstaller spec to import local-packages
1 parent 4eea904 commit 1de2cfe

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ before_install:
4242
- pip3 install coveralls
4343
#- pip3 install pydocstyle
4444
- pip3 install mkdocs
45-
- pip3 install pyinstaller
45+
# We need a newer unreleased version of PyInstaller for Python 3.5
46+
- pip3 install https://github.com/pyinstaller/pyinstaller/archive/964547cd92cabe28150d52c2ca809de74a5ddbaa.zip
4647

4748
# Check Python, pip and package versions
4849
- python -c "import sys; print(sys.executable)"

ardublockly/ardublockly.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ Ardublockly.init = function() {
2727
Ardublockly.bindBlocklyEventListeners();
2828

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

package/build_pyinstaller.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@
3131
os.path.dirname( # going up 1 level
3232
os.path.dirname(os.path.realpath(__file__))) # folder dir of this
3333
sys.path.append(project_root_dir)
34-
# Add the local-packages to sys path
35-
from ardublocklyserver import local_packages_path
36-
sys.path.insert(0, local_packages_path)
34+
3735

3836
spec_coll_name = "server"
3937
exec_folder_name = "arduexec"

package/pyinstaller.spec

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
11
# -*- mode: python -*-
22

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

7+
# We have a 'local-packages' folder with modules, need to expand sys.path
8+
import os
9+
import sys
10+
project_root = os.path.realpath('')
11+
print('PyInstaller defined project root: %s' % project_root)
12+
local_packages = os.path.join(
13+
project_root, 'ardublocklyserver', 'local-packages')
14+
sys.path.insert(0, project_root)
15+
sys.path.insert(0, local_packages)
16+
17+
# Import required modules, ensures PyInstaller fails if it cannot find them
18+
import ardublockly
19+
import six, configparser, serial, waitress, bottle
20+
21+
722
block_cipher = None
823

924
a = Analysis(['../start.py'],
1025
pathex=None,
11-
hiddenimports=["ardublocklyserver"],
26+
hiddenimports=['ardublocklyserver', 'waitress'],
1227
hookspath=None,
1328
runtime_hooks=None,
1429
excludes=None)

start.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ def main():
134134
"""
135135
print('Running Python %s (%s bit) on %s' % (platform.python_version(),
136136
(struct.calcsize('P') * 8), platform.platform()))
137-
print('Local packages path: %s' % ardublocklyserver.local_packages_path)
137+
if os.path.isdir(ardublocklyserver.local_packages_path):
138+
print('Local packages: %s' % ardublocklyserver.local_packages_path)
139+
else:
140+
print('Not using local-packages.')
138141

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

0 commit comments

Comments
 (0)