Skip to content

Commit

Permalink
create executable using pyinstaller
Browse files Browse the repository at this point in the history
  • Loading branch information
achimmihca committed Aug 16, 2021
1 parent 32d1590 commit 2cb7123
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.idea/
dist/
build/
config.json
dedo_mouse.log
__pycache__/
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ However, licenses of the used libraries (see requirements.txt) differ.
For development only:
- pylint: [GPL v2.0](https://github.com/rr-/pylint/blob/main/LICENSE)
- mypy: [MIT and others](https://github.com/python/mypy/blob/master/LICENSE)
- pyinstaller: [Custom GPL](https://github.com/pyinstaller/pyinstaller/blob/develop/COPYING.txt)

## Create Executable
Open a console in the virtual environment, then run

`pyinstaller main.spec`

This should create a folder named `dist` with the executable.

## Trivia
'Dedo' is Spanish and means 'finger'.
54 changes: 54 additions & 0 deletions main.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# -*- mode: python ; coding: utf-8 -*-


block_cipher = None

# Needed to copy mediapipe files to correct location (https://stackoverflow.com/questions/67887088/issues-compiling-mediapipe-with-pyinstaller-on-macos)
def get_mediapipe_path():
import mediapipe
mediapipe_path = mediapipe.__path__[0]
return mediapipe_path

a = Analysis(['src\\main.py'],
pathex=['.\\'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)

# Needed to copy mediapipe files to correct location (https://stackoverflow.com/questions/67887088/issues-compiling-mediapipe-with-pyinstaller-on-macos)
mediapipe_tree = Tree(get_mediapipe_path(), prefix='mediapipe', excludes=["*.pyc"])
a.datas += mediapipe_tree
a.binaries = filter(lambda x: 'mediapipe' not in x[0], a.binaries)

exe = EXE(pyz,
a.scripts,
[],
exclude_binaries=True,
name='DedoMouse',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=False,
disable_windowed_traceback=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='main')
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ pyside6==6.1.2
rx==3.2.0
pylint==2.9.3
mypy==0.910
pyinstaller==4.5.1

0 comments on commit 2cb7123

Please sign in to comment.