Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
ENH: Update workflow to create executable
Browse files Browse the repository at this point in the history
  • Loading branch information
ArndalAndersen authored and ArndalAndersen committed May 1, 2019
1 parent 46b729e commit 57d5139
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
2019.1
------
- Improve, fix, and update how to create an executable
- Turn `pyqmix-web` into a proper Python package that can be published on PyPI
- Add entry point script, such that the user can now simply enter `pyqmix-web`
in their terminal after installation, which will fire up the backend and
Expand Down
10 changes: 6 additions & 4 deletions EXECUTABLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
## This guideline assumes that:
- A `run.py` file has been created.
Check out the `run.py` file in this repository.
- Flask serves static files from the `pyqmix` sub-directory of an automatically created temporary folder. The exact location of this folder is saved in the environment variable `_MEIPASS` when the `PyInstaller`-created standalone exectuable is started. Typically it will be located inside the current user's `AppData\Local\Temp` folder.
- Flask serves static files from an automatically created temporary folder. The exact location of this folder is saved in the environment variable `_MEIPASS` when the `PyInstaller`-created standalone exectuable is started. Typically it will be located inside the current user's `AppData\Local\Temp` folder.
Check out the `app.py` file in this repository.
- The frontend and backend are located in neighboring directories

## Prepare the Python virtual environment for the backend
- Create a virtual environment
- Install the required dependencies: `flask`, `flask-restplus`, and, of course, `pyqmix`
- Install `PyInstaller`
- Install the required dependencies: ` pip install flask flask-restplus pyqmix`. The executable will only work if flask and flask-restplus are installed via pip.
- Install PyInstaller: `pip install PyInstaller`
- The newest `jsonschema` module does not work with PyInstaller. Instead, use `jsonchema` in an older version, for example: 2.6.0.

## Create a production build of the React frontend
1. Open a terminal
Expand All @@ -35,7 +36,8 @@ This will create a run.spec file in the backend directory.
```
* Edit pathex to: `pathex=[spec_root]`
* Edit datas to: `datas=[('../name_of_frontend_folder/build', 'name_of_web_application')]`

* Optionally, you can add an icon to your standalone. Add `icon='../pyqmix_frontend/public/pyqmixweb_desktop_icon.ico'` to the EXE-section of run.spec.

## Build the executable
1. Open a terminal
2. Browse to the `pyqmix_backend` directory
Expand Down
2 changes: 1 addition & 1 deletion pyqmix_backend/run.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import webbrowser
from .backend_app import app
from pyqmix_backend.backend_app import app
import threading
import time
from urllib import request
Expand Down
10 changes: 6 additions & 4 deletions pyqmix_backend/run.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
# See:
# https://stackoverflow.com/a/50402636/1944216
# https://pythonhosted.org/PyInstaller/spec-files.html#globals-available-to-the-spec-file
block_cipher = None
import os
spec_root = os.path.abspath(SPECPATH)


a = Analysis(['run.py'],
pathex=[spec_root],
binaries=[],
Expand All @@ -18,18 +18,20 @@ a = Analysis(['run.py'],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
cipher=block_cipher,
noarchive=False)

pyz = PYZ(a.pure, a.zipped_data,
cipher=None)

cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='pyqmix-web',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
runtime_tmpdir=None,
Expand Down

0 comments on commit 57d5139

Please sign in to comment.