Skip to content

Commit 17cbcd9

Browse files
committed
Add new github action that should build the wheel for both archs
1 parent b682fc8 commit 17cbcd9

File tree

1 file changed

+103
-20
lines changed

1 file changed

+103
-20
lines changed

.github/workflows/build_wheel.yaml

Lines changed: 103 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,44 +12,127 @@
1212
#-*
1313
#-*
1414
#Z* -------------------------------------------------------------------
15+
#name: Build Wheel
16+
#
17+
#on: [push]
18+
#
19+
#jobs:
20+
# build:
21+
#
22+
# runs-on: macos-latest
23+
# strategy:
24+
# matrix:
25+
# python-version: ["3.10", "3.11", "3.12"]
26+
#
27+
# steps:
28+
# - uses: actions/checkout@v4
29+
# - name: Set up Python ${{ matrix.python-version }}
30+
# uses: actions/setup-python@v5
31+
# with:
32+
# python-version: ${{ matrix.python-version }}
33+
# # You can test your matrix by printing the current Python version
34+
# - name: Display Python version
35+
# run: python -c "import sys; print(sys.version)"
36+
#
37+
# - name: Install dependencies
38+
# run: |
39+
# /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
40+
# brew install cmake
41+
# python -m venv .venv
42+
# ./.venv/bin/pip install wheel setuptools
43+
# ./.venv/bin/pip install -r requirements.txt
44+
# ./automator.sh setup dev-env
45+
#
46+
# - name: Build wheel
47+
# run: |
48+
# ./automator.sh build so
49+
# ./automator.sh build wheel
50+
#
51+
# - name: Upload artifact
52+
# uses: actions/upload-artifact@v4
53+
# with:
54+
# name: wheel-${{ matrix.python-version }}
55+
# path: dist/*.whl
56+
57+
1558
name: Build Wheel
1659

1760
on: [push]
1861

62+
env:
63+
VCPKG_ROOT: ${{ github.workspace }}/vendor/vcpkg # Match your project structure
64+
VCPKG_TRIPLET: x64-osx # Use arm64-osx for Apple Silicon
65+
1966
jobs:
2067
build:
21-
2268
runs-on: macos-latest
2369
strategy:
2470
matrix:
25-
python-version: ["3.10", "3.11", "3.12"]
26-
71+
arch: [x86_64, arm64]
72+
python-version: ["3.11", "3.12"]
2773
steps:
28-
- uses: actions/checkout@v4
29-
- name: Set up Python ${{ matrix.python-version }}
30-
uses: actions/setup-python@v5
74+
- name: Checkout repository
75+
uses: actions/checkout@v3
3176
with:
32-
python-version: ${{ matrix.python-version }}
33-
# You can test your matrix by printing the current Python version
34-
- name: Display Python version
35-
run: python -c "import sys; print(sys.version)"
77+
submodules: recursive
3678

37-
- name: Install dependencies
79+
- name: Setup Python
80+
uses: actions/setup-python@v4
81+
with:
82+
python-version: ${{ env.PYTHON_VER }}
83+
84+
- name: Create virtual environment
3885
run: |
39-
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
40-
brew install cmake
4186
python -m venv .venv
42-
./.venv/bin/pip install wheel setuptools
43-
./.venv/bin/pip install -r requirements.txt
44-
./automator.sh setup dev-env
87+
source .venv/bin/activate
88+
python -m pip install wheel # Add other build deps if needed
89+
python -m pip install -r requirements.txt
90+
91+
- name: Cache vcpkg
92+
uses: actions/cache@v3
93+
with:
94+
path: |
95+
${{ env.VCPKG_ROOT }}/downloads
96+
${{ env.VCPKG_ROOT }}/packages
97+
${{ env.VCPKG_ROOT }}/installed
98+
key: ${{ runner.os }}-vcpkg-${{ matrix.arch }}-${{ hashFiles('vcpkg.json') }}
99+
restore-keys: |
100+
${{ runner.os }}-vcpkg-${{ matrix.arch }}-
45101
46-
- name: Build wheel
102+
- name: Bootstrap vcpkg
103+
run: ${{ env.VCPKG_ROOT }}/bootstrap-vcpkg.sh -disableMetrics
104+
105+
- name: Install vcpkg dependencies
47106
run: |
48-
./automator.sh build so
49-
./automator.sh build wheel
107+
TRIPLET=$([ "${{ matrix.arch }}" = "arm64" ] && echo "arm64-osx" || echo "x64-osx")
108+
${{ env.VCPKG_ROOT }}/vcpkg install
50109
110+
- name: Build extension
111+
env:
112+
CMAKE_ARGS: >
113+
-DCMAKE_TOOLCHAIN_FILE=./vendor/vcpkg/scripts/buildsystems/vcpkg.cmake
114+
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }}
115+
-DPYTHON_VER=${{ env.PYTHON_VER }}
116+
-DSHARED_SUFFIX=.cpython-311-darwin.so # Update to match Python version
117+
run: |
118+
source .venv/bin/activate
119+
python setup.py build bdist_wheel
120+
# - name: Create universal binary
121+
# if: matrix.arch == 'x86_64' # Run once after both arch builds
122+
# run: |
123+
# lipo -create \
124+
# -output dist/_cmd_universal.so \
125+
# build/lib*/_cmd*.so
126+
# rm build/lib*/_cmd*.so # Clean individual arch builds
127+
# mv dist/_cmd_universal.so build/lib/
128+
#
129+
# - name: Package wheel
130+
# if: matrix.arch == 'x86_64'
131+
# run: |
132+
# source .venv/bin/activate
133+
# python setup.py bdist_wheel
51134
- name: Upload artifact
52135
uses: actions/upload-artifact@v4
53136
with:
54-
name: wheel-${{ matrix.python-version }}
137+
name: pymol-wheel
55138
path: dist/*.whl

0 commit comments

Comments
 (0)