Skip to content

Commit

Permalink
Allow to specify the architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
vasole committed Nov 24, 2023
1 parent acebb66 commit 9e1d538
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 16 deletions.
11 changes: 11 additions & 0 deletions build-pyinstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@
os.path.join(".", "build-" + sys.platform),
os.path.join(".", "dist-" + sys.platform))

if sys.platform.startswith("darwin"):
if "arm64" in sys.argv:
os.putenv("PYMCA_PYINSTALLER_TARGET_ARCH", "arm64")
elif "universal2" in sys.argv:
os.putenv("PYMCA_PYINSTALLER_TARGET_ARCH", "universal2")
elif "x86_64" in sys.argv:
os.putenv("PYMCA_PYINSTALLER_TARGET_ARCH", "x86_64")
else:
# let PyInstaller choose according to platform
pass

if sys.platform.startswith("win"):
cmd = cmd.replace(";", "&")
result = os.system(cmd)
Expand Down
51 changes: 35 additions & 16 deletions package/pyinstaller/pyinstaller.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- mode: python -*-
import sys
import os.path
import os
from pathlib import Path
import shutil
import subprocess
Expand Down Expand Up @@ -155,21 +155,40 @@ for i in range(len(script_a)):
script_a[i].zipped_data,
cipher=block_cipher))

script_exe.append(
EXE(
script_pyz[i],
script_a[i].scripts,
script_a[i].dependencies,
[],
exclude_binaries=True,
name=script_n[i],
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False,
console=True,
icon=icon)
)
arch = os.getenv("PYMCA_PYINSTALLER_TARGET_ARCH")
if arch:
script_exe.append(
EXE(
script_pyz[i],
script_a[i].scripts,
script_a[i].dependencies,
[],
exclude_binaries=True,
name=script_n[i],
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False,
console=True,
icon=icon,
target_arch=arch)
)
else:
script_exe.append(
EXE(
script_pyz[i],
script_a[i].scripts,
script_a[i].dependencies,
[],
exclude_binaries=True,
name=script_n[i],
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False,
console=True,
icon=icon)
)
script_col.append(
COLLECT(
script_exe[i],
Expand Down

0 comments on commit 9e1d538

Please sign in to comment.