Skip to content

Commit

Permalink
build macos arm64 wheels
Browse files Browse the repository at this point in the history
  • Loading branch information
Luiz Irber committed Apr 8, 2022
1 parent a998a6a commit bd23914
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
1 change: 1 addition & 0 deletions .ci/install_cargo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable
export PATH="$HOME/.cargo/bin:$PATH"
rustc -V
rustup target add aarch64-apple-darwin
12 changes: 6 additions & 6 deletions .github/workflows/build_wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
linux-ppc64le,
linux-s390x,
macos-x86_64,
macos-arm64,
]
include:
- build: linux-x86_64
Expand All @@ -41,7 +42,11 @@ jobs:
- build: macos-x86_64
os: macos-latest
arch: x86_64
macos_target: 'MACOSX_DEPLOYMENT_TARGET=10.11'
macos_target: 'MACOSX_DEPLOYMENT_TARGET=10.11 CARGO_BUILD_TARGET=x86_64-apple-darwin'
- build: macos-arm64
os: macos-latest
arch: arm64
macos_target: 'MACOSX_DEPLOYMENT_TARGET=11 CARGO_BUILD_TARGET=aarch64-apple-darwin'
fail-fast: false

steps:
Expand All @@ -63,12 +68,7 @@ jobs:
- name: Build wheels
uses: pypa/cibuildwheel@v2.2.2
env:
CIBW_BUILD: "cp39-*"
CIBW_SKIP: "*-win32 *-manylinux_i686 *-musllinux_ppc64le *-musllinux_s390x"
CIBW_BEFORE_BUILD: 'source .ci/install_cargo.sh'
CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH"'
CIBW_ENVIRONMENT_MACOS: ${{ matrix.macos_target }}
CIBW_BUILD_VERBOSITY: 3
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
CIBW_ARCHS_MACOS: ${{ matrix.arch }}

Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ include_trailing_comma = true
force_grid_wrap = 0
line_length = 88
known_first_party = ["sourmash"]

[tool.cibuildwheel]
build = "cp39-*"
skip = "*-win32 *-manylinux_i686 *-musllinux_ppc64le *-musllinux_s390x"
before-build = "source .ci/install_cargo.sh"
environment = { PATH="$HOME/.cargo/bin:$PATH" }
build-verbosity = 3
13 changes: 11 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
NO_BUILD = os.environ.get("NO_BUILD") == "1"


def find_dylib(name, paths):
def find_dylib_no_build(name, paths):
to_find = None
if sys.platform == 'darwin':
to_find = f'lib{name}.dylib'
Expand All @@ -25,6 +25,15 @@ def find_dylib(name, paths):
raise LookupError('dylib %r not found' % name)


def find_dylib(build, target):
cargo_target = os.environ.get("CARGO_BUILD_TARGET")
if cargo_target:
in_path = "target/%s/%s" % (cargo_target, target)
else:
in_path = "target/%s" % target
return build.find_dylib("sourmash", in_path=in_path)


def build_native(spec):
cmd = ["cargo", "build",
"--manifest-path", "src/core/Cargo.toml",
Expand All @@ -41,7 +50,7 @@ def build_native(spec):
header_filename = lambda: "include/sourmash.h"
else:
build = spec.add_external_build(cmd=cmd, path=".")
dylib=lambda: build.find_dylib("sourmash", in_path="target/%s" % target)
dylib = lambda: find_dylib(build, target)
header_filename=lambda: build.find_header("sourmash.h", in_path="include")

rtld_flags = ["NOW"]
Expand Down

0 comments on commit bd23914

Please sign in to comment.