Skip to content

Commit 0ad21f7

Browse files
Build for Linux AArch64 and other miscellaneous cleanups (#710)
* Bump minimum macOS version to 10.13 * Add `ubuntu-22.04-arm` image to CI * Fix a typo * Install Zarr 3, now that it is available * Allow compilation on Linux AArch64 * Don't check for SSE2/AVX2 for AArch64 * Bump to `[email protected]` Suggested-by: <[email protected]> * Add a CHANGELOG entry * Add `extra_link_args` for pthreads * Drop redundant `get_arch_specific_objects` Co-Authored-By: David Stansby <[email protected]> * Add note for macOS compatibility --------- Co-authored-by: David Stansby <[email protected]>
1 parent a2bdbe5 commit 0ad21f7

File tree

5 files changed

+38
-14
lines changed

5 files changed

+38
-14
lines changed

.github/workflows/ci.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
python-version: ["3.11", "3.12", "3.13"]
16-
# macos-13 is an intel runner, macos-14 is a arm64 runner
17-
platform: [ubuntu-latest, windows-latest, macos-13, macos-14]
16+
# macos-13 is an intel runner, macos-14 is an arm64 runner
17+
platform: [ubuntu-latest, ubuntu-22.04-arm, windows-latest, macos-13, macos-14]
1818

1919
defaults:
2020
run:
@@ -28,7 +28,7 @@ jobs:
2828
fetch-depth: 0 # required for version resolution
2929

3030
- name: Set up Conda
31-
uses: conda-incubator/[email protected].0
31+
uses: conda-incubator/[email protected].1
3232
with:
3333
channels: conda-forge
3434
miniforge-version: latest
@@ -56,8 +56,7 @@ jobs:
5656
# Since zarr v3 requires numpy >= 1.25, on Python 3.11 leave it out
5757
# so we can have some tests of our minimum version of numpy (1.24)
5858
if: matrix.python-version != '3.11'
59-
# TODO: remove --pre option when zarr v3 is out
60-
run: python -m pip install --pre zarr>=3.0.0b2
59+
run: python -m pip install zarr>=3
6160

6261
- name: List installed packages
6362
run: python -m pip list

.github/workflows/wheel.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
# macos-13 is an intel runner, macos-14 is a arm64 runner
17-
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
16+
# macos-13 is an intel runner, macos-14 is an arm64 runner
17+
os: [ubuntu-latest, ubuntu-22.04-arm, windows-latest, macos-13, macos-14]
1818
env:
1919
CIBW_TEST_COMMAND: python -c "import numcodecs"
2020
CIBW_BUILD: "cp311-* cp312-* cp313-*"

docs/release.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ Release notes
1717
Unreleased
1818
----------
1919

20+
Enhancements
21+
~~~~~~~~~~~~
22+
23+
* Add support for the Linux AArch64 architecture, and bump the minimum
24+
macOS deployment target for x86_64 to 10.13.
25+
By :user:`Agriya Khetarpal <agriyakhetarpal>`, :issue:`288`.
26+
2027
Improvements
2128
~~~~~~~~~~~~
2229
* Raise a custom `UnknownCodecError` when trying to retrieve an unavailable codec.
@@ -40,7 +47,7 @@ Breaking changes
4047

4148
Deprecations
4249
~~~~~~~~~~~~
43-
The following ``blosc`` funcitons are deprecated, with no replacement.
50+
The following ``blosc`` functions are deprecated, with no replacement.
4451
This is because they are not intended to be public API.
4552

4653
- ``numcodecs.blosc.init``

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ filterwarnings = [
157157
[tool.cibuildwheel]
158158
environment = { DISABLE_NUMCODECS_AVX2=1 }
159159
[tool.cibuildwheel.macos]
160-
environment = { MACOSX_DEPLOYMENT_TARGET=10.9, DISABLE_NUMCODECS_AVX2=1, CFLAGS="$CFLAGS -Wno-implicit-function-declaration" }
160+
# cibuildwheel uses 3.12 for the Python driver, which supports High Sierra and later
161+
# https://github.com/pypa/cibuildwheel/blob/ee63bf16da6cddfb925f542f2c7b59ad50e93969/action.yml#L31
162+
environment = { MACOSX_DEPLOYMENT_TARGET=10.13, DISABLE_NUMCODECS_AVX2=1, CFLAGS="$CFLAGS -Wno-implicit-function-declaration" }
161163
[[tool.cibuildwheel.overrides]]
162164
select = "*-macosx_arm64"
163165
environment = { DISABLE_NUMCODECS_AVX2=1, DISABLE_NUMCODECS_SSE2=1 }

setup.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,15 @@
1313
# determine CPU support for SSE2 and AVX2
1414
cpu_info = cpuinfo.get_cpu_info()
1515
flags = cpu_info.get('flags', [])
16-
have_sse2 = 'sse2' in flags
17-
have_avx2 = 'avx2' in flags
16+
machine = cpuinfo.platform.machine()
17+
18+
# only check for x86 features on x86_64 arch
19+
have_sse2 = False
20+
have_avx2 = False
21+
if machine == 'x86_64':
22+
have_sse2 = 'sse2' in flags
23+
have_avx2 = 'avx2' in flags
24+
1825
disable_sse2 = 'DISABLE_NUMCODECS_SSE2' in os.environ
1926
disable_avx2 = 'DISABLE_NUMCODECS_AVX2' in os.environ
2027

@@ -24,7 +31,7 @@
2431
if have_cflags:
2532
# respect compiler options set by user
2633
pass
27-
elif os.name == 'posix':
34+
elif os.name == 'posix' and machine == 'x86_64':
2835
if disable_sse2:
2936
base_compile_args.append('-mno-sse2')
3037
elif have_sse2:
@@ -53,8 +60,14 @@ def blosc_extension():
5360
info('setting up Blosc extension')
5461

5562
extra_compile_args = base_compile_args.copy()
63+
extra_link_args = []
5664
define_macros = []
5765

66+
# ensure pthread is properly linked on POSIX systems
67+
if os.name == 'posix':
68+
extra_compile_args.append('-pthread')
69+
extra_link_args.append('-pthread')
70+
5871
# setup blosc sources
5972
blosc_sources = [f for f in glob('c-blosc/blosc/*.c') if 'avx2' not in f and 'sse2' not in f]
6073
include_dirs = [os.path.join('c-blosc', 'blosc')]
@@ -118,6 +131,7 @@ def blosc_extension():
118131
include_dirs=include_dirs,
119132
define_macros=define_macros,
120133
extra_compile_args=extra_compile_args,
134+
extra_link_args=extra_link_args,
121135
extra_objects=extra_objects,
122136
),
123137
]
@@ -307,8 +321,10 @@ class ve_build_ext(build_ext):
307321

308322
def run(self):
309323
try:
310-
if cpuinfo.platform.machine() == 'x86_64':
311-
S_files = glob('c-blosc/internal-complibs/zstd*/decompress/*amd64.S')
324+
machine = cpuinfo.platform.machine()
325+
if machine in ('x86_64', 'aarch64'):
326+
pattern = '*amd64.S' if machine == 'x86_64' else '*aarch64.S'
327+
S_files = glob(f'c-blosc/internal-complibs/zstd*/decompress/{pattern}')
312328
compiler = ccompiler.new_compiler()
313329
customize_compiler(compiler)
314330
compiler.src_extensions.append('.S')

0 commit comments

Comments
 (0)