Skip to content

Commit

Permalink
Improve build process. Put commit sha in build. Add icon
Browse files Browse the repository at this point in the history
  • Loading branch information
alej0varas committed May 27, 2024
1 parent 5a56ec0 commit 75bcb82
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
/build/
/dist/
/.env
/src/_constants.py
/venv_w/
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
release:
rm -rf ./dist ./build
pyinstaller src/main.py --name mulpyplayer --onefile --clean --add-data "assets:assets"
# spec file generated unsing:
# pyinstaller src/main.py --name mulpyplayer --onefile --clean --add-data "assets:assets"
pyinstall:
pyinstaller mulpyplayer.spec
2 changes: 2 additions & 0 deletions Makefile.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:: spec fire generated using pyinstaller src/main.py --noconsole --name MulpyplayerWindows --onefile --clean --add-data "assets:assets" --icon assets/patricie.ico
pyinstaller MulpyplayerWindows.spec
39 changes: 39 additions & 0 deletions MulpyplayerWindows.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# -*- mode: python ; coding: utf-8 -*-


a = Analysis(
['src\\main.py'],
pathex=[],
binaries=[],
datas=[('assets', 'assets')],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name='MulpyplayerWindows',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon=['assets\\patricie.ico'],
)
Binary file added assets/patricie.ico
Binary file not shown.
48 changes: 48 additions & 0 deletions mulpyplayer.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# -*- mode: python ; coding: utf-8 -*-

# write runtime constants
import git

_repo = git.Repo(search_parent_directories=True)
_commit_sha = _repo.head.object.hexsha

with open("src/_constants.py", "w") as f:
f.write(f'COMMIT_SHA = "{_commit_sha[:8]}"\n')
# end constants

a = Analysis(
["src/main.py", "src/_constants.py"],
pathex=[],
binaries=[],
datas=[("assets", "assets")],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name="mulpyplayer",
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,
icon=[],
)
17 changes: 11 additions & 6 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
# for pyinstall as explained here:
# https://api.arcade.academy/en/development/tutorials/bundling_with_pyinstaller/index.html#handling-data-files
import argparse
import os
import sys

# for pyinstall as explained here:
# https://api.arcade.academy/en/development/tutorials/bundling_with_pyinstaller/index.html#handling-data-files
_sha = ""
if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
os.chdir(sys._MEIPASS)
# end for pyinstall

import argparse
# load constants created at build time
import _constants

from bcp.gui import main
_sha = _constants.COMMIT_SHA
os.environ["COMMIT_SHA"] = _sha
# end for pyinstall

# this import must be placed after os.chdir
from bcp.gui import main # noqa: E402

if __name__ == "__main__":
parser = argparse.ArgumentParser()
Expand Down

0 comments on commit 75bcb82

Please sign in to comment.