Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1e0346a
Fix builds for macos, musllinux, and windows
peytondmurray Dec 17, 2025
698f6f7
Remove macos-13 (unsupported); fix deps for various build platforms
peytondmurray Dec 17, 2025
d4f1165
Trigger on PR
peytondmurray Dec 17, 2025
5124b60
Robust odbc detection in subproject too
peytondmurray Dec 17, 2025
86fdcba
Wrong kwarg
peytondmurray Dec 17, 2025
b34bcdc
Force c++17; install msvc, apparently it's not on windows runners ???
peytondmurray Dec 17, 2025
35c8f6b
Fix cpp std option
peytondmurray Dec 17, 2025
eb553b0
Skip 32bit windows wheels; set PYTHONUTF8=1 on windows
peytondmurray Dec 17, 2025
3378add
Disable autocrlf on windows, it breaks meson patching
peytondmurray Dec 17, 2025
410bab5
Don't use relpath when getting numpy include directory
peytondmurray Dec 17, 2025
6a1b5e1
Remove textenc.h, I think this is solved by fixing includes
peytondmurray Dec 18, 2025
a5b9bee
Install icu and pkgconf so meson can find icu on windows
peytondmurray Dec 18, 2025
238e161
Try installing pkgconfiglite; maybe meson will see that?
peytondmurray Dec 18, 2025
1cb7e80
Correctly expand env variables
peytondmurray Dec 18, 2025
bb34d60
Disable everything except windows; add tmate
peytondmurray Dec 18, 2025
33e4bdd
hmm, set the PKG_CONFIG_PATH correctly
peytondmurray Dec 19, 2025
be44b83
What?
peytondmurray Dec 19, 2025
7b8afd0
Insert PKG_CONFIG_PATH into CIBW environment manually
peytondmurray Dec 19, 2025
653b3e0
Try using vcpkg pkg-config
peytondmurray Dec 19, 2025
ccf64c0
Add in tmate to debug path
peytondmurray Dec 19, 2025
1856507
Remove tmate
peytondmurray Dec 20, 2025
793290e
Fix the locations by hand
peytondmurray Dec 20, 2025
840ea2c
Only disable compiler warnings on linux/macos
peytondmurray Dec 20, 2025
0423b73
Reorder headers so windows.h appears before sql types
peytondmurray Dec 20, 2025
de1033e
Ignore strict strings
peytondmurray Dec 20, 2025
e825a7a
Reenable other builds
peytondmurray Dec 20, 2025
2232d7a
Try overriding odbc dependency in the subproject
peytondmurray Dec 20, 2025
3daf433
Use immutable commit hash instead of tag for pyodbc
peytondmurray Dec 20, 2025
232b27d
Fix name of needed workflow; only run tests on PRs, not push also
peytondmurray Dec 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 59 additions & 33 deletions .github/workflows/artifacts_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
name: Build the release artifacts and publish to PyPI

on:
pull_request:
release:
types: [published]
workflow_dispatch:
Expand All @@ -26,6 +27,11 @@ jobs:
- 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

Expand All @@ -35,19 +41,39 @@ jobs:
name: sdist__${{ github.sha }}
path: ./dist/*.gz

build_windows_x86_wheels:
name: Build wheels on Windows x86_64
runs-on: windows-2022
build_windows_amd64_wheels:
name: Build wheels on Windows amd64
runs-on: windows-latest

steps:
- uses: actions/checkout@v4.3.0

# 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 x86"
# AMD64 and Intel32 wheels
CIBW_BUILD: "cp*-win_amd64 cp*-win32"
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
Expand All @@ -62,11 +88,32 @@ jobs:
steps:
- uses: actions/checkout@v4.3.0

# 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
Expand All @@ -91,7 +138,7 @@ jobs:
# 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
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
Expand Down Expand Up @@ -125,7 +172,7 @@ jobs:
# 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
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
Expand All @@ -142,28 +189,6 @@ jobs:
name: wheels_ubuntu_musllinux__${{ github.sha }}
path: ./wheelhouse/*.whl

build_macos_x86_wheels:
name: Build wheels on macOS x86_64
runs-on: macos-13

steps:
- uses: actions/checkout@v4.3.0

- name: Build wheels
uses: pypa/cibuildwheel@v3.2.1
# https://cibuildwheel.readthedocs.io/en/stable/options/#options-summary
env:
CIBW_ARCHS_MACOS: x86_64
CIBW_BUILD: "cp*macosx_x86_64"
# 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_x86__${{ github.sha }}
path: ./wheelhouse/*.whl

build_macos_arm64_wheels:
name: Build wheels on macOS ARM64
runs-on: macos-14
Expand All @@ -174,7 +199,9 @@ jobs:
- 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
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
Expand All @@ -198,12 +225,11 @@ jobs:
runs-on: ubuntu-latest
needs:
- build_macos_arm64_wheels
- build_macos_x86_wheels
- build_sdist
- build_ubuntu_manylinux_wheels
- build_ubuntu_musllinux_wheels
- build_windows_arm64_wheels
- build_windows_x86_wheels
- build_windows_amd64_wheels

environment:
name: pypi
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu_build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Ubuntu build

on: [push, pull_request]
on: [pull_request]

jobs:
run_tests:
Expand Down
42 changes: 19 additions & 23 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,28 @@ project(
'npyodbc',
'cpp',
version: run_command(['python', '-m', 'setuptools_scm'], check: true).stdout().strip(),
default_options: ['cpp_std=c++17']
)

python = import('python').find_installation(pure: false)
python_dep = python.dependency()

# ODBC driver needs to be installed by the OS.
compiler = meson.get_compiler('cpp')
odbc_dep = compiler.find_library('odbc')

numpy_inc = run_command(
python,
['-c', 'import os, numpy; print(os.path.relpath(numpy.get_include()))'],
check : true,
).stdout().strip()
numpy_dep = declare_dependency(include_directories : numpy_inc)
numpy_inc = include_directories(
run_command(
python,
['-c', 'import numpy; print(numpy.get_include())'],
check : true,
).stdout().strip()
)
numpy_dep = declare_dependency(include_directories: numpy_inc)

pyodbc_proj = subproject('pyodbc')
# Patch pyodbc and declare it (and odbc itself) as dependencies
subproject('pyodbc')
pyodbc_dep = dependency('pyodbc')

odbc_dep = dependency('odbc')
icu_dep = dependency('icu-uc')

npyodbc_inc = include_directories('include')
Expand All @@ -32,34 +35,27 @@ npyodbc_sources = [
add_project_arguments(
[
'-DPYODBC_VERSION=' + meson.project_version(),
'-Wno-write-strings',
'-Wno-deprecated-declarations',
],
language: 'cpp'
)

odbc_config = find_program('odbc_config', required : false)
deps = []
cflags = []
lflags = []

odbc_cflags = []
odbc_lflags = []
if odbc_config.found()
odbc_cflags = run_command([odbc_config, '--cflags'], check : true).stdout().strip()
odbc_lflags = run_command([odbc_config, '--libs'], check : true).stdout().strip()
endif

# Build the npyodbc module
python.extension_module(
'npyodbc',
npyodbc_sources,
dependencies : [
python_dep,
odbc_dep,
numpy_dep,
pyodbc_dep,
icu_dep
],
icu_dep,
] + deps,
include_directories : [npyodbc_inc],
install : true,
cpp_args : odbc_cflags,
link_args : odbc_lflags,
cpp_args : cflags,
link_args : lflags,
)
2 changes: 1 addition & 1 deletion src/npcontainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#define NPY_NO_DEPRECATED_API NPY_1_25_API_VERSION

#include <Python.h>
#include <sqltypes.h>
#include <stdio.h>
#include <string.h>

Expand Down Expand Up @@ -50,6 +49,7 @@ PyDataType_ELSIZE(PyArray_Descr *dtype) {
#include "dbspecific.h"
#include "errors.h"
#include "pyodbcmodule.h"
#include <sqltypes.h>
// clang-format on

#include "npcontainer.h"
Expand Down
8 changes: 4 additions & 4 deletions src/npyodbcmodule.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#include <Python.h>
#include "numpy/numpyconfig.h"
#include <sql.h>
#include <sqlext.h>

#include "methodobject.h"
#include "modsupport.h"
#include "pyodbc.h"
Expand All @@ -11,6 +7,10 @@
#include "connection.h"
#include "pyodbcmodule.h"

#include "numpy/numpyconfig.h"
#include <sql.h>
#include <sqlext.h>

// Set declaration for the pyodbc initialization function
// defined in pyodbcmodule.h -> pyodbcmodule.cpp
extern "C" {
Expand Down
10 changes: 0 additions & 10 deletions subprojects/packagefiles/patches/textenc.patch

This file was deleted.

59 changes: 54 additions & 5 deletions subprojects/packagefiles/pyodbc/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ python_dep = python.dependency()

compiler = meson.get_compiler('cpp')

# ODBC driver needs to be installed by the OS.
odbc_dep = compiler.find_library('odbc')

pyodbc_sources = [
'src/cnxninfo.cpp',
'src/connection.cpp',
Expand All @@ -30,13 +27,65 @@ pyodbc_inc = include_directories(
is_system: true
)

deps = []
cflags = []
lflags = []

if host_machine.system() == 'windows'
# Copy additional windows cflags from setup.py
cflags += [
'/Wall',
'/wd4514',
'/wd4820',
'/wd4668',
'/wd4711',
'/wd4100',
'/wd4127',
'/wd4191',
'/d2FH4-',
'/Zc:strictStrings-',
]

lflags = ['/d2:-FH4-']
deps += [
compiler.find_library('odbc32', required: true),
compiler.find_library('advapi32', required: true),
]
else # Unix

# First try to detect odbc via meson
odbc = compiler.find_library('odbc', required: false)
if odbc.found()
# If we can find odbc via meson, no other action is needed
deps += [odbc]

else
# Otherwise, we try to use odbc_config
odbc_config = find_program('odbc_config', required: false)
if odbc_config.found()
cflags += run_command([odbc_config, '--cflags'], check: true).stdout().strip().split()
lflags += run_command([odbc_config, '--libs'], check: true).stdout().strip().split()
else
error('Cannot find either the odbc library or the odbc_config binary. Aborting.')
endif
endif
endif

odbc_dep = declare_dependency(
dependencies: deps,
compile_args: cflags,
link_args: lflags,
)

pyodbc_dep = declare_dependency(
sources: pyodbc_sources,
dependencies: [
python_dep,
odbc_dep,
],
] + deps,
include_directories: [pyodbc_inc],
compile_args: cflags,
link_args: lflags,
)

meson.override_dependency('pyodbc', pyodbc_dep)
meson.override_dependency('odbc', odbc_dep)
5 changes: 3 additions & 2 deletions subprojects/pyodbc.wrap
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[wrap-git]
directory = pyodbc
url = https://github.com/mkleehammer/pyodbc.git
revision = 5.3.0
# 5.3.0
revision = 7ee5b566984f7bd3d8fcfa0369e9e163e70e1cbd
depth = 1
patch_directory = pyodbc
diff_files = patches/textenc.patch, patches/pyproject.patch, patches/cursor.patch, patches/pyodbcmodule.patch
diff_files = patches/pyproject.patch, patches/cursor.patch, patches/pyodbcmodule.patch

[provide]
dependency_names = pyodbc
Loading