Skip to content

Commit

Permalink
Build wheels for MacOS for X86 and ARM64 (#976)
Browse files Browse the repository at this point in the history
  • Loading branch information
Earammak authored Dec 11, 2024
1 parent e50b975 commit b76a8c0
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 18 deletions.
81 changes: 64 additions & 17 deletions .github/workflows/bld_wheels_and_upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ jobs:
matrix:
os: [windows-latest]
steps:
- uses: actions/checkout@v4.1.1
- uses: actions/checkout@v4.2.2
- name: Build wheels
uses: pypa/cibuildwheel@v2.16.5
uses: pypa/cibuildwheel@v2.22.0
env:
CIBW_BUILD: "*-win_amd64"
CIBW_SKIP: "cp36-* pp*"
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4.4.3
with:
name: wheels_windows64__${{ github.sha }}
path: ./wheelhouse/*.whl

build_wheels_windows_32:
Expand All @@ -36,26 +37,27 @@ jobs:
matrix:
os: [windows-latest]
steps:
- uses: actions/checkout@v4.1.1
- uses: actions/checkout@v4.2.2
- name: Build wheels
uses: pypa/cibuildwheel@v2.16.5
uses: pypa/cibuildwheel@v2.22.0
env:
CIBW_BUILD: "*-win32"
CIBW_SKIP: "cp36-* pp*"
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4.4.3
with:
path: ./wheelhouse/*.whl
build_wheels_macos_linux:
name: wheels_windows32__${{ github.sha }}
path: ./wheelhouse/*.whl

build_wheels_linux:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# macos-13 is an intel runner, macos-14 is apple silicon
os: [macos-13,macos-14,ubuntu-latest]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4.2.2
- name: Build wheels
uses: pypa/cibuildwheel@v2.16.5
uses: pypa/cibuildwheel@v2.22.0
env:
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_SKIP: "cp36-* *-musllinux_* pp* *-*linux_{aarch64,ppc64le}"
Expand All @@ -72,14 +74,60 @@ jobs:
--exclude libdl.so.2
--wheel-dir {dest_dir}
{wheel}
- uses: actions/upload-artifact@v3
- uses: actions/[email protected]
with:
name: wheels_linux__${{ github.sha }}
path: ./wheelhouse/*.whl

build_macos_arm64_wheels:
name: Build wheels on macOS ARM64
runs-on: macos-14
steps:
- uses: actions/[email protected]
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_SKIP: "cp36-*"
- name: Upload wheels
uses: actions/[email protected]
with:
name: wheels_macos_arm64__${{ github.sha }}
path: ./wheelhouse/*.whl

build_wheels_macos_x86:
name: Build wheels for macOS x86_64
runs-on: macos-13

strategy:
matrix:
architecture: [x86_64]

steps:
- uses: actions/[email protected]
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install cibuildwheel # Install cibuildwheel to build the wheels
- name: Set macOS deployment target
run: echo "MACOSX_DEPLOYMENT_TARGET=10.15" >> $GITHUB_ENV

- name: Build wheels with cibuildwheel
run: |
CIBW_ARCHS_MACOS="${{ matrix.architecture }}"
python -m cibuildwheel --platform macos --output-dir ./wheelhouse
- name: Upload wheels as artifacts
uses: actions/[email protected]
with:
name: wheels_macosx86_python313__${{ github.sha }}
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4.2.2
- name: Install Python dependencies
run: python -m pip install --upgrade pip build
- name: Build sdist
Expand All @@ -102,14 +150,14 @@ jobs:
env:
VERSION: ${{ steps.version.outputs.VERSION}}
- name: Upload sdist
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4.4.3
with:
path: |
./dist/*.tar.gz
upload_pypi:
needs: [build_sdist,build_wheels_macos_linux, build_wheels_windows_64,build_wheels_windows_32]
needs: [build_sdist,build_wheels_linux, build_wheels_windows_64,build_wheels_windows_32, build_macos_arm64_wheels, build_wheels_macos_x86]
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -129,4 +177,3 @@ jobs:
- name: Publish distribution to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1

24 changes: 24 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ DEALINGS IN THE SOFTWARE.
1. [ibm_db Installation on Linux, AIX, zLinux, Widnows and MacOS.](#inslnx)
2. [ibm_db Installation on z/OS](#inszos)
3. [ibm_db installation on MacOS M1/M2 Chip System](#m1chip)
4. [Troubleshooting Post Install Errors on MacOS](#troubleshooting)
[SQL30081N Error](#sql30081n)
[Symbol not found error or malloc error](#symbolerror)

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

Expand Down Expand Up @@ -328,6 +331,27 @@ print('ODBC Test end')
### Installation:
Follow same steps as documented for [ibm_db Installation on Linux, AIX, zLinux, Widnows and MacOS.](#inslnx)
## <a name="troubleshooting"></a> 4. Troubleshooting Post Install Errors on MacOS
<a name="sql30081n"></a> 4.1 SQL30081N Error
* If connection fails with SQL30081N error: means `ibm_db` installation is correct and you need to provide correct connection string.
<a name="symbolerror"></a> 4.2 Symbol not found error or malloc error
* If `import ibm_db` fails with `Symbol not found: ___cxa_throw_bad_array_new_length` error or `malloc` error:
You need to find the correct location of lib/gcc/12 directory and add it to DYLD_LIBRARY_PATH environment variable.
Also, execute below commands from terminal with correct location of `lib/gcc/12/libstdc++.6.dylib` library.
```
cd ..../site_packages/clidriverd/lib
install_name_tool -change /usr/local/lib/gcc/8/libstdc++.6.dylib <full path of libstdc++.6.dylib> libdb2.dylib
f.e.
install_name_tool -change /usr/local/lib/gcc/8/libstdc++.6.dylib /usr/local/homebrew/lib/gcc/12/libstdc++.6.dylib libdb2.dylib
```
* 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:
```
cd .../lib/python3.11/site-packages/clidriver/lib
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
```
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`
Now run your test program and verify.
# M1 MAC Steps to Install IBM DB and Support Docker RUN
## Installation Steps:
### Install Podman / Docker:
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[tool.cibuildwheel.macos]
[tool.cibuildwheel.macos]
repair-wheel-command = "delocate-wheel --ignore-missing-dependencies --require-archs {delocate_archs} -w {dest_dir} -v {wheel}"
skip = "cp36-macosx_x86_64"

0 comments on commit b76a8c0

Please sign in to comment.