Skip to content

Commit

Permalink
Apple silicon & Python 3.12 (#20)
Browse files Browse the repository at this point in the history
Support for Apple silicon and Python 3.12
  • Loading branch information
martinellimarco authored May 4, 2024
1 parent dd6899b commit efa50c9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
os: [macos-13, ubuntu-latest, windows-latest]
manylinux-image: [manylinux2014]

steps:
Expand All @@ -23,12 +23,12 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'
python-version: '3.12'

- name: Install Dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade-strategy eager --upgrade cython twine cibuildwheel
python3 -m pip install --upgrade-strategy eager --upgrade cython twine cibuildwheel setuptools
- name: Build Tarball
if: matrix.os == 'ubuntu-latest'
Expand All @@ -39,8 +39,9 @@ jobs:
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux-image }}
CIBW_MUSLLINUX_X86_64_IMAGE: musllinux_1_1
CIBW_ARCHS: auto64
CIBW_ARCHS_MACOS: "x86_64 arm64"
CIBW_BEFORE_ALL_LINUX: yum install -y libzstd-devel || apk add zstd-dev
CIBW_BEFORE_ALL_MACOS: brew install zstd
CIBW_BEFORE_ALL_MACOS: brew update && brew reinstall zstd
CIBW_BEFORE_BUILD_WINDOWS: "python {package}/libzstd/_get_zstd.py && pip install delvewheel"
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -w {dest_dir} {wheel}"
run: python -m cibuildwheel --output-dir dist
Expand All @@ -64,7 +65,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'
python-version: '3.12'

- name: Install Dependencies
run: |
Expand Down
23 changes: 16 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ jobs:
# 3.9 was released 2020-10-05 and end-of-life will be 2025-10-25
# 3.10 was released 2021-10-04 and end-of-life will be 2026-10-25
# 3.11 was released 2022-10-24 and end-of-life will be 2027-10-24
python-version: ['3.7', '3.11']
os: [macos-latest, ubuntu-latest, windows-latest]
# 3.12 was released 2023-10-02 and end-of-life will be 2028-10
python-version: ['3.8', '3.12']
#os: [macos-13, macos-14, ubuntu-latest, windows-latest]
os: [macos-13, ubuntu-latest, windows-latest]

steps:
- uses: actions/checkout@v2
Expand All @@ -28,6 +30,11 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install Dependencies (macos)
if: matrix.os == 'macos-13' || matrix.os == 'macos-14'
run: |
brew update && brew reinstall zstd
- name: Install Dependencies (ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
Expand All @@ -43,7 +50,7 @@ jobs:
- name: Install Python Modules
run: |
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade-strategy eager --upgrade cython twine cibuildwheel
python3 -m pip install --upgrade-strategy eager --upgrade cython twine cibuildwheel setuptools
- name: Test Installation From Tarball
shell: bash
Expand All @@ -65,7 +72,8 @@ jobs:

strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
#os: [macos-13, macos-14, ubuntu-latest, windows-latest]
os: [macos-13, ubuntu-latest, windows-latest]
manylinux-image: [manylinux2014]

steps:
Expand All @@ -76,12 +84,12 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'
python-version: '3.12'

- name: Install Python Dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade-strategy eager --upgrade cython twine cibuildwheel
python3 -m pip install --upgrade-strategy eager --upgrade cython twine cibuildwheel setuptools
- name: Build Tarball
if: matrix.os == 'ubuntu-latest'
Expand All @@ -92,8 +100,9 @@ jobs:
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux-image }}
CIBW_MUSLLINUX_X86_64_IMAGE: musllinux_1_1
CIBW_ARCHS: auto64
CIBW_ARCHS_MACOS: "x86_64 arm64"
CIBW_BEFORE_ALL_LINUX: yum install -y libzstd-devel || apk add zstd-dev
CIBW_BEFORE_ALL_MACOS: brew install zstd
CIBW_BEFORE_ALL_MACOS: brew update && brew reinstall zstd
CIBW_BEFORE_BUILD_WINDOWS: "python {package}/libzstd/_get_zstd.py && pip install delvewheel"
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -w {dest_dir} {wheel}"
run: python -m cibuildwheel --output-dir dist
Expand Down
15 changes: 11 additions & 4 deletions libzstd/_get_zstd.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,20 @@


with zipfile.ZipFile(io.BytesIO(zip_data)) as zf:
INCLUDE_DIR.joinpath("zstd.h").write_bytes(zf.read("include/zstd.h"))
LIBRARY_DIR.joinpath("libzstd.dll").write_bytes(zf.read("dll/libzstd.dll"))
files = zf.namelist()
zstd_h = next((f for f in files if "include/zstd.h" in f), None)
libzstd_dll = next((f for f in files if "dll/libzstd.dll" in f), None)
libzstd_lib = next((f for f in files if "dll/libzstd.lib" in f), None)
libzstd_dll_a = next((f for f in files if "dll/libzstd.dll.a" in f), None)

INCLUDE_DIR.joinpath("zstd.h").write_bytes(zf.read(zstd_h))
LIBRARY_DIR.joinpath("libzstd.dll").write_bytes(zf.read(libzstd_dll))
try:
_libzstd_lib = zf.read("dll/libzstd.lib")
_libzstd_lib = zf.read(libzstd_lib)
except KeyError:
_libzstd_lib = zf.read("dll/libzstd.dll.a")
_libzstd_lib = zf.read(libzstd_dll_a)
# this renames libzstd.dll.a to libzstd.lib for setuptools to work
LIBRARY_DIR.joinpath("libzstd.lib").write_bytes(_libzstd_lib)


print("success")

0 comments on commit efa50c9

Please sign in to comment.