Skip to content

Commit 9df905c

Browse files
committed
Merge #21: [Build] Update build requirements
a5374f3 Update .gitignore (Fuzzbawls) 031ef52 [Build] Add/update deployment capabilities (Fuzzbawls) 4ae2624 [Build] Update requirements (Fuzzbawls) Pull request description: Same updates that happened for SPMT rolled up into a single PR here. Note: this only focusing on the build/deploy areas. ACKs for top commit: Liquid369: ACK a5374f3 Tree-SHA512: 41130281da64e29467092294880bc478f8f9d8020eb39f1bbf86d8b7de1823dbee93288da7dca5f01ad967076e8dcbcada292fb3a4d515592c42b4952e890ad8
2 parents da4284c + a5374f3 commit 9df905c

File tree

7 files changed

+196
-46
lines changed

7 files changed

+196
-46
lines changed

.github/workflows/main.yaml

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@ jobs:
1010
shell: bash
1111
steps:
1212
- name: Checkout Repo
13-
uses: actions/checkout@v3
13+
uses: actions/checkout@v4
1414
with:
1515
fetch-depth: 0
1616

1717
- name: Initialize Python
18-
uses: actions/setup-python@v4
18+
uses: actions/setup-python@v5
1919
with:
20-
python-version: 3.7
20+
python-version: '3.10'
2121

2222
- name: Install Dependencies
2323
run: |
24-
python -m pip install --upgrade wheel
24+
pip install pip==24.0
25+
pip install wheel==0.35.0
26+
pip install setuptools==53.0.0
2527
pip install -r requirements.txt
2628
pip install importlib-metadata==4.13.0
2729
pip install flake8==3.8.4
@@ -51,7 +53,7 @@ jobs:
5153
packages: libusb-1.0-0-dev libudev-dev
5254

5355
- name: macOS
54-
os: macos-11
56+
os: macos-12
5557
cachepath: ~/Library/Caches/pip
5658

5759
- name: Windows
@@ -60,13 +62,13 @@ jobs:
6062

6163
steps:
6264
- name: Get Source
63-
uses: actions/checkout@v3
64-
- name: Setup Python 3.7
65-
uses: actions/setup-python@v4
65+
uses: actions/checkout@v4
66+
- name: Setup Python 3.10
67+
uses: actions/setup-python@v5
6668
with:
67-
python-version: 3.7
69+
python-version: '3.10'
6870
- name: Setup pip cache
69-
uses: actions/cache@v3
71+
uses: actions/cache@v4
7072
with:
7173
path: ${{ matrix.config.cachepath }}
7274
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
@@ -78,7 +80,13 @@ jobs:
7880
sudo apt-get update
7981
sudo apt-get install --no-install-recommends --no-upgrade -qq ${{ matrix.config.packages }}
8082
fi
81-
python -m pip install --upgrade wheel
83+
if [[ ${{ matrix.config.os }} = windows* ]]; then
84+
python.exe -m pip install pip==24.0
85+
else
86+
pip install pip==24.0
87+
fi
88+
pip install wheel==0.35.0
89+
pip install setuptools==53.0.0
8290
pip install -r requirements.txt
8391
pip install pyinstaller
8492
- name: Build

.gitignore

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1+
# IDE artifacts
12
/.project
23
/.pydevproject
3-
/.settings/
4-
*.json
4+
/.pytest_cache/
55
/.idea/
6+
/.settings/
7+
/__pycache__/
8+
9+
# Virtual environments
10+
/venv*/
11+
12+
# Build artifacts
613
/build/
714
/dist/
8-
/__pycache__/
9-
/venv/
10-
/.pytest_cache/
15+
/PET4L*/
16+
17+
# Deployment artifacts
18+
/*.exe
19+
/*.tar.gz
20+
/*.dmg
21+
/*.zip
22+
/*.app

contrib/macdeploy/appdmg.json.in

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"title": "PET4L %version%",
3+
"icon": "../img/spmt.icns",
4+
"icon-size": 96,
5+
"background": "background.tiff",
6+
"contents": [
7+
{ "x": 370, "y": 156, "type": "link", "path": "/Applications" },
8+
{ "x": 128, "y": 156, "type": "file", "path": "pet4l.app" }
9+
],
10+
"code-sign": {
11+
"signing-identity": "%signer%"
12+
}
13+
}

contrib/macdeploy/background.svg

Lines changed: 34 additions & 0 deletions
Loading
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
6+
<true/>
7+
<key>com.apple.security.cs.disable-library-validation</key>
8+
<true/>
9+
<key>com.apple.security.automation.apple-events</key>
10+
<true/>
11+
<key>com.apple.security.cs.allow-jit</key>
12+
<true/>
13+
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
14+
<true/>
15+
<key>com.apple.security.device.camera</key>
16+
<true/>
17+
</dict>
18+
</plist>

requirements.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
wheel==0.35.0
2+
setuptools==53.0.0
13
python-bitcoinrpc==1.0
24
bitcoin==1.1.42
35
btchip-python==0.1.27
4-
trezor==0.11.3
5-
PyQt5>=5.9,<5.14.1
6-
requests>=2.18.4,<=2.23
7-
simplejson<=3.13.2
8-
ecdsa==0.13.3
6+
trezor==0.11.5
7+
PyQt5>=5.15.10
8+
requests==2.32.2
9+
simplejson==3.19.2
10+
ecdsa==0.19.0

specPet4l.spec

Lines changed: 88 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# -*- mode: python -*-
22
import sys
3+
import platform
34
import os.path as os_path
5+
import shutil
46
import simplejson as json
7+
import subprocess
58

69
os_type = sys.platform
710
block_cipher = None
@@ -11,9 +14,31 @@ def libModule(module, source, dest):
1114
m = __import__(module)
1215
module_path = os_path.dirname(m.__file__)
1316
del m
14-
print("libModule %s" % str(( os_path.join(module_path, source), dest )))
17+
print(f"libModule {(os.path.join(module_path, source), dest)}")
1518
return ( os_path.join(module_path, source), dest )
1619

20+
def is_tool(prog):
21+
for dir in os.environ['PATH'].split(os.pathsep):
22+
if os.path.exists(os.path.join(dir, prog)):
23+
try:
24+
subprocess.call([os.path.join(dir, prog)],
25+
stdout=subprocess.PIPE,
26+
stderr=subprocess.STDOUT)
27+
except(OSError, e):
28+
return False
29+
return True
30+
return False
31+
32+
# Set this to True if codesigning macOS bundles. Requires an Apple issued developer ID certificate.
33+
code_sign = False
34+
codesigner = 'fuzzbawls@pivx.org'
35+
36+
# detect CPU architecture
37+
cpu_arch = platform.processor()
38+
if os_type == 'darwin':
39+
if cpu_arch == 'arm': cpu_arch = 'arm64'
40+
if cpu_arch == 'i386': cpu_arch = 'x86_64'
41+
1742
# look for version string
1843
version_str = ''
1944
with open(os_path.join(base_dir, 'src', 'version.txt')) as version_file:
@@ -88,14 +113,23 @@ exe = EXE(pyz,
88113
strip=False,
89114
upx=False,
90115
console=False,
91-
icon=os_path.join(base_dir, 'img', 'spmt.%s' % ('icns' if os_type=='darwin' else 'ico')) )
116+
target_arch=f'{cpu_arch}',
117+
entitlements_file='contrib/macdeploy/entitlements.plist',
118+
codesign_identity=f'{codesigner if code_sign == True else ""}',
119+
icon = os_path.join(base_dir, 'img', f'spmt.{"icns" if os_type == "darwin" else "ico"}'))
92120

93121
if os_type == 'darwin':
94122
app = BUNDLE(exe,
95123
name='pet4l.app',
96124
icon=os_path.join(base_dir, 'img', 'spmt.icns'),
97-
bundle_identifier=None,
98-
info_plist={'NSHighResolutionCapable': 'True'})
125+
bundle_identifier='io.pivx.pet4l',
126+
info_plist={
127+
'NSHighResolutionCapable': 'True',
128+
'CFBundleVersion': version_str,
129+
'CFBundleShortVersionString': version_str,
130+
'NSPrincipalClass': 'NSApplication',
131+
'LSApplicationCategoryType': 'public.app-category.finance'
132+
})
99133

100134

101135
# Prepare bundles
@@ -104,37 +138,66 @@ app_path = os_path.join(dist_path, 'app')
104138
os.chdir(dist_path)
105139

106140
if os_type == 'win32':
107-
os.chdir(base_dir)
108-
# Rename dist Dir
109-
dist_path_win = os_path.join(base_dir, 'PET4L-v' + version_str + '-Win64')
110-
os.rename(dist_path, dist_path_win)
111-
# Create NSIS compressed installer
112-
print('Creating Windows installer (requires NSIS)')
113-
os.system('\"c:\\program files (x86)\\NSIS\\makensis.exe\" %s' % os.path.join(base_dir, 'setup.nsi'))
141+
os.chdir(base_dir)
142+
# Rename dist Dir
143+
dist_path_win = os_path.join(base_dir, f'PET4L-v{version_str}-Win64')
144+
if os_path.exists(dist_path_win):
145+
shutil.rmtree(dist_path_win)
146+
os.rename(dist_path, dist_path_win)
147+
# Check for NSIS
148+
prog_path = os.environ["ProgramFiles(x86)"]
149+
nsis_bin = os_path.join(prog_path, "NSIS", "makensis.exe")
150+
if os_path.exists(nsis_bin):
151+
# Create NSIS compressed installer
152+
print('Creating Windows installer')
153+
os.system(f'"{nsis_bin}" {os_path.join(base_dir, "setup.nsi")}')
154+
else:
155+
print('NSIS not found, cannot build windows installer.')
114156

115157
if os_type == 'linux':
116-
os.chdir(base_dir)
117-
# Rename dist Dir
118-
dist_path_linux = os_path.join(base_dir, 'PET4L-v' + version_str + '-gnu_linux')
119-
os.rename(dist_path, dist_path_linux)
120-
# Compress dist Dir
121-
print('Compressing Linux App Folder')
122-
os.system('tar -zcvf %s -C %s %s' % ('PET4L-v' + version_str + '-x86_64-gnu_linux.tar.gz',
123-
base_dir, 'PET4L-v' + version_str + '-gnu_linux'))
158+
os.chdir(base_dir)
159+
# Rename dist Dir
160+
dist_path_linux = os_path.join(base_dir, f'PET4L-v{version_str}-{cpu_arch}-gnu_linux')
161+
if os_path.exists(dist_path_linux):
162+
shutil.rmtree(dist_path_linux)
163+
os.rename(dist_path, dist_path_linux)
164+
# Compress dist Dir
165+
print('Compressing Linux App Folder')
166+
os.system(f'tar -zcvf PET4L-v{version_str}-{cpu_arch}-gnu_linux.tar.gz -C {base_dir} PET4L-v{version_str}-{cpu_arch}-gnu_linux')
124167

125168
if os_type == 'darwin':
126169
os.chdir(base_dir)
127170
# Rename dist Dir
128-
dist_path_mac = os_path.join(base_dir, 'PET4L-v' + version_str + '-MacOSX')
171+
dist_path_mac = os_path.join(base_dir, f'PET4L-v{version_str}-{cpu_arch}-MacOS')
172+
if os_path.exists(dist_path_mac):
173+
shutil.rmtree(dist_path_mac)
129174
os.rename(dist_path, dist_path_mac)
130175
# Remove 'app' folder
131-
print("Removin 'app' folder")
176+
print("Removing 'app' folder")
132177
os.chdir(dist_path_mac)
133178
os.system('rm -rf app')
134179
os.chdir(base_dir)
135180
# Compress dist Dir
136181
print('Compressing Mac App Folder')
137-
os.system('tar -zcvf %s -C %s %s' % ('PET4L-v' + version_str + '-MacOSX.tar.gz',
138-
base_dir, 'PET4L-v' + version_str + '-MacOSX'))
139-
140-
182+
os.system(f'tar -zcvf PET4L-v{version_str}-{cpu_arch}-MacOS.tar.gz -C {base_dir} PET4L-v{version_str}-{cpu_arch}-MacOS')
183+
184+
# dmg image creation uses the node.js appdmg package
185+
if is_tool("appdmg"):
186+
# Prepare dmg
187+
print("Preparing distribution dmg installer")
188+
os.chdir(dist_path_mac)
189+
with open(os_path.join(base_dir, 'contrib/macdeploy', 'appdmg.json.in')) as conf:
190+
confdata = conf.read()
191+
confdata = confdata.replace('%version%', version_str)
192+
confdata = confdata.replace('%signer%', f'{codesigner if code_sign == True else ""}')
193+
with open('appdmg.json', 'w') as newconf:
194+
newconf.write(confdata)
195+
196+
os.system(f'sed \"s/PACKAGE_NAME/PET4L {version_str}/\" < \"../contrib/macdeploy/background.svg\" | rsvg-convert -f png -d 72 -p 72 | convert - background.tiff@2x.png')
197+
os.system('convert background.tiff@2x.png -resize 500x320 background.tiff.png')
198+
os.system('tiffutil -cathidpicheck background.tiff.png background.tiff@2x.png -out background.tiff')
199+
os.remove('background.tiff.png')
200+
os.system(f'appdmg appdmg.json ../PET4L-v{version_str}-{cpu_arch}-MacOS.dmg')
201+
os.remove('background.tiff@2x.png')
202+
else:
203+
print("appdmg not found, skipping DMG creation")

0 commit comments

Comments
 (0)