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