Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate DET executable files #232

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/release_actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: commcare-export release actions
on:
release:
types: [published]

jobs:
generate_release_assets:
name: Generate release assets
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Pull docker images for pyinstaller/wine
run: |
docker pull cdrx/pyinstaller-linux
docker pull cdrx/pyinstaller-windows

- name: Generate linux binary
run: |
docker run -v "$(pwd):/src/" cdrx/pyinstaller-linux

- name: Generate windows exe
run: |
docker run -v "$(pwd):/src/" cdrx/pyinstaller-windows

- name: Upload release assets
uses: AButler/upload-release-assets@v3.0
with:
files: "./dist/linux/*;./dist/windows/*"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where would we find this? Or does it automatically attach the asset to the release?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the files are automatically attached to the release as assets.

repo-token: ${{ secrets.GITHUB_TOKEN }}
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,11 @@ https://pypi.python.org/pypi/commcare-export

https://github.com/dimagi/commcare-export/releases

Once the release is created, a GitHub workflow is kicked off that generates two release artifacts,
which constitute executable files of the DET compatible with the following operating systems, namely
1. Linux
2. Windows


Testing and Test Databases
--------------------------
Expand Down Expand Up @@ -656,3 +661,18 @@ export HQ_API_KEY=<apikey>

For Travis builds these are included as encrypted vars in the travis
config.


Compiling executable files locally
-----------------------------------
The DET executable files are compiled using a tool called [pyinstaller](https://pyinstaller.org/en/stable/).
Pyinstaller is very easy to use, but only works out-of-the-box for Linux as support for cross-compilation was
dropped in earlier releases. Another tool, [wine](https://www.winehq.org/), can be used in conjuction with
pyinstaller to compile the Windows exe files.

Luckily in the world we live there's a repo out there called [docker-pyinstaller](https://github.com/cdrx/docker-pyinstaller)
which takes you through very simple steps to pull and use docker images to generate both the Linux binary and
Windows .exe files, so we don't ever have to worry about installing any additional packages ourselves.

Please note that the `commcare-export.spec` file used by the docker containers is already defined and sits at the top of this project.
It shouldn't be necessary for you to change any parameters in the file.
36 changes: 36 additions & 0 deletions commcare-export.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- mode: python ; coding: utf-8 -*-


a = Analysis(
['commcare_export/cli.py'],
pathex=[],
binaries=[],
datas=[('./commcare_export', '.')],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
noarchive=False,
)
pyz = PYZ(a.pure)

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name='commcare-export',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
Loading