Skip to content

Commit

Permalink
build windows exe with pyinstaller
Browse files Browse the repository at this point in the history
  • Loading branch information
fpletz committed Jan 21, 2024
1 parent b1da796 commit 659e755
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 3 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build

on:
push:

jobs:
build-windows:
runs-on: windows-2022
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Install Python
uses: actions/setup-python@v1
with:
python-version: '3.12'
architecture: 'x64'
- name: Install poetry
run: |
pip install poetry
- name: Build
run: |
poetry run build
- name: Upload artifacts
uses: actions/upload-artifacts@v2
with:
name: Windows
path: dist/mapbuilder.exe
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ __pycache__/
*$py.class
.idea
.direnv/
build/
dist/
6 changes: 6 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
pygeodesy = prev.pygeodesy.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or []) ++ [final.setuptools];
});
altgraph = prev.altgraph.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or []) ++ [final.setuptools];
});
pyinstaller = prev.pyinstaller.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or []) ++ [pkgs.zlib];
});
});
devEnv = poetry2nix.mkPoetryEnv {
inherit overrides;
Expand Down
13 changes: 13 additions & 0 deletions mapbuilder/pyinstaller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import PyInstaller.__main__
from pathlib import Path

HERE = Path(__file__).parent.absolute()
path_to_main = str(HERE / "__main__.py")

def install():
PyInstaller.__main__.run([
path_to_main,
'--onefile',
'--windowed',
'--name', 'mapbuilder',
])
111 changes: 109 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = ["Alex Legler <[email protected]>"]
license = "MIT"

[tool.poetry.dependencies]
python = "^3.11"
python = "~3.11"
Jinja2 = "^3.1.2"
shapely = "^2.0.2"
more-itertools = "^10.1.0"
Expand All @@ -18,10 +18,12 @@ xmltodict = "^0.13.0"

[tool.poetry.scripts]
mapbuilder = 'mapbuilder.__main__:entry'
build = "mapbuilder.pyinstaller:install"

[tool.poetry.group.dev.dependencies]
ruff = "0.1.8"
lxml-stubs = "^0.4.0"
pyinstaller = "^6.3.0"

[tool.ruff]
line-length = 100
Expand Down

0 comments on commit 659e755

Please sign in to comment.