Skip to content

Commit

Permalink
Bundle macOS into windowed app.
Browse files Browse the repository at this point in the history
    + Added version.txt with git hash
  • Loading branch information
doizuc committed Nov 13, 2023
1 parent 9703b0c commit 40a7782
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
Binary file added Data/Img/logo.icns
Binary file not shown.
4 changes: 2 additions & 2 deletions README_bundle.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ On macOS, bundled application are not signed, hence macOS Gatekeeper will raise

cd HyperCP-v1.2.0-Darwin
sudo xattr -r -d com.apple.quarantine HyperCP-v1.2.0-Darwin
sudo xattr -r -d com.apple.quarantine _internal/**/*.dylib
sudo xattr -r -d com.apple.quarantine _internal/**/*.so
sudo xattr -r -d com.apple.quarantine **/*.dylib
sudo xattr -r -d com.apple.quarantine **/*.so

Another workaround (not recommended) is to disable macOS Gatekeeper only during the time HyperCP is used.

Expand Down
26 changes: 24 additions & 2 deletions make.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import re
import glob
import platform
import subprocess

import PyInstaller.__main__

Expand All @@ -15,9 +16,14 @@
add_data_sep = ':'
if platform.system() == 'Darwin':
os_specific_options = [
# f'--icon={os.path.relpath(os.path.join("Data", "Img", "logo.icns"), root)}',
f'--icon={os.path.relpath(os.path.join("Data", "Img", "logo.icns"), root)}',
'--windowed',
'--target-arch=universal2',
# Required for code signing
'--osx-bundle-identifier=com.nasa.hypercp.hypercp',
# '--target-arch=universal2',
# f'--codesign-identity={os.getenv("CODESIGN_HASH")}',
# f'--osx-entitlements-file={os.path.join("Bundled", "entitlements.plist")}',

]
elif platform.system() == 'Windows':
os_specific_options = [
Expand All @@ -37,8 +43,24 @@
version = l.split('=')[1].strip(" \n'")
break

# Get git hash (without git package)
try:
__git_hash__ = subprocess.check_output(['git', 'rev-parse', 'HEAD'], #'--short',
cwd=os.path.dirname(os.path.abspath(__file__))).decode('ascii').strip()
except (subprocess.SubprocessError, FileNotFoundError):
__git_hash__ = 'git_na'

# Update version.txt file
if os.path.exists('version.txt'):
os.remove('version.txt')
with open('version.txt', 'w') as f:
f.write(f"version={version}\n")
f.write(f"git_hash={__git_hash__}\n")
f.close()

# Include all Data files (except Zhang table)
linked_data = [
f'--add-data={os.path.relpath("version.txt", root)}{add_data_sep}.',
f'--add-data={os.path.relpath("Config", root)}{add_data_sep}Config',
f'--add-data={os.path.relpath(".ecmwf_api_config", root)}{add_data_sep}.',
]
Expand Down

0 comments on commit 40a7782

Please sign in to comment.