Skip to content

Commit

Permalink
Merge pull request #158 from dlyongemallo/pyinstaller_executable
Browse files Browse the repository at this point in the history
Add zxlive.spec file for creating an executable using pyinstaller.
  • Loading branch information
jvdwetering authored Oct 31, 2023
2 parents db88e7a + 34f7b67 commit 703530f
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 59 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
__pycache__
build
dist
*.egg-info
.vs
*.tikz
Expand All @@ -11,4 +12,4 @@ build
*.zxp
*.qasm
.env
*.zxr
*.zxr
4 changes: 4 additions & 0 deletions zxlive.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from zxlive import app

if __name__ == '__main__':
app.main()
46 changes: 46 additions & 0 deletions zxlive.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# -*- mode: python ; coding: utf-8 -*-

# To create executable, run:
# pyinstaller zxlive.spec
# This will create a directory called "dist" containing the executable for the host OS.


a = Analysis(
['zxlive.py'],
pathex=[],
binaries=[],
datas=[('zxlive/icons/magic-wand.svg', 'zxlive/icons'),
('zxlive/icons/tikzit-tool-edge.svg', 'zxlive/icons'),
('zxlive/icons/tikzit-tool-node.svg', 'zxlive/icons'),
('zxlive/icons/tikzit-tool-select.svg', 'zxlive/icons'),
('zxlive/icons/undo.svg', 'zxlive/icons'),
('zxlive/icons/redo.svg', 'zxlive/icons')],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
)
pyz = PYZ(a.pure)

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name='zxlive',
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,
)
4 changes: 3 additions & 1 deletion zxlive/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

_ROOT = os.path.abspath(os.path.dirname(__file__))


def get_data(path: str) -> str:
return os.path.join(_ROOT, path)
return os.path.join(os.environ.get("_MEIPASS", _ROOT), path)


CUSTOM_RULES_PATH: Final = "lemmas/"

Expand Down
6 changes: 5 additions & 1 deletion zxlive/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ def import_diagram_from_file(file_path: str, selected_filter: str = FileFormat.A
selected_format = next(f for f in FileFormat if f.filter == selected_filter)
if selected_format == FileFormat.All:
ext = file_path.split(".")[-1]
selected_format = next(f for f in FileFormat if f.extension == ext)
try:
selected_format = next(f for f in FileFormat if f.extension == ext)
except StopIteration:
show_error_msg("Failed to import file", f"Couldn't determine filetype: {file_path}.")
return None

# TODO: This would be nicer with match statements (requires python 3.10 though)...
try:
Expand Down
26 changes: 1 addition & 25 deletions zxlive/icons/redo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions zxlive/icons/tikzit-tool-edge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions zxlive/icons/tikzit-tool-node.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions zxlive/icons/tikzit-tool-select.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 1 addition & 25 deletions zxlive/icons/undo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 703530f

Please sign in to comment.