Skip to content

Deduplicate module initialization #23

Deduplicate module initialization

Deduplicate module initialization #23

Workflow file for this run

# Build all the artifacts for a release (i.e. the source distribution file and the various wheels)
# https://docs.github.com/en/actions/using-jobs/choosing-the-runner-for-a-job
# https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
# https://cibuildwheel.readthedocs.io/en/stable/options/#options-summary
name: Build the release artifacts and publish to PyPI
on:
pull_request:
release:
types: [published]
workflow_dispatch:
inputs:
test_pypi:
type: boolean
description: 'Test release: publish on test.pypi.org'
default: false
jobs:
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.3.0
with:
fetch-depth: 0 # get the non-merge commit for PRs
fetch-tags: true # include tags to get correct version from setuptools_scm
- name: Install Python dependencies
run: python -m pip install --upgrade pip build
- name: Install sqlite
run: |
sudo apt update
sudo apt install -y sqlite3 unixodbc-dev libsqliteodbc libicu-dev
- name: Build sdist
run: python -m build --sdist
- name: Upload sdist
uses: actions/upload-artifact@v6
with:
name: sdist__${{ github.sha }}
path: ./dist/*.gz
build_windows_amd64_wheels:
name: Build wheels on Windows amd64
runs-on: windows-latest
steps:
- uses: actions/checkout@v4.3.0
with:
fetch-depth: 0 # get the non-merge commit for PRs
fetch-tags: true # include tags to get correct version from setuptools_scm
# https://github.com/actions/runner-images/issues/9894#issuecomment-2120538177
# suggests we need to set up a c compiler on windows.
- name: Setup Cpp
uses: aminya/setup-cpp@v1
with:
compiler: msvc
vcvarsall: true
cmake: true
ninja: true
vcpkg: true
- name: Install icu, pkgconf
shell: bash
run: |
vcpkg install icu pkgconf
- name: Build wheels
uses: pypa/cibuildwheel@v3.2.1
env:
CIBW_ARCHS_WINDOWS: "AMD64"
CIBW_BUILD: "cp*-win_amd64"
CIBW_SKIP: "*-win32"
CIBW_ENVIRONMENT: >
PYTHONUTF8=1
PKG_CONFIG='C:/Users/runneradmin/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe'
PKG_CONFIG_PATH='C:/Users/runneradmin/vcpkg/installed/x64-windows/lib/pkgconfig/'
- name: Upload wheels
uses: actions/upload-artifact@v6
with:
name: wheels_windows_x86_64__${{ github.sha }}
path: ./wheelhouse/*.whl
build_windows_arm64_wheels:
name: Build wheels on Windows ARM64
runs-on: windows-11-arm
steps:
- uses: actions/checkout@v4.3.0
with:
fetch-depth: 0 # get the non-merge commit for PRs
fetch-tags: true # include tags to get correct version from setuptools_scm
# https://github.com/actions/runner-images/issues/9894#issuecomment-2120538177
# suggests we need to set up a c compiler on windows.
- name: Setup Cpp
uses: aminya/setup-cpp@v1
with:
compiler: msvc
vcvarsall: true
cmake: true
ninja: true
vcpkg: true
- name: Install icu, pkgconf
shell: bash
run: |
vcpkg install icu pkgconf
- name: Build wheels
uses: pypa/cibuildwheel@v3.2.1
env:
CIBW_ARCHS_WINDOWS: "ARM64"
CIBW_BUILD: "cp*-win_arm64"
CIBW_SKIP: "*-win32"
CIBW_ENVIRONMENT: >
PYTHONUTF8=1
PKG_CONFIG='C:/Users/runneradmin/vcpkg/installed/arm64-windows/tools/pkgconf/pkgconf.exe'
PKG_CONFIG_PATH='C:/Users/runneradmin/vcpkg/installed/arm64-windows/lib/pkgconfig/'
- name: Upload wheels
uses: actions/upload-artifact@v6
with:
name: wheels_windows_arm64__${{ github.sha }}
path: ./wheelhouse/*.whl
build_ubuntu_manylinux_wheels:
name: Build wheels on Ubuntu manylinux
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4.3.0
with:
fetch-depth: 0 # get the non-merge commit for PRs
fetch-tags: true # include tags to get correct version from setuptools_scm
- name: Set up QEMU
# QEMU is needed for Linux aarch64 wheels
uses: docker/setup-qemu-action@v3.6.0
- name: Build wheels
uses: pypa/cibuildwheel@v3.2.1
env:
# https://github.com/pypa/manylinux#docker-images
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
CIBW_ARCHS_LINUX: x86_64 aarch64
CIBW_BEFORE_ALL_LINUX: yum -y install unixODBC-devel libicu-devel meson
# Intel64 and ARM64 wheels
CIBW_BUILD: "cp*-manylinux_x86_64 cp*-manylinux_aarch64"
# the raw wheel filename is not PyPi compliant so the wheel must be repaired but
# suppress the addition of unixODBC libs to the wheel with --exclude's
CIBW_REPAIR_WHEEL_COMMAND_LINUX:
auditwheel repair
--exclude "libodbc.so.*"
--wheel-dir {dest_dir}
{wheel}
- name: Upload wheels
uses: actions/upload-artifact@v6
with:
name: wheels_ubuntu_manylinux__${{ github.sha }}
path: ./wheelhouse/*.whl
build_ubuntu_musllinux_wheels:
name: Build wheels on Ubuntu musllinux
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4.3.0
with:
fetch-depth: 0 # get the non-merge commit for PRs
fetch-tags: true # include tags to get correct version from setuptools_scm
- name: Set up QEMU
# QEMU is needed for Linux aarch64 wheels
uses: docker/setup-qemu-action@v3.6.0
- name: Build wheels
uses: pypa/cibuildwheel@v3.2.1
env:
# https://github.com/pypa/manylinux#docker-images
CIBW_MUSLLINUX_X86_64_IMAGE: musllinux_1_2
CIBW_ARCHS_LINUX: x86_64 aarch64
CIBW_BEFORE_ALL_LINUX: apk add unixodbc-dev icu-dev meson
# Intel64 and ARM64 wheels
CIBW_BUILD: "cp*-musllinux_x86_64 cp*-musllinux_aarch64"
# the raw wheel filename is not PyPi compliant so the wheel must be repaired but
# suppress the addition of unixODBC libs to the wheel with --exclude's
CIBW_REPAIR_WHEEL_COMMAND_LINUX:
auditwheel repair
--exclude "libodbc.so.*"
--wheel-dir {dest_dir}
{wheel}
- name: Upload wheels
uses: actions/upload-artifact@v6
with:
name: wheels_ubuntu_musllinux__${{ github.sha }}
path: ./wheelhouse/*.whl
build_macos_arm64_wheels:
name: Build wheels on macOS ARM64
runs-on: macos-14
steps:
- uses: actions/checkout@v4.3.0
with:
fetch-depth: 0 # get the non-merge commit for PRs
fetch-tags: true # include tags to get correct version from setuptools_scm
- name: Install unixODBC
# unixODBC is necessary for the SQL C header files, e.g. sql.h, but doesn't appear
# to be pre-installed on macos-14, hence make sure it really is installed
run: |
brew install unixodbc icu4c
echo "PKG_CONFIG_PATH=$(brew --prefix)/lib/pkgconfig:$(brew --prefix icu4c)/lib/pkgconfig" >> $GITHUB_ENV
- name: Build wheels
uses: pypa/cibuildwheel@v3.2.1
# https://cibuildwheel.readthedocs.io/en/stable/options/#options-summary
env:
CIBW_ARCHS_MACOS: arm64
CIBW_BUILD: "cp*macosx_arm64"
# suppress the inclusion of the unixODBC dynamic libraries by disabling the repair command
CIBW_REPAIR_WHEEL_COMMAND_MACOS: ""
- name: Upload wheels
uses: actions/upload-artifact@v6
with:
name: wheels_macos_arm64__${{ github.sha }}
path: ./wheelhouse/*.whl
publish:
name: Publish to PyPI
if: (github.event_name == 'release' && startsWith(github.ref, 'refs/tags')) || (github.event_name == 'workflow_dispatch')
runs-on: ubuntu-latest
needs:
- build_macos_arm64_wheels
- build_sdist
- build_ubuntu_manylinux_wheels
- build_ubuntu_musllinux_wheels
- build_windows_arm64_wheels
- build_windows_amd64_wheels
environment:
name: pypi
url: https://pypi.org/p/npyodbc
permissions:
id-token: write
steps:
- name: Download the artifacts
uses: actions/download-artifact@v7
with:
merge-multiple: true
path: wheels/
- name: 🧪 Publish to PyPI Testing
uses: pypa/gh-action-pypi-publish@release/v1
if: ${{ inputs.test_pypi }}
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: wheels
- name: 🎉 Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: ${{ !inputs.test_pypi }}
with:
packages-dir: wheels