Skip to content

Commit a42f985

Browse files
committed
oxidized-importer: support building on macOS
This required a cargo config file to make the linker happy. We also had to teach setup.py about .dylib files. For convenience, we add a script to build a wheel from macOS. Although I've only tested this on my local machine, not in CI yet. And minor changes to setup.py to find the Rust shared libraryu
1 parent 4cc7827 commit a42f985

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

ci/build-wheel-macos.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
# Script to build macOS binary wheel for oxidized_importer.
3+
4+
set -exo pipefail
5+
6+
export CIBW_BUILD=cp38-macosx_x86_64
7+
8+
python3.8 -m cibuildwheel --output-dir wheelhouse --platform macos

oxidized-importer/.cargo/config

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This is needed to avoid linking errors due to undefined symbols when
2+
# building Python extension modules.
3+
[target.x86_64-apple-darwin]
4+
rustflags = [
5+
"-C", "link-arg=-undefined",
6+
"-C", "link-arg=dynamic_lookup",
7+
]

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ def build(self, build_dir: pathlib.Path, get_ext_path_fn):
5050

5151
if os.name == "nt":
5252
rust_lib_filename = "%s.dll" % self.name
53+
elif sys.platform == "darwin":
54+
rust_lib_filename = "lib%s.dylib" % self.name
5355
else:
5456
rust_lib_filename = "lib%s.so" % self.name
5557

0 commit comments

Comments
 (0)