diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 58484bb77ab6501d4cc8a37b12c37b4b73f98ca5..6378f9677bd04d46e3294c913c5042486cb92d24 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -190,7 +190,7 @@ jobs: - name: Build source package run: | pip install cython - python scripts/fetch-vendor /tmp/vendor + python scripts/fetch-vendor.py /tmp/vendor PKG_CONFIG_PATH=/tmp/vendor/lib/pkgconfig make build python setup.py sdist - name: Upload source package @@ -204,7 +204,17 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + include: + - os: macos-latest + arch: arm64 + - os: macos-latest + arch: x86_64 + - os: ubuntu-latest + arch: i686 + - os: ubuntu-latest + arch: x86_64 + - os: windows-latest + arch: AMD64 steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v1 @@ -217,9 +227,9 @@ jobs: brew install pkg-config - name: Build wheels env: - CIBW_ARCHS_WINDOWS: AMD64 - CIBW_BEFORE_BUILD: pip install cython && python scripts/fetch-vendor /tmp/vendor - CIBW_BEFORE_BUILD_WINDOWS: pip install cython && python scripts\fetch-vendor C:\cibw\vendor + CIBW_ARCHS: ${{ matrix.arch }} + CIBW_BEFORE_BUILD: pip install cython && python scripts/fetch-vendor.py /tmp/vendor + CIBW_BEFORE_BUILD_WINDOWS: pip install cython && python scripts\fetch-vendor.py C:\cibw\vendor CIBW_ENVIRONMENT_LINUX: LD_LIBRARY_PATH=/tmp/vendor/lib:$LD_LIBRARY_PATH PKG_CONFIG_PATH=/tmp/vendor/lib/pkgconfig CIBW_ENVIRONMENT_MACOS: PKG_CONFIG_PATH=/tmp/vendor/lib/pkgconfig LDFLAGS=-headerpad_max_install_names CIBW_ENVIRONMENT_WINDOWS: INCLUDE=C:\\cibw\\vendor\\include LIB=C:\\cibw\\vendor\\lib PYAV_SKIP_TESTS=unicode_filename diff --git a/scripts/fetch-vendor.json b/scripts/fetch-vendor.json index 4cddc2f3bb383ec91073e706e70b1fcac03716ad..d87885e4b6a08caa2c9d40fcc4807c1830fff250 100644 --- a/scripts/fetch-vendor.json +++ b/scripts/fetch-vendor.json @@ -1,3 +1,3 @@ { - "urls": ["https://github.com/PyAV-Org/pyav-ffmpeg/releases/download/4.3.2-1/ffmpeg-{platform}.tar.gz"] + "urls": ["https://github.com/PyAV-Org/pyav-ffmpeg/releases/download/4.3.2-2/ffmpeg-{platform}.tar.gz"] } diff --git a/scripts/fetch-vendor b/scripts/fetch-vendor.py old mode 100755 new mode 100644 similarity index 64% rename from scripts/fetch-vendor rename to scripts/fetch-vendor.py index aa354aaba1bca7b28fb73310db13ebe63cdbcaaa..fcfa8d3c81afd9b7bf91fbe738d35c3a2ac57a46 --- a/scripts/fetch-vendor +++ b/scripts/fetch-vendor.py @@ -1,30 +1,37 @@ -#!/usr/bin/env python - import argparse import logging import json import os +import platform import shutil import struct import subprocess -import sys def get_platform(): - if sys.platform == "linux": - return "manylinux_%s" % os.uname().machine - elif sys.platform == "darwin": - return "macosx_%s" % os.uname().machine - elif sys.platform == "win32": - return "win%s" % (struct.calcsize("P") * 8) + system = platform.system() + machine = platform.machine() + if system == "Linux": + return f"manylinux_{machine}" + elif system == "Darwin": + # cibuildwheel sets ARCHFLAGS: + # https://github.com/pypa/cibuildwheel/blob/5255155bc57eb6224354356df648dc42e31a0028/cibuildwheel/macos.py#L207-L220 + if "ARCHFLAGS" in os.environ: + machine = os.environ["ARCHFLAGS"].split()[1] + return f"macosx_{machine}" + elif system == "Windows": + if struct.calcsize("P") * 8 == 64: + return "win_amd64" + else: + return "win32" else: - raise Exception("Unsupported platfom %s" % sys.platform) + raise Exception(f"Unsupported system {system}") parser = argparse.ArgumentParser(description="Fetch and extract tarballs") parser.add_argument("destination_dir") parser.add_argument("--cache-dir", default="tarballs") -parser.add_argument("--config-file", default=__file__ + ".json") +parser.add_argument("--config-file", default=os.path.splitext(__file__)[0] + ".json") args = parser.parse_args() logging.basicConfig(level=logging.INFO)