Skip to content

Commit 166b4da

Browse files
committed
Merge branch 'master' of https://github.com/shdwmtr/pybuilder
2 parents 0c971c6 + 83da638 commit 166b4da

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

.github/workflows/osx.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Build ARM64 Python on macOS
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build:
8+
runs-on: macos-latest
9+
steps:
10+
- name: Set up Rosetta 2
11+
run: |
12+
softwareupdate --install-rosetta --agree-to-license || true
13+
14+
- name: Download Python 3.11.8 Source
15+
run: |
16+
curl -O https://www.python.org/ftp/python/3.11.8/Python-3.11.8.tgz
17+
tar -xf Python-3.11.8.tgz
18+
cd Python-3.11.8
19+
20+
- name: Build Python 3.11.8 for ARM64
21+
run: |
22+
cd Python-3.11.8
23+
arch -arm64 ./configure --prefix=/tmp/python-build --enable-optimizations
24+
arch -arm64 make -j$(sysctl -n hw.ncpu)
25+
arch -arm64 make install
26+
27+
sudo mkdir -p /tmp/python-build/lib/tmp
28+
cd /tmp/python-build/lib/tmp
29+
sudo ar -x ../libpython3.11.a
30+
sudo gcc -m32 -shared -o ../libpython-3.11.8.dylib *.o -arch arm64
31+
32+
cd /tmp/python-build/lib
33+
sudo rm -rf tmp
34+
ls
35+
36+
# Remove unimportant files that take up lots of space
37+
sudo rm -rf /tmp/python-build/lib/python3.11/test/
38+
sudo rm -rf /tmp/python-build/lib/python3.11/__pycache__/
39+
sudo rm -rf /tmp/python-build/lib/python3.11/config-3.11-darwin/
40+
sudo rm -rf /tmp/python-build/lib/python3.11/tkinter/
41+
sudo rm -rf /tmp/python-build/lib/python3.11/idlelib/
42+
sudo rm -rf /tmp/python-build/lib/python3.11/turtledemo/
43+
44+
# Remove the static library as we've built a shared library
45+
sudo rm /tmp/python-build/lib/libpython3.11.a
46+
47+
# Strip the build binaries to reduce size
48+
sudo strip /tmp/python-build/bin/python3.11
49+
sudo strip /tmp/python-build/lib/libpython-3.11.8.dylib
50+
51+
# Remove extra bin files that are not needed
52+
sudo rm /tmp/python-build/bin/python3.11-config
53+
sudo rm /tmp/python-build/bin/idle3.11
54+
sudo rm /tmp/python-build/bin/pydoc3.11
55+
sudo rm /tmp/python-build/bin/pip3.11
56+
sudo rm /tmp/python-build/bin/2to3-3.11
57+
58+
- name: Verify Build
59+
run: |
60+
/tmp/python-build/bin/python3 --version
61+
/tmp/python-build/bin/python3 -c "import platform; print(platform.machine())"
62+
file $HOME/python-arm64/bin/python3
63+
64+
- name: Upload Python Artifact
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: python-arm64-macos
68+
path: /tmp/python-build/
69+
include-hidden-files: 'true'

0 commit comments

Comments
 (0)