Commit 13fb6c14 authored by carlosperate's avatar carlosperate

Added PyInstaller spec file and linux build script.

parent 8c6e9ba0
......@@ -86,6 +86,7 @@ cef_debug.log
# Packaged python build folders and files
/win
/arduexec
/package/build
/ardublockly_run.bat
......
......@@ -6,10 +6,12 @@ https://github.com/google/blockly
It adds the following features:
* Arduino code generation
* Arduino specific blocks
* Static Typing
* Code warnings
This fork frequently pulls updates from upstream to maintain it up to date.
This fork gets frequent upstream pulls to maintain it up to date.
## Git configuration
......@@ -17,21 +19,25 @@ This fork is configured as a Git Subtree, this is done to be able to pull all th
### Pulling from upstream
Adding the blockly repository as a remote and fetching latest:
```
git remote add -f blockly https://github.com/google/blockly.git
```
Pulling from blockly master, from the project root directory:
```
git fetch blockly master
git subtree pull --prefix blockly blockly master
```
The pull all the changes into a single commit the flag `---squashed` can be added to the `subtree pull` command.
To pull all the changes into a single commit the flag `---squashed` can be added to the `subtree pull` command.
Then resolve any conflicts and push to origin.
## Blockly
Google's Blockly is a web-based, visual programming editor. Users can drag
......
# Ardublockly package
This folder contains the Python scripts required to package Ardublockly into a standalone executable. This way it can be distributed without any dependencies other than having the Arduino IDE.
Currently it is only built for Windows, but it could be updated to be built for Linux and Mac OS X (a move from py2exe to Pyinstaller is planned).
Currently the Windows build is created using py2exe and the Linux and Mac OS X builds are created using PyInstaller (in the future PyInstaller might be updated to also create the Windows builds, for now the original py2exe script is pretty stable).
__Downloading the packaged Ardublockly__: The binaries will be hosted in GitHub as part of the [repository releases][1].
## Building Ardublockly from source
These scripts have tested using Python 2.7.
These build scripts only work on Python 2.7.
While it is possible to maintain compatibility with other Python versions (the ArdublocklyServer Python package used in the developer installation has been tested on Python 2.7 and 3.4), due to the multiple individual perks of the python libraries used here, a single build environment will be targeted.
Git also needs to be installed on the system.
While the non-GUI version of Ardublockly (command line server + system browser) is compatible with other Python versions (tested on Python 2.7 and 3.4), due to the individual perks of the python libraries used here and unavailability of CEF Python 3 bindings, a single build environment based on Python 2.7 will be targeted.
If you are using Python virtual environments on Windows this [collection of Python extensions binaries][2] is highly recommended.
### Python dependencies
The specific version of the Python dependencies can be found in the [requirements.txt][3] file.
The specific versions of the Python dependencies can be found in the [requirements.txt][3] file.
#### cefpython3
CEF Python provides Python bindings for the Chromium Embedded Framework. This is used in Ardublockly to create a webview of the Ardublockly web app without requiring any specific browser installation. This is specially useful for the project because the frameworks used work best on the Chrome engine.
[Install cefpython following their project installation instructions][5]. On Windows and Mac OS X cefpython can be easily installed using pip:
```
pip install cefpython3
```
#### wxPython
wxPython provides python bindings for the wxWidgets, the cross-platform GUI toolkit.
You can download wxPython from their [official website][4].
#### cefpython3
CEF Python provides python bindings for the Chromium Embedded Framework. This is used in Ardublockly to create a webview of the Ardublockly web app without requiring any specific browser installation. This is specially useful for the project because the frameworks used work best on the Chrome engine.
[Install cefpython following their project installation instructions][5]
(I have recently found some odd issues in Ubuntu 15.04 when cefpython is running with wxPython version 3.0.2.0, reverting back to the 2.8.12.1 version seemed to fix them.)
#### py2exe
py2exe is a Distutils extension to build Python scripts into Windows executable programs.
py2exe is a Distutils extension to build Python scripts into Windows executable programs.
There is a plan to migrate from py2exe to Pyinstaller, but for now this is the main library used to create the Windows build.
This package is only required for the Windows build. The Linux and Mac OS X builds use PyInstaller.
You can download py2exe from their [official website][6].
#### PyInstaller
Converts (packages) Python programs into stand-alone executables, used for the Linux and Mac OS X builds.
You can download PyInstaller from the official [repository wiki][9]. As the version stored in Pypi is quite old, pip would install an outdated version that won't work with the current specs file.
#### MkDocs
MkDocs is a static page generator specifically designed for documentation using Markdown.
The project documentation is written and hosted in the [Arudblockly repository GitHub Wiki][7]. The build script for the documentation pulls its markdown files and converts them into an HTML static site for offline access.
The project documentation is written and hosted in the [Ardublockly repository GitHub Wiki][7]. The build script for the documentation pulls its markdown files and converts them into an HTML static site for offline access.
More information about this procedure can be found in [this article][8].
MkDocs can be easily installed using pip:
```
pip install MkDocs
```
## Build steps
Download and initialise this project repository:
```
git clone https://github.com/carlosperate/ardublockly.git
cd ardublockly
......@@ -51,16 +72,23 @@ git submodule update
```
Now navigate to the `package` folder in the project directory:
```
cd package
```
To first build the offline documentation execute the `build_docs.py` file. This will add a folder named `documentation` into the project root directory:
```
python build_docs.py
```
To build Ardublockly all you have to do is execute the `build_windows.py` file:
The build steps for Ardublockly are slightly different depending on the platform.
### Windows Build
To build Ardublockly under windows all you have to do is execute the `build_windows.py` file from the `package` directory :
```
python build_windows.py
```
......@@ -70,6 +98,14 @@ This will remove any previous build directory (`/win` directory in project root)
To run Ardublockly on Windows execute the `ardublockly_run.bat` file.
### Linux Build
This part of the documentation is still under work.
### Mac OS X Build
This part of the documentation is still under work.
[1]: https://github.com/carlosperate/ardublockly/releases/
[2]: http://www.lfd.uci.edu/~gohlke/pythonlibs/
[3]: requirements.txt
......@@ -78,3 +114,4 @@ To run Ardublockly on Windows execute the `ardublockly_run.bat` file.
[6]: http://www.py2exe.org/
[7]: https://github.com/carlosperate/ardublockly/wiki
[8]: http://www.embeddedlog.com/static-docs-from-github-wiki.html
[9]: https://github.com/pyinstaller/pyinstaller/wiki
#!/usr/bin/env python2
# -*- coding: utf-8 -*- #
#
# Builds the Ardublockly application for Linux.
#
# Copyright (c) 2015 carlosperate https://github.com/carlosperate/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import os
import shutil
import subprocess
import cefpython3
from glob import glob
# The project_root_dir depends on the location of this file, so it cannot be
# moved without updating this line
project_root_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
exec_folder_name = "arduexec"
script_tag = "[Ardublockly build] "
script_tab = " "
def remove_pyinstaller_temps():
""" Removes the temporary folders created by PyInstaller. """
dist_dir = os.path.join(os.getcwd(), "dist")
build_dir = os.path.join(os.getcwd(), "build")
if os.path.exists(dist_dir):
shutil.rmtree(dist_dir)
if os.path.exists(build_dir):
shutil.rmtree(build_dir)
def remove_executable_folder():
""" Removes the current ardublockly PyInstaller executable folder. """
exec_dir = os.path.join(project_root_dir, "dist", exec_folder_name)
if os.path.exists(exec_dir):
shutil.rmtree(exec_dir)
def pyinstaller_build():
""" . """
process = ["python",
"package/pyinstaller/pyinstaller.py",
"package/pyinstaller.spec"]
print(script_tab + "Command: %s" % process)
subprocess.call(process)
def move_executable_folder():
""" Moves the PyInstaller executable folder from dist to project root. """
original_exec_dir = os.path.join(project_root_dir, "dist", exec_folder_name)
if os.path.exists(original_exec_dir):
shutil.move(original_exec_dir, project_root_dir)
def copy_cefpython_data_files():
""" Copies into the executable folder required cefpython files. """
cef_path = os.path.dirname(cefpython3.__file__)
cef_exec_folder = os.path.join(
project_root_dir, exec_folder_name, "cefpython3")
cef_exec_locales = os.path.join(cef_exec_folder, "locales")
data_files = [
"%s/libcef.so" % cef_path,
"%s/libffmpegsumo.so" % cef_path,
"%s/subprocess" % cef_path]
locales = glob(r"%s/locales/*.*" % cef_path)
# Ensure the cefpython3 folders are created
if not os.path.exists(cef_exec_folder):
os.makedirs(cef_exec_folder)
if not os.path.exists(cef_exec_locales):
os.makedirs(cef_exec_locales)
# Copy all the files
for f in data_files:
shutil.copy(f, cef_exec_folder)
for f in locales:
shutil.copy(f, cef_exec_locales)
def main():
print(script_tag + "Building Ardublockly for Linux.")
print(script_tag + "Project directory is: %s" % project_root_dir)
print(script_tag + "Script working directory: %s" % os.getcwd())
print(script_tag + "Removing PyInstaller old temp directories.")
remove_pyinstaller_temps()
print(script_tag + "Running PyInstaller process:")
pyinstaller_build()
print(script_tag + "Moving executable folder to project root.")
move_executable_folder()
print(script_tag + "Coping cefpython data files into executable directory.")
copy_cefpython_data_files()
print(script_tag + "Removing PyInstaller recent temp directories.")
remove_pyinstaller_temps()
if __name__ == "__main__":
main()
# -*- mode: python -*-
# set up directories
#this_file_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
#this_file_parent = os.path.dirname(this_file_dir)
#def get_cefpython_path():
# from cefpython3 import cefpython
# return "%s%s" % (os.path.dirname(cefpython.__file__), os.sep)
#cef_path = get_cefpython_path()
# Enable the ArdublocklyServer package access the sys path for pyinstaller to find
#sys.path.append(this_file_parent)
block_cipher = None
a = Analysis(['start_cef.py'],
pathex=None,
hiddenimports=["ArdublocklyServer", "cefpython3", "wx"],
hookspath=None,
runtime_hooks=None,
excludes=None,
cipher=block_cipher)
pyz = PYZ(a.pure,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=False,
name='ardublockly',
debug=False,
strip=None,
upx=True,
console=False)
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=None,
upx=True,
name='arduexec')
cefpython3=>31.2
py2exe=>0.6.9
wxPython=>3.0.2.0
wxPython-common=>3.0.2.0
mkdocs=>0.12.1
mkdocs>=0.12.1
cefpython3>=31.2
py2exe>=0.6.9
wxPython>=3.0.2.0
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment