Skip to content

Commit b76a8c0

Browse files
authored
Build wheels for MacOS for X86 and ARM64 (#976)
1 parent e50b975 commit b76a8c0

File tree

3 files changed

+90
-18
lines changed

3 files changed

+90
-18
lines changed

.github/workflows/bld_wheels_and_upload.yml

Lines changed: 64 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ jobs:
1919
matrix:
2020
os: [windows-latest]
2121
steps:
22-
- uses: actions/checkout@v4.1.1
22+
- uses: actions/checkout@v4.2.2
2323
- name: Build wheels
24-
uses: pypa/cibuildwheel@v2.16.5
24+
uses: pypa/cibuildwheel@v2.22.0
2525
env:
2626
CIBW_BUILD: "*-win_amd64"
2727
CIBW_SKIP: "cp36-* pp*"
28-
- uses: actions/upload-artifact@v3
28+
- uses: actions/upload-artifact@v4.4.3
2929
with:
30+
name: wheels_windows64__${{ github.sha }}
3031
path: ./wheelhouse/*.whl
3132

3233
build_wheels_windows_32:
@@ -36,26 +37,27 @@ jobs:
3637
matrix:
3738
os: [windows-latest]
3839
steps:
39-
- uses: actions/checkout@v4.1.1
40+
- uses: actions/checkout@v4.2.2
4041
- name: Build wheels
41-
uses: pypa/cibuildwheel@v2.16.5
42+
uses: pypa/cibuildwheel@v2.22.0
4243
env:
4344
CIBW_BUILD: "*-win32"
4445
CIBW_SKIP: "cp36-* pp*"
45-
- uses: actions/upload-artifact@v3
46+
- uses: actions/upload-artifact@v4.4.3
4647
with:
47-
path: ./wheelhouse/*.whl
48-
build_wheels_macos_linux:
48+
name: wheels_windows32__${{ github.sha }}
49+
path: ./wheelhouse/*.whl
50+
51+
build_wheels_linux:
4952
name: Build wheels on ${{ matrix.os }}
5053
runs-on: ${{ matrix.os }}
5154
strategy:
5255
matrix:
53-
# macos-13 is an intel runner, macos-14 is apple silicon
54-
os: [macos-13,macos-14,ubuntu-latest]
56+
os: [ubuntu-latest]
5557
steps:
56-
- uses: actions/checkout@v3
58+
- uses: actions/checkout@v4.2.2
5759
- name: Build wheels
58-
uses: pypa/cibuildwheel@v2.16.5
60+
uses: pypa/cibuildwheel@v2.22.0
5961
env:
6062
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
6163
CIBW_SKIP: "cp36-* *-musllinux_* pp* *-*linux_{aarch64,ppc64le}"
@@ -72,14 +74,60 @@ jobs:
7274
--exclude libdl.so.2
7375
--wheel-dir {dest_dir}
7476
{wheel}
75-
- uses: actions/upload-artifact@v3
77+
- uses: actions/upload-artifact@v4.4.3
78+
with:
79+
name: wheels_linux__${{ github.sha }}
80+
path: ./wheelhouse/*.whl
81+
82+
build_macos_arm64_wheels:
83+
name: Build wheels on macOS ARM64
84+
runs-on: macos-14
85+
steps:
86+
- uses: actions/checkout@v4.2.2
87+
- name: Build wheels
88+
uses: pypa/cibuildwheel@v2.22.0
89+
env:
90+
CIBW_SKIP: "cp36-*"
91+
- name: Upload wheels
92+
uses: actions/upload-artifact@v4.4.3
7693
with:
94+
name: wheels_macos_arm64__${{ github.sha }}
7795
path: ./wheelhouse/*.whl
96+
97+
build_wheels_macos_x86:
98+
name: Build wheels for macOS x86_64
99+
runs-on: macos-13
100+
101+
strategy:
102+
matrix:
103+
architecture: [x86_64]
104+
105+
steps:
106+
- uses: actions/checkout@v4.2.2
107+
- name: Install dependencies
108+
run: |
109+
python -m pip install --upgrade pip
110+
pip install cibuildwheel # Install cibuildwheel to build the wheels
111+
112+
- name: Set macOS deployment target
113+
run: echo "MACOSX_DEPLOYMENT_TARGET=10.15" >> $GITHUB_ENV
114+
115+
- name: Build wheels with cibuildwheel
116+
run: |
117+
CIBW_ARCHS_MACOS="${{ matrix.architecture }}"
118+
python -m cibuildwheel --platform macos --output-dir ./wheelhouse
119+
120+
- name: Upload wheels as artifacts
121+
uses: actions/upload-artifact@v4.4.3
122+
with:
123+
name: wheels_macosx86_python313__${{ github.sha }}
124+
path: ./wheelhouse/*.whl
125+
78126
build_sdist:
79127
name: Build source distribution
80128
runs-on: ubuntu-latest
81129
steps:
82-
- uses: actions/checkout@v3
130+
- uses: actions/checkout@v4.2.2
83131
- name: Install Python dependencies
84132
run: python -m pip install --upgrade pip build
85133
- name: Build sdist
@@ -102,14 +150,14 @@ jobs:
102150
env:
103151
VERSION: ${{ steps.version.outputs.VERSION}}
104152
- name: Upload sdist
105-
uses: actions/upload-artifact@v3
153+
uses: actions/upload-artifact@v4.4.3
106154
with:
107155
path: |
108156
./dist/*.tar.gz
109157
110158
111159
upload_pypi:
112-
needs: [build_sdist,build_wheels_macos_linux, build_wheels_windows_64,build_wheels_windows_32]
160+
needs: [build_sdist,build_wheels_linux, build_wheels_windows_64,build_wheels_windows_32, build_macos_arm64_wheels, build_wheels_macos_x86]
113161
runs-on: ${{ matrix.os }}
114162
strategy:
115163
matrix:
@@ -129,4 +177,3 @@ jobs:
129177
- name: Publish distribution to PyPI
130178
if: startsWith(github.ref, 'refs/tags')
131179
uses: pypa/gh-action-pypi-publish@release/v1
132-

INSTALL.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ DEALINGS IN THE SOFTWARE.
2424
1. [ibm_db Installation on Linux, AIX, zLinux, Widnows and MacOS.](#inslnx)
2525
2. [ibm_db Installation on z/OS](#inszos)
2626
3. [ibm_db installation on MacOS M1/M2 Chip System](#m1chip)
27+
4. [Troubleshooting Post Install Errors on MacOS](#troubleshooting)
28+
[SQL30081N Error](#sql30081n)
29+
[Symbol not found error or malloc error](#symbolerror)
2730

2831
## <a name="inslnx"></a> 1. Python-ibm_db Installation on Linux, AIX, zLinux, Windows and MacOS.
2932

@@ -328,6 +331,27 @@ print('ODBC Test end')
328331
### Installation:
329332
Follow same steps as documented for [ibm_db Installation on Linux, AIX, zLinux, Widnows and MacOS.](#inslnx)
330333
334+
## <a name="troubleshooting"></a> 4. Troubleshooting Post Install Errors on MacOS
335+
<a name="sql30081n"></a> 4.1 SQL30081N Error
336+
* If connection fails with SQL30081N error: means `ibm_db` installation is correct and you need to provide correct connection string.
337+
<a name="symbolerror"></a> 4.2 Symbol not found error or malloc error
338+
* If `import ibm_db` fails with `Symbol not found: ___cxa_throw_bad_array_new_length` error or `malloc` error:
339+
You need to find the correct location of lib/gcc/12 directory and add it to DYLD_LIBRARY_PATH environment variable.
340+
Also, execute below commands from terminal with correct location of `lib/gcc/12/libstdc++.6.dylib` library.
341+
```
342+
cd ..../site_packages/clidriverd/lib
343+
install_name_tool -change /usr/local/lib/gcc/8/libstdc++.6.dylib <full path of libstdc++.6.dylib> libdb2.dylib
344+
f.e.
345+
install_name_tool -change /usr/local/lib/gcc/8/libstdc++.6.dylib /usr/local/homebrew/lib/gcc/12/libstdc++.6.dylib libdb2.dylib
346+
```
347+
* Suppose, you have installed gcc v13.1.0 and libstdc++ is available under `/usr/local/Homebrew/Cellar/gcc/13.1.0/lib/gcc/13`, then you need to run below two commands from terminal to fix this issue:
348+
```
349+
cd .../lib/python3.11/site-packages/clidriver/lib
350+
install_name_tool -change /usr/local/lib/gcc/8/libstdc++.6.dylib /usr/local/Homebrew/Cellar/gcc/13.1.0/lib/gcc/13/libstdc++.6.dylib libdb2.dylib
351+
```
352+
i.e. change current path of `libstdc++.6.dylib` in `libdb2.dylib` library to the corrent path in your system. You can find the path of `libstdc++.6.dylib` in libdb2.dylib using the command : `otool -L libdb2.dylib`. Once you have the path of libstdc++.6.dylib, you need to change it using the commond: `install_name_tool -change <current path in libdb2.dylib> <actual path in your system> libdb2.dylib`
353+
Now run your test program and verify.
354+
331355
# M1 MAC Steps to Install IBM DB and Support Docker RUN
332356
## Installation Steps:
333357
### Install Podman / Docker:

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[build-system]
22
requires = ["setuptools"]
33
build-backend = "setuptools.build_meta"
4-
[tool.cibuildwheel.macos]
4+
[tool.cibuildwheel.macos]
55
repair-wheel-command = "delocate-wheel --ignore-missing-dependencies --require-archs {delocate_archs} -w {dest_dir} -v {wheel}"
6+
skip = "cp36-macosx_x86_64"

0 commit comments

Comments
 (0)