From 694260e72fcffcf4b0f7fb47d09703cb6bd78521 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= <sybren@stuvel.eu>
Date: Wed, 23 Aug 2017 17:36:54 +0200
Subject: [PATCH] Initial support for pyinstaller, needs testing & documenting

It also needs to be extended to include the system integration files.
---
 README.md            |  5 +++++
 flamenco-worker.py   |  7 +++++++
 flamenco-worker.spec | 40 ++++++++++++++++++++++++++++++++++++++++
 requirements-dev.txt |  1 +
 4 files changed, 53 insertions(+)
 create mode 100644 flamenco-worker.py
 create mode 100644 flamenco-worker.spec

diff --git a/README.md b/README.md
index 83451c7d..5bb3aef8 100644
--- a/README.md
+++ b/README.md
@@ -117,3 +117,8 @@ Flamenco Worker responds to the following POSIX signals:
 Run `python setup.py zip` to create a distributable zip file. It contains the Wheel,
 example configuration file, this README.md, license information and system integration
 files.
+
+Run `pyinstaller flamenco-worker.spec` to create a distributable directory in
+`dist/flamenco-worker-{version}` that contains a directly runnable Flamenco Worker.
+This build then doesn't require installing Python or any dependencies, and can be
+directly run on a target machine of the same OS.
diff --git a/flamenco-worker.py b/flamenco-worker.py
new file mode 100644
index 00000000..daa23dc0
--- /dev/null
+++ b/flamenco-worker.py
@@ -0,0 +1,7 @@
+#!/usr/bin/env python3
+
+# This script serves as entry point for PyInstaller.
+
+from flamenco_worker import cli
+
+cli.main()
diff --git a/flamenco-worker.spec b/flamenco-worker.spec
new file mode 100644
index 00000000..3a097704
--- /dev/null
+++ b/flamenco-worker.spec
@@ -0,0 +1,40 @@
+# -*- mode: python -*-
+
+# This definition is used by PyInstaller to build ready-to-run bundles.
+
+from flamenco_worker import __version__
+
+block_cipher = None
+
+
+a = Analysis(['flamenco-worker.py'],
+             pathex=['./flamenco-worker-python'],
+             binaries=[],
+             datas=[('flamenco-worker.cfg', '.'),
+                    ('README.md', '.'),
+                    ('CHANGELOG.md', '.'),
+                    ('LICENSE.txt', '.')],
+             hiddenimports=[],
+             hookspath=[],
+             runtime_hooks=[],
+             excludes=[],
+             win_no_prefer_redirects=False,
+             win_private_assemblies=False,
+             cipher=block_cipher)
+pyz = PYZ(a.pure, a.zipped_data,
+             cipher=block_cipher)
+exe = EXE(pyz,
+          a.scripts,
+          exclude_binaries=True,
+          name='flamenco-worker',
+          debug=False,
+          strip=False,
+          upx=True,
+          console=True )
+coll = COLLECT(exe,
+               a.binaries,
+               a.zipfiles,
+               a.datas,
+               strip=False,
+               upx=True,
+               name='flamenco-worker-%s' % __version__)
diff --git a/requirements-dev.txt b/requirements-dev.txt
index f122cc5e..bcd9c6e5 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -1,2 +1,3 @@
 -r requirements-test.txt
 ipython
+pyinstaller
-- 
GitLab