Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fetchdictarray
Browse files Browse the repository at this point in the history
  • Loading branch information
ilanschnell committed Jan 12, 2023
2 parents c47a212 + 4829107 commit 94673fe
Show file tree
Hide file tree
Showing 32 changed files with 1,669 additions and 434 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/artifacts_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Build all the artifacts for a release (i.e. the source distribution file and the various wheels)

name: Build the release artifacts

# include "workflow_dispatch" so this workflow can be run manually from the Actions portal
on: [workflow_dispatch]

jobs:
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip build
- name: Build sdist
run: python -m build --sdist --no-isolation

- name: Upload sdist
uses: actions/upload-artifact@v3
with:
name: sdist_${{ github.sha }}
path: ./dist/*.gz

build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# https://docs.github.com/en/actions/using-jobs/choosing-the-runner-for-a-job
os: [windows-2019, macos-11, ubuntu-20.04]

steps:
- uses: actions/checkout@v3

- name: Set up QEMU
# QEMU is needed for Linux aarch64 wheels
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v2
with:
platforms: all

- name: Build wheels
uses: pypa/[email protected]
# https://cibuildwheel.readthedocs.io/en/stable/options/#options-summary
env:
# Windows - both 64-bit and 32-bit builds
CIBW_ARCHS_WINDOWS: "AMD64 x86"

# macOS - both Intel and ARM builds; no bundled libraries
CIBW_ARCHS_MACOS: "x86_64 arm64"
# prevent the addition of unixODBC dylibs to the wheel by simply not calling the repair
CIBW_REPAIR_WHEEL_COMMAND_MACOS: ""

# Linux - based on CentOS 7; glibc 64-bit builds only; no bundled libraries
# https://github.com/pypa/manylinux#docker-images
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_ARCHS_LINUX: x86_64 aarch64
# this installs unixODBC 2.3.1 which is quite old but it has the latest ABI so should be fine
CIBW_BEFORE_ALL_LINUX: yum -y install unixODBC-devel
# 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.2
--exclude libltdl.so.7
--wheel-dir {dest_dir}
{wheel}

# Build choices - disable musl Linux and PyPy builds
CIBW_SKIP: "*-musllinux_* pp*"

- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels_${{ github.sha }}
path: ./wheelhouse/*.whl
49 changes: 20 additions & 29 deletions .github/workflows/ubuntu_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on: [push, pull_request]

jobs:
run_tests:

runs-on: ubuntu-latest
name: Run tests on Python ${{ matrix.python-version }}
runs-on: ubuntu-20.04

strategy:
fail-fast: false
Expand All @@ -23,6 +23,8 @@ jobs:
tests-dir: tests3
- python-version: "3.10"
tests-dir: tests3
- python-version: "3.11"
tests-dir: tests3

services:

Expand Down Expand Up @@ -72,6 +74,13 @@ jobs:
echo "*** cat /etc/odbc.ini"
cat /etc/odbc.ini
- name: Install ODBC driver for SQL Server
run: |
echo "*** apt-get install the driver"
sudo ACCEPT_EULA=Y apt-get install --yes msodbcsql18
echo '*** ls -l /usr/lib/x86_64-linux-gnu/odbc'
ls -l /opt/microsoft/msodbcsql18/lib64 || true
- name: Install ODBC driver for PostgreSQL
run: |
echo "*** apt-get install the driver"
Expand Down Expand Up @@ -113,6 +122,8 @@ jobs:
cat /etc/odbc.ini
echo '*** ls -l /opt/microsoft/msodbcsql17/lib64'
ls -l /opt/microsoft/msodbcsql17/lib64 || true
echo '*** ls -l /opt/microsoft/msodbcsql18/lib64'
ls -l /opt/microsoft/msodbcsql18/lib64 || true
echo '*** ls -l /usr/lib/x86_64-linux-gnu/odbc'
ls -l /usr/lib/x86_64-linux-gnu/odbc || true
Expand Down Expand Up @@ -147,10 +158,10 @@ jobs:
echo "*** create database"
mysql --user=root --password=root --execute "CREATE DATABASE test"
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -165,12 +176,14 @@ jobs:
cd "$GITHUB_WORKSPACE"
echo "*** current python version"
python -VV
echo "*** run setup.py"
python setup.py install
echo "*** pip install"
python -m pip install .
echo "*** pip freeze"
python -m pip freeze --all
echo "*** pyodbc version"
python -c "import pyodbc; print(pyodbc.version)"
echo "*** pyodbc drivers"
python -c "import pyodbc; print('\n'.join(sorted(pyodbc.drivers())))"
- name: Run SQL Server 2017 tests
run: |
Expand All @@ -180,7 +193,7 @@ jobs:
- name: Run SQL Server 2019 tests
run: |
cd "$GITHUB_WORKSPACE"
python "./${{ matrix.tests-dir }}/sqlservertests.py" "DRIVER={ODBC Driver 17 for SQL Server};SERVER=localhost,1402;UID=sa;PWD=StrongPassword2019;DATABASE=test"
python "./${{ matrix.tests-dir }}/sqlservertests.py" "DRIVER={ODBC Driver 18 for SQL Server};SERVER=localhost,1402;UID=sa;PWD=StrongPassword2019;DATABASE=test;Encrypt=Optional"
- name: Run PostgreSQL tests
run: |
Expand All @@ -191,25 +204,3 @@ jobs:
run: |
cd "$GITHUB_WORKSPACE"
python "./${{ matrix.tests-dir }}/mysqltests.py" "DRIVER={MySQL ODBC 8.0 ANSI Driver};SERVER=localhost;UID=root;PWD=root;DATABASE=test;CHARSET=utf8mb4"
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2019, macos-10.15]

steps:
- uses: actions/checkout@v2

- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_24
CIBW_BEFORE_ALL_LINUX: apt-get update && apt-get -y install unixodbc-dev
# disable 32-bit and pypy builds
CIBW_SKIP: "*-win32 *-manylinux_i686 pp*"

- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,16 @@ x86/
# Executables
*.exe

# Linters
.flake8
.pylintrc

# Other
pyodbc.conf
tmp
tags
xxx_*

# The Access unit tests copy empty.accdb and empty.mdb to these names and use them.
test.accdb
test.mdb

4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
global-exclude *.py[cod]

include src/*.h
include src/*.cpp
include tests2/*
Expand All @@ -9,3 +7,5 @@ include LICENSE.txt

# Include this file, needed for bdist_rpm
include MANIFEST.in

global-exclude *.py[cod]
31 changes: 20 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,36 @@
# pyodbc

[![Windows Status](https://ci.appveyor.com/api/projects/status/github/mkleehammer/pyodbc?branch=master&svg=true&passingText=Windows%20build)](https://ci.appveyor.com/project/mkleehammer/pyodbc)
[![Ubuntu build](https://github.com/mkleehammer/pyodbc/actions/workflows/ubuntu_build.yml/badge.svg)](https://github.com/mkleehammer/pyodbc/actions/workflows/ubuntu_build.yml)
[![AppVeyor](https://ci.appveyor.com/api/projects/status/github/mkleehammer/pyodbc?branch=master&svg=true&passingText=Windows%20build&failingText=Windows%20build)](https://ci.appveyor.com/project/mkleehammer/pyodbc)
[![Github Actions - Ubuntu Build](https://github.com/mkleehammer/pyodbc/actions/workflows/ubuntu_build.yml/badge.svg?branch=master)](https://github.com/mkleehammer/pyodbc/actions/workflows/ubuntu_build.yml)
[![PyPI](https://img.shields.io/pypi/v/pyodbc?color=brightgreen)](https://pypi.org/project/pyodbc/)

pyodbc is an open source Python module that makes accessing ODBC databases simple. It
implements the [DB API 2.0](https://www.python.org/dev/peps/pep-0249) specification but is
packed with even more Pythonic convenience.

The easiest way to install is to use pip:
The easiest way to install pyodbc is to use pip:

pip install pyodbc

If you are using Mac, you should be using `Homebrew` for installing pyodbc:
On Macs, you should probably install unixODBC first if you don't already have an ODBC
driver manager installed, e.g. using `Homebrew`:

```brew install unixodbc
pip install pyodbc```

Precompiled binary wheels are provided for most Python versions on Windows and macOS. On other
operating systems this will build from source. Note, pyodbc contains C++ extensions so you will
need a suitable C++ compiler on your computer to install pyodbc, for all operating systems. See
the [docs](https://github.com/mkleehammer/pyodbc/wiki/Install) for details.
brew install unixodbc
pip install pyodbc

Similarly, on Unix you should make sure you have an ODBC driver manager installed before
installing pyodbc. See the [docs](https://github.com/mkleehammer/pyodbc/wiki/Install)
for more information about how to do this on different Unix flavors. (On Windows, the
ODBC driver manager is built-in.)

Precompiled binary wheels are provided for multiple Python versions on most Windows, macOS,
and Linux platforms. On other platforms pyodbc will be built from the source code. Note,
pyodbc contains C++ extensions so when building from source you will need a suitable C++
compiler. See the [docs](https://github.com/mkleehammer/pyodbc/wiki/Install) for details.

[Documentation](https://github.com/mkleehammer/pyodbc/wiki)

[Release Notes](https://github.com/mkleehammer/pyodbc/releases)

IMPORTANT: Python 2.7 support is being ended. The pyodbc 4.x versions will be the last to
support Python 2.7. The pyodbc 5.x versions will support only Python 3.7 and above.
10 changes: 9 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ environment:
MSSQL_INSTANCE: "(local)\\SQL2017"
POSTGRES_PATH: "C:\\Program Files\\PostgreSQL\\11"
MYSQL_PATH: "C:\\Program Files\\MySQL\\MySQL Server 5.7"
# the cache should always be saved, even on failure, to be available for the next run
APPVEYOR_SAVE_CACHE_ON_ERROR: "true"

matrix:

Expand Down Expand Up @@ -92,8 +94,14 @@ environment:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
PYTHON_HOME: "C:\\Python310-x64"

- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
PYTHON_HOME: "C:\\Python311"

- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
PYTHON_HOME: "C:\\Python311-x64"

cache:
- apvyr_cache -> appveyor\install.ps1
- apvyr_cache

install:
- ps: .\appveyor\install.ps1
Expand Down
15 changes: 9 additions & 6 deletions appveyor/build_script.cmd
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
ECHO *** Environment variables:
ECHO APPVEYOR_BUILD_FOLDER : %APPVEYOR_BUILD_FOLDER%
ECHO APPVEYOR_BUILD_WORKER_IMAGE: %APPVEYOR_BUILD_WORKER_IMAGE%
ECHO APPVEYOR_JOB_NUMBER: %APPVEYOR_JOB_NUMBER%
ECHO APPVEYOR_JOB_ID : %APPVEYOR_JOB_ID%
ECHO APPVEYOR_JOB_NAME : %APPVEYOR_JOB_NAME%
ECHO APPVEYOR_BUILD_FOLDER : %APPVEYOR_BUILD_FOLDER%
ECHO APPVEYOR_BUILD_WORKER_IMAGE : %APPVEYOR_BUILD_WORKER_IMAGE%
ECHO APPVEYOR_JOB_NUMBER : %APPVEYOR_JOB_NUMBER%
ECHO APPVEYOR_JOB_ID : %APPVEYOR_JOB_ID%
ECHO APPVEYOR_JOB_NAME : %APPVEYOR_JOB_NAME%
ECHO APPVEYOR_SAVE_CACHE_ON_ERROR: %APPVEYOR_SAVE_CACHE_ON_ERROR%
ECHO.
ECHO APVYR_RUN_TESTS : %APVYR_RUN_TESTS%
ECHO APVYR_RUN_MSSQL_TESTS : %APVYR_RUN_MSSQL_TESTS%
ECHO APVYR_RUN_POSTGRES_TESTS: %APVYR_RUN_POSTGRES_TESTS%
ECHO APVYR_RUN_MYSQL_TESTS : %APVYR_RUN_MYSQL_TESTS%
ECHO APVYR_GENERATE_WHEELS : %APVYR_GENERATE_WHEELS%
ECHO APVYR_VERBOSE : %APVYR_VERBOSE%
ECHO.
ECHO PYTHON_HOME : %PYTHON_HOME%
ECHO MSSQL_INSTANCE: %MSSQL_INSTANCE%
ECHO POSTGRES_PATH : %POSTGRES_PATH%
Expand Down Expand Up @@ -38,7 +41,7 @@ IF ERRORLEVEL 1 (

ECHO.
ECHO *** Installing pyodbc...
"%PYTHON_HOME%\python" setup.py install
"%PYTHON_HOME%\python" -m pip install .
IF ERRORLEVEL 1 (
ECHO *** ERROR: pyodbc install failed
EXIT 1
Expand Down
Loading

0 comments on commit 94673fe

Please sign in to comment.