From 55eb7310b0a0f424da33f4b6d3b4b50e02c323eb Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Fri, 17 Sep 2021 11:22:12 -0400 Subject: [PATCH] feat: build wheels using CIBuildWheel (#103) The 'python-publish' workflow now runs nightly, as well as on creation of a release. Uploads to PyPI only occur during release runs.t --- .github/sync-repo-settings.yaml | 15 +- .github/workflows/presubmit.yml | 252 +++++++++++++++++---------- .github/workflows/python-publish.yml | 245 ++++++++++++++++++-------- setup.py | 72 ++++++-- 4 files changed, 385 insertions(+), 199 deletions(-) diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index eaee3817..c6d8d663 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -28,18 +28,9 @@ branchProtectionRules: requiresStrictStatusChecks: true # List of required status check contexts that must pass for commits to be accepted to matching branches. requiredStatusCheckContexts: - - 'build-linux (3.6)' - - 'build-linux (3.7)' - - 'build-linux (3.8)' - - 'build-linux (3.9)' - - 'build-macos (3.6)' - - 'build-macos (3.7)' - - 'build-macos (3.8)' - - 'build-macos (3.9)' - - 'build-windows (3.6)' - - 'build-windows (3.7)' - - 'build-windows (3.8)' - - 'build-windows (3.9)' + - 'Build / test wheels (presubmit) / ubuntu-20.04 (pull_request)' + - 'Build / test wheels (presubmit) / macos-10.15 (pull_request)' + - 'Build / test wheels (presubmit) / windows-2019 ( x64 ) (pull_request)' - 'cla/google' # List of explicit permissions to add (additive only) permissionRules: diff --git a/.github/workflows/presubmit.yml b/.github/workflows/presubmit.yml index 0f1b460e..a48a2d45 100644 --- a/.github/workflows/presubmit.yml +++ b/.github/workflows/presubmit.yml @@ -1,5 +1,4 @@ - -name: Presubmit +name: Build / test wheels (presubmit) on: pull_request: @@ -7,128 +6,195 @@ on: - main jobs: - build-source-distribution: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - - name: Build - run: python setup.py sdist - - uses: actions/upload-artifact@v2 - with: - name: python-package-distributions - path: dist - build-linux: - runs-on: ubuntu-latest + build-wheels-linux: + name: ${{ matrix.os }} strategy: matrix: - # 3.10 is not yet available in manylinux docker images. - # https://github.com/pypa/manylinux - # python: [3.6, 3.7, 3.8, 3.9, 3.10-dev] - python: [3.6, 3.7, 3.8, 3.9, 3.10-dev] - # It is possible 3.10-dev will fail when the other versions are green. - # Turn off fast fail so if 3.10 fails the other required versions have - # the opportunity to pass. - fail-fast: false + os: + - ubuntu-20.04 + runs-on: ${{ matrix.os }} + steps: - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 with: - python-version: ${{ matrix.python }} - - name: Install dependencies - run: | - python -m pip install --upgrade setuptools pip wheel - - name: Build + submodules: 'recursive' + + - name: Build Wheels + uses: pypa/cibuildwheel@v2.1.1 env: - BUILD_PYTHON: ${{ matrix.python }} - CRC32C_PURE_PYTHON: "0" - run: | - ./scripts/manylinux/build.sh - - name: Test Import - run: | - pip install --no-index --find-links=wheels google-crc32c - python ./scripts/check_crc32c_extension.py - - name: Run tests - run: | - pip install pytest - python -m pytest tests + # For presubmit, just build / test the most common arch + CIBW_ARCHS: native + # For presubmit, skip build / test for pypy + CIBW_SKIP: pp37* + CIBW_ENVIRONMENT: > + CRC32C_PURE_PYTHON="0" + CRC32C_INSTALL_PREFIX="$(pwd)/usr" + CIBW_BUILD_VERBOSITY: 1 + # Build the C library inside CIBW so that the manylinux image is + # used to link the share library; otherwise, our extension wouldn't + # be able to link with it. + CIBW_BEFORE_BUILD: > + python -m pip install --upgrade setuptools pip wheel && + python -m pip install cmake && + cmake -S google_crc32c -B build \ + -DCMAKE_BUILD_TYPE=Release \ + -DCRC32C_BUILD_TESTS=no \ + -DCRC32C_BUILD_BENCHMARKS=no \ + -DBUILD_SHARED_LIBS=yes \ + -DCMAKE_INSTALL_PREFIX:PATH=$(pwd)/usr && + make -C build all install + CIBW_TEST_REQUIRES: pytest + CIBW_TEST_COMMAND: py.test -v {project}/tests/ + - uses: actions/upload-artifact@v2 with: name: python-package-distributions - path: ./wheels/google_crc32c*.whl + path: wheelhouse/ - build-macos: - runs-on: macos-latest + build-wheels-macos: + name: ${{ matrix.os }} strategy: matrix: - python: [3.6, 3.7, 3.8, 3.9, 3.10-dev] - # It is possible 3.10-dev will fail when the other versions are green. - # Turn off fast fail so if 3.10 fails the other required versions have - # the opportunity to pass. - fail-fast: false + os: + - macos-10.15 + # Wheels port forward + #- macos-11 + runs-on: ${{ matrix.os }} steps: + - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 with: - python-version: ${{ matrix.python }} - - name: Install dependencies - run: | - python -m pip install --upgrade setuptools pip wheel - - name: Build + submodules: 'recursive' + + - name: Get C library hash + id: get-c-lib-hash + run: + echo "::set-output name=hash::$(git -C google_crc32c log -n 1 --pretty=%H)" + + - id: load-cache + name: Load cached C library + uses: actions/cache@v2 + with: + path: ${{ github.workspace }}/usr + key: + libcrc32c-${{ matrix.os }}-${{ steps.get-c-lib-hash.outputs.hash }} + + - name: Build C Library + if: steps.load-cache.outputs.cache-hit != 'true' + run: > + python -m pip install --upgrade setuptools pip wheel && + python -m pip install cmake && + cmake -S google_crc32c -B build \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 \ + -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \ + -DCRC32C_BUILD_TESTS=no \ + -DCRC32C_BUILD_BENCHMARKS=no \ + -DBUILD_SHARED_LIBS=yes \ + -DCMAKE_INSTALL_PREFIX:PATH=${{ github.workspace }}/usr \ + -DCMAKE_INSTALL_NAME_DIR:PATH=${{ github.workspace }}/usr/lib && + make -C build all install + + - name: Build Wheels + uses: pypa/cibuildwheel@v2.1.1 env: - CRC32C_PURE_PYTHON: "0" - run: | - ./scripts/osx/build_gh_action.sh - - name: Test Import - run: | - pip install --no-index --find-links=wheels google-crc32c - python ./scripts/check_crc32c_extension.py - - name: Run tests - run: | - pip install pytest - python -m pytest tests + # For presubmit, just build / test the most common arch + CIBW_ARCHS: native + # For presubmit, skip build / test for pypy + CIBW_SKIP: pp37* + CIBW_ENVIRONMENT: > + CRC32C_PURE_PYTHON="0" + CRC32C_INSTALL_PREFIX="$(pwd)/usr" + CIBW_BUILD_VERBOSITY: 1 + CIBW_TEST_REQUIRES: pytest + CIBW_TEST_COMMAND: py.test -v {project}/tests/ + - uses: actions/upload-artifact@v2 with: name: python-package-distributions - path: ./wheels/google_crc32c*.whl + path: wheelhouse/ + + build-wheels-windows: + name: ${{ matrix.os }} ( ${{ matrix.platform }} ) - build-windows: - runs-on: windows-latest strategy: matrix: - python: [3.6, 3.7, 3.8, 3.9, 3.10-dev] - # It is possible 3.10-dev will fail when the other versions are green. - # Turn off fast fail so if 3.10 fails the other required versions have - # the opportunity to pass. - fail-fast: false + os: + - windows-2019 + platform: + # For presubmit, just build / test the most common platform + - x64 + #- Win32 + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.0.2 with: - # Use 16.x - vs-version: '[16.0, 17.0)' - - name: Set up Python - uses: actions/setup-python@v2 + submodules: 'recursive' + + - name: Get C library hash + id: get-c-lib-hash + run: + echo "::set-output name=hash::$(git -C google_crc32c log -n 1 --pretty=%H)" + + - id: load-cache + name: Load cached C library + uses: actions/cache@v2 with: - python-version: ${{ matrix.python }} - - name: Install dependencies + path: ${{ github.workspace }}\usr + key: + libcrc32c-${{ matrix.os }}-${{ matrix.platform }}-${{ steps.get-c-lib-hash.outputs.hash }} + + - name: Build C Library + if: steps.load-cache.outputs.cache-hit != 'true' run: | + echo "::group::Install cmake" python -m pip install --upgrade setuptools pip wheel - - name: Build - env: - CRC32C_PURE_PYTHON: "0" + python -m pip install cmake + echo "::endgroup::" + echo "::group::Run cmake to initialze build tree" + cmake -S google_crc32c -B build -G "Visual Studio 16 2019" -A ${{ matrix.platform }} -DCRC32C_BUILD_BENCHMARKS=no -DCRC32C_BUILD_TESTS=no -DBUILD_SHARED_LIBS=no -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=yes -DCRC32C_USE_GLOG=0 + echo "::endgroup::" + echo "::group::Run cmake to build library" + cmake --build build --verbose --config Release + echo "::endgroup::" + echo "::group::Run cmake to install library" + cmake --install build --verbose --config Release --prefix=${{ github.workspace }}\usr\ + echo "::endgroup::" + + # Passing through ${{ github.workspace }} to CIBW_ENVIRONMENT mangles + # backslashes: compute a variant which uses only forward-slashses. + - id: crc32c-install-prefix + name: Dead-reckon a CIBW-compatible install prefix + shell: bash run: | - where python - ./scripts/windows/build.bat ${{ matrix.python }} - - name: Test Import + python -c "import os; workspace = '/'.join(os.getenv('GITHUB_WORKSPACE').split(os.sep)); pfx = f'{workspace}/usr'; print(f'::set-output name=prefix::{pfx}')" + + - id: platform-arch + name: Map platform -> wheel arch + shell: bash run: | - ./scripts/windows/test.bat ${{ matrix.python }} + if [[ "${{ matrix.platform }}" == "Win32" ]]; then + echo "::set-output name=arch::x86" + else + echo "::set-output name=arch::AMD64" + fi + + - name: Build Wheels + uses: pypa/cibuildwheel@v2.1.1 + env: + CIBW_ARCHS_WINDOWS: ${{ steps.platform-arch.outputs.arch }} + # For presubmit, skip build / test for pypy + CIBW_SKIP: pp37* + CIBW_ENVIRONMENT: CRC32C_PURE_PYTHON="0" CRC32C_INSTALL_PREFIX="${{ steps.crc32c-install-prefix.outputs.prefix }}" + CIBW_BUILD_VERBOSITY: 3 + CIBW_TEST_REQUIRES: pytest + CIBW_TEST_COMMAND: py.test -v {project}/tests + - uses: actions/upload-artifact@v2 with: name: python-package-distributions - path: ./wheels/google_crc32c*.whl + path: wheelhouse/ diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 33e4c8f3..c3f7c861 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -4,6 +4,9 @@ name: Build binary wheels and upload to PyPI on: release: types: [created] + schedule: + # Build nightly at 05:43 UTC + - cron: '43 5 * * *' jobs: build-source-distribution: @@ -17,116 +20,206 @@ jobs: - uses: actions/upload-artifact@v2 with: name: python-package-distributions - path: dist + path: dist/ + + build-wheels-linux: + name: Build wheels on ${{ matrix.os }} - ${{ matrix.arch }} - build-linux: - runs-on: ubuntu-latest strategy: matrix: - python: [3.6, 3.7, 3.8, 3.9, 3.10-dev] + os: + - ubuntu-20.04 + arch: + - x86_64 + - i686 + - aarch64 + + runs-on: ${{ matrix.os }} + steps: - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 with: - python-version: ${{ matrix.python }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel - - name: Build + submodules: 'recursive' + + - name: Set up QEMU for ARM64 cross compile + if: ${{ matrix.arch }} == 'aarch64' + id: qemu + uses: docker/setup-qemu-action@v1 + + - name: Build Wheels + uses: pypa/cibuildwheel@v2.1.1 env: - BUILD_PYTHON: ${{ matrix.python }} - CRC32C_PURE_PYTHON: "0" - run: | - ./scripts/manylinux/build.sh - - name: Test Import - run: | - pip install --no-index --find-links=wheels google-crc32c - python ./scripts/check_crc32c_extension.py - - name: Run tests - run: | - pip install pytest - python -m pytest tests + CIBW_ARCHS_LINUX: ${{ matrix.arch }} + CIBW_ENVIRONMENT: > + CRC32C_PURE_PYTHON="0" + CRC32C_INSTALL_PREFIX="$(pwd)/usr" + CIBW_BUILD_VERBOSITY: 1 + # Build the C library inside CIBW so that the manylinux image is + # used to link the share library; otherwise, our extension wouldn't + # be able to link with it. + CIBW_BEFORE_BUILD: > + python -m pip install --upgrade setuptools pip wheel && + python -m pip install cmake && + cmake -S google_crc32c -B build \ + -DCMAKE_BUILD_TYPE=Release \ + -DCRC32C_BUILD_TESTS=no \ + -DCRC32C_BUILD_BENCHMARKS=no \ + -DBUILD_SHARED_LIBS=yes \ + -DCMAKE_INSTALL_PREFIX:PATH=$(pwd)/usr && + make -C build all install + CIBW_TEST_REQUIRES: pytest + CIBW_TEST_COMMAND: py.test -v {project}/tests/ + - uses: actions/upload-artifact@v2 with: name: python-package-distributions - path: ./wheels/google_crc32c*.whl + path: wheelhouse/ - build-macos: - runs-on: macos-latest + build-wheels-macos: + name: Build wheels on ${{ matrix.os }} - ${{ matrix.arch }} strategy: matrix: - python: [3.6, 3.7, 3.8, 3.9, 3.10-dev] + os: + - macos-10.15 + #- macos-11 + arch: + - x86_64 + - universal2 + runs-on: ${{ matrix.os }} steps: + - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 with: - python-version: ${{ matrix.python }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel - - name: Build + submodules: 'recursive' + + - name: Get C library hash + id: get-c-lib-hash + run: + echo "::set-output name=hash::$(git -C google_crc32c log -n 1 --pretty=%H)" + + - id: load-cache + name: Load cached C library + uses: actions/cache@v2 + with: + path: ${{ github.workspace }}/usr + key: + libcrc32c-${{ matrix.os }}-${{ steps.get-c-lib-hash.outputs.hash }} + + - name: Build C Library + if: steps.load-cache.outputs.cache-hit != 'true' + run: > + python -m pip install --upgrade setuptools pip wheel && + python -m pip install cmake && + cmake -S google_crc32c -B build \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 \ + -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \ + -DCRC32C_BUILD_TESTS=no \ + -DCRC32C_BUILD_BENCHMARKS=no \ + -DBUILD_SHARED_LIBS=yes \ + -DCMAKE_INSTALL_PREFIX:PATH=${{ github.workspace }}/usr \ + -DCMAKE_INSTALL_NAME_DIR:PATH=${{ github.workspace }}/usr/lib && + make -C build all install + + - name: Build Wheels + uses: pypa/cibuildwheel@v2.1.1 env: - CRC32C_PURE_PYTHON: "0" - run: | - ./scripts/osx/build_gh_action.sh - - name: Test Import - run: | - pip install --no-index --find-links=wheels google-crc32c - python ./scripts/check_crc32c_extension.py - - name: Run tests - run: | - pip install pytest - python -m pytest tests + CIBW_ARCHS_MACOS: ${{ matrix.arch }} + CIBW_ENVIRONMENT: > + CRC32C_PURE_PYTHON="0" + CRC32C_INSTALL_PREFIX="$(pwd)/usr" + CIBW_BUILD_VERBOSITY: 1 + CIBW_TEST_REQUIRES: pytest + CIBW_TEST_COMMAND: py.test -v {project}/tests/ + - uses: actions/upload-artifact@v2 with: name: python-package-distributions - path: ./wheels/google_crc32c*.whl + path: wheelhouse/ + + build-wheels-windows: + name: Build wheels on ${{ matrix.os }} ( ${{ matrix.platform }} ) - build-windows: - runs-on: windows-latest strategy: matrix: - python: [3.6, 3.7, 3.8, 3.9, 3.10-dev] + os: + - windows-2019 + platform: + - x64 + - Win32 + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.0.2 with: - # Use 16.x - vs-version: '[16.0, 17.0)' - - name: Set up Python - uses: actions/setup-python@v2 + submodules: 'recursive' + + - name: Get C library hash + id: get-c-lib-hash + run: + echo "::set-output name=hash::$(git -C google_crc32c log -n 1 --pretty=%H)" + + - id: load-cache + name: Load cached C library + uses: actions/cache@v2 with: - python-version: ${{ matrix.python }} - - name: Install dependencies + path: ${{ github.workspace }}\usr + key: + libcrc32c-${{ matrix.os }}-${{ matrix.platform }}-${{ steps.get-c-lib-hash.outputs.hash }} + + - name: Build C Library + if: steps.load-cache.outputs.cache-hit != 'true' run: | - python -m pip install --upgrade pip - pip install setuptools wheel - - name: Build - env: - CRC32C_PURE_PYTHON: "0" + python -m pip install --upgrade setuptools pip wheel + python -m pip install cmake + cmake -S google_crc32c -B build -G "Visual Studio 16 2019" -A ${{ matrix.platform }} -DCRC32C_BUILD_BENCHMARKS=no -DCRC32C_BUILD_TESTS=no -DBUILD_SHARED_LIBS=no -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=yes -DCRC32C_USE_GLOG=0 + cmake --build build --verbose --config Release + cmake --install build --verbose --config Release --prefix=${{ github.workspace }}\usr\ + + # Passing through ${{ github.workspace }} to CIBW_ENVIRONMENT mangles + # backslashes: compute a variant which uses only forward-slashses. + - id: crc32c-install-prefix + name: Dead-reckon a CIBW-compatible install prefix + shell: bash run: | - where python - ./scripts/windows/build.bat ${{ matrix.python }} - - name: Test Import + python -c "import os; workspace = '/'.join(os.getenv('GITHUB_WORKSPACE').split(os.sep)); pfx = f'{workspace}/usr'; print(f'::set-output name=prefix::{pfx}')" + + - id: platform-arch + name: Map platform -> wheel arch + shell: bash run: | - ./scripts/windows/test.bat ${{ matrix.python }} + if [[ "${{ matrix.platform }}" == "Win32" ]]; then + echo "::set-output name=arch::x86" + else + echo "::set-output name=arch::AMD64" + fi + + - name: Build Wheels + uses: pypa/cibuildwheel@v2.1.1 + env: + CIBW_ARCHS_WINDOWS: ${{ steps.platform-arch.outputs.arch }} + CIBW_ENVIRONMENT: > + CRC32C_INSTALL_PREFIX="${{ steps.crc32c-install-prefix.outputs.prefix }}" + CRC32C_PURE_PYTHON="0" + CIBW_BUILD_VERBOSITY: 1 + CIBW_TEST_REQUIRES: pytest + CIBW_TEST_COMMAND: py.test -v {project}/tests + - uses: actions/upload-artifact@v2 with: name: python-package-distributions - path: ./wheels/google_crc32c*.whl + path: wheelhouse/ publish: + if: github.event_name == 'release' needs: - - build-linux - - build-macos - - build-windows - build-source-distribution + - build-wheels-linux + - build-wheels-macos + - build-wheels-windows runs-on: ubuntu-latest steps: - name: Download all the dists @@ -138,15 +231,15 @@ jobs: uses: actions/download-artifact@v2 with: name: python-package-distributions - path: wheels/ + path: wheelhouse/ - name: What will we publish? - run: ls wheels + run: ls wheelhouse/ - name: Publish Source Distribution uses: pypa/gh-action-pypi-publish@master with: user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} - packages_dir: dist + packages_dir: dist/ skip_existing: true # repository_url: https://test.pypi.org/legacy/ - name: Publish Wheels @@ -154,6 +247,6 @@ jobs: with: user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} - packages_dir: wheels + packages_dir: wheelhouse/ skip_existing: true # repository_url: https://test.pypi.org/legacy/ diff --git a/setup.py b/setup.py index 7a073bb7..463498ae 100644 --- a/setup.py +++ b/setup.py @@ -14,6 +14,7 @@ import logging import os +import platform import shutil import setuptools import setuptools.command.build_ext @@ -28,18 +29,21 @@ def copy_dll(build_lib): - if os.name != "nt": - return - + return # trying static build of C library. install_prefix = os.environ.get("CRC32C_INSTALL_PREFIX") - if install_prefix is None: - return - installed_dll = os.path.join(install_prefix, "bin", _DLL_FILENAME) - lib_dlls = os.path.join(build_lib, "google_crc32c", _EXTRA_DLL) - os.makedirs(lib_dlls, exist_ok=True) - relocated_dll = os.path.join(lib_dlls, _DLL_FILENAME) - shutil.copyfile(installed_dll, relocated_dll) + if os.name == "nt" and install_prefix is not None: + assert os.path.isdir(install_prefix) + + installed_dll = os.path.join(install_prefix, "bin", _DLL_FILENAME) + assert os.path.isfile(installed_dll) + + lib_dlls = os.path.join(build_lib, "google_crc32c", _EXTRA_DLL) + os.makedirs(lib_dlls, exist_ok=True) + relocated_dll = os.path.join(lib_dlls, _DLL_FILENAME) + + shutil.copyfile(installed_dll, relocated_dll) + assert os.path.isfile(relocated_dll) class BuildExtWithDLL(setuptools.command.build_ext.build_ext): @@ -49,14 +53,6 @@ def run(self): return result -module_path = os.path.join("src", "google_crc32c", "_crc32c.c") -module = setuptools.Extension( - "google_crc32c._crc32c", - sources=[os.path.normcase(module_path)], - libraries=["crc32c"], -) - - def build_pure_python(): setuptools.setup( packages=["google_crc32c"], @@ -66,6 +62,46 @@ def build_pure_python(): def build_c_extension(): + install_prefix = os.getenv("CRC32C_INSTALL_PREFIX") + if install_prefix is not None: + install_prefix = os.path.normcase(install_prefix) + print(f"#### using local install of 'crc32c': {install_prefix!r}") + #assert os.path.isdir(install_prefix) + install_prefix = os.path.realpath(install_prefix) + include_dirs = [os.path.join(install_prefix, "include")] + library_dirs = [os.path.join(install_prefix, "lib")] + + if platform.system() == "Linux": + library_dirs.append(os.path.join(install_prefix, "lib64")) + + if os.name == "nt": + library_dirs.append(os.path.join(install_prefix, "bin")) + kwargs = { + "include_dirs": include_dirs, + "library_dirs": library_dirs, + } + else: + runtime_library_dirs = library_dirs[:] + kwargs = { + "include_dirs": include_dirs, + "library_dirs": library_dirs, + "runtime_library_dirs": runtime_library_dirs, + } + else: + print("#### using global install of 'crc32c'") + kwargs = {} + + module_path = os.path.join("src", "google_crc32c", "_crc32c.c") + sources=[os.path.normcase(module_path)] + print(f"##### sources: {sources}") + print(f"##### module kwargs: {kwargs}") + module = setuptools.Extension( + "google_crc32c._crc32c", + sources=sources, + libraries=["crc32c"], + **kwargs + ) + setuptools.setup( packages=["google_crc32c"], package_dir={"": "src"},