Skip to content

Commit

Permalink
Merge branch 'mkleehammer:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ndmlny-qs authored Aug 29, 2023
2 parents 27bf598 + b854497 commit 16d10e5
Show file tree
Hide file tree
Showing 82 changed files with 3,470 additions and 16,185 deletions.
4 changes: 3 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ ignore =
E221,
# multi spaces before op - I line up assignments often
E401,
# multiple imports on one line
# multiple imports on one line
E722,
# ignore bare except in tests
14 changes: 10 additions & 4 deletions .github/workflows/artifacts_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ jobs:
strategy:
matrix:
# https://docs.github.com/en/actions/using-jobs/choosing-the-runner-for-a-job
# ubuntu-20.04 supports more versions of Python than ubuntu-22.04
# https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
os: [windows-2019, macos-11, ubuntu-20.04]
os: [windows-2019, macos-11, ubuntu-22.04]

steps:
- uses: actions/checkout@v3
Expand All @@ -53,9 +52,16 @@ jobs:
# Windows - both 64-bit and 32-bit builds
CIBW_ARCHS_WINDOWS: "AMD64 x86"

# macOS - just Intel build (ARM doesn't work); no bundled libraries
# macOS
#
# At the time of this writing, Github actions still do not support ARM macs - all
# runners are Intel. You can cross-compile on Intel to ARM, however, which is good
# enough us.
#
# https://cibuildwheel.readthedocs.io/en/stable/faq/#how-to-cross-compile
CIBW_ARCHS_MACOS: x86_64

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: ""

Expand Down
63 changes: 38 additions & 25 deletions .github/workflows/ubuntu_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
# Github Actions no longer supports Python 2.7 (June 2023)
# https://github.com/actions/runner-images/issues/7401
include:
- python-version: "3.6"
tests-dir: tests3
- python-version: "3.7"
tests-dir: tests3
- python-version: "3.8"
tests-dir: tests3
- python-version: "3.9"
tests-dir: tests3
- python-version: "3.10"
tests-dir: tests3
- python-version: "3.11"
tests-dir: tests3
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]

services:

Expand All @@ -46,6 +32,14 @@ jobs:
ACCEPT_EULA: Y
SA_PASSWORD: StrongPassword2019

mssql2022:
image: mcr.microsoft.com/mssql/server:2022-latest
ports:
- 1403:1433
env:
ACCEPT_EULA: Y
SA_PASSWORD: StrongPassword2022

postgres:
image: postgres:11
env:
Expand Down Expand Up @@ -137,6 +131,9 @@ jobs:
echo "*** SQL Server 2019"
docker exec -i "${{ job.services.mssql2019.id }}" /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'StrongPassword2019' -Q "SELECT @@VERSION" || sleep 5
docker exec -i "${{ job.services.mssql2019.id }}" /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'StrongPassword2019' -Q "CREATE DATABASE test"
echo "*** SQL Server 2022"
docker exec -i "${{ job.services.mssql2022.id }}" /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'StrongPassword2022' -Q "SELECT @@VERSION" || sleep 5
docker exec -i "${{ job.services.mssql2022.id }}" /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'StrongPassword2022' -Q "CREATE DATABASE test"
- name: Create test database in PostgreSQL
run: |
Expand Down Expand Up @@ -167,11 +164,12 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install Python dependencies
- name: Install Python dev dependencies
# pyodbc doesn't have any Python dependencies, but we do need pytest for testing.
run: |
cd "$GITHUB_WORKSPACE"
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
- name: Build and install pyodbc
run: |
Expand All @@ -187,22 +185,37 @@ jobs:
echo "*** pyodbc drivers"
python -c "import pyodbc; print('\n'.join(sorted(pyodbc.drivers())))"
- name: Run SQL Server 2017 tests
- name: Run PostgreSQL tests
env:
PYODBC_POSTGRESQL: "DRIVER={PostgreSQL Unicode};SERVER=localhost;PORT=5432;UID=postgres_user;PWD=postgres_pwd;DATABASE=test"
run: |
cd "$GITHUB_WORKSPACE"
python "./${{ matrix.tests-dir }}/sqlservertests.py" "DRIVER={ODBC Driver 17 for SQL Server};SERVER=localhost,1401;UID=sa;PWD=StrongPassword2017;DATABASE=test"
python -m pytest "./tests/postgresql_test.py"
- name: Run SQL Server 2019 tests
- name: Run MySQL tests
env:
PYODBC_MYSQL: "DRIVER={MySQL ODBC 8.0 ANSI Driver};SERVER=localhost;UID=root;PWD=root;DATABASE=test;CHARSET=utf8mb4"
run: |
cd "$GITHUB_WORKSPACE"
python "./${{ matrix.tests-dir }}/sqlservertests.py" "DRIVER={ODBC Driver 18 for SQL Server};SERVER=localhost,1402;UID=sa;PWD=StrongPassword2019;DATABASE=test;Encrypt=Optional"
python -m pytest "./tests/mysql_test.py"
- name: Run PostgreSQL tests
- name: Run SQL Server 2017 tests
env:
PYODBC_SQLSERVER: "DRIVER={ODBC Driver 17 for SQL Server};SERVER=localhost,1401;UID=sa;PWD=StrongPassword2017;DATABASE=test"
run: |
cd "$GITHUB_WORKSPACE"
python "./${{ matrix.tests-dir }}/pgtests.py" "DRIVER={PostgreSQL Unicode};SERVER=localhost;PORT=5432;UID=postgres_user;PWD=postgres_pwd;DATABASE=test"
python -m pytest "./tests/sqlserver_test.py"
- name: Run MySQL tests
- name: Run SQL Server 2019 tests
env:
PYODBC_SQLSERVER: "DRIVER={ODBC Driver 18 for SQL Server};SERVER=localhost,1402;UID=sa;PWD=StrongPassword2019;DATABASE=test;Encrypt=Optional"
run: |
cd "$GITHUB_WORKSPACE"
python -m pytest "./tests/sqlserver_test.py"
- name: Run SQL Server 2022 tests
env:
PYODBC_SQLSERVER: "DRIVER={ODBC Driver 18 for SQL Server};SERVER=localhost,1403;UID=sa;PWD=StrongPassword2022;DATABASE=test;Encrypt=Optional"
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"
python -m pytest "./tests/sqlserver_test.py"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ x86/
# Linters
.flake8
.pylintrc
.ruff_cache/
ruff.toml

# Other
pyodbc.conf
Expand Down
28 changes: 28 additions & 0 deletions HACKING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@


# Development Testing

We use tox for complete testing, but when you are in the middle of development you need fast
turn around. In this mode you need to be able to build and run tests using pytest manually.
To do this, build from the root of the directory using `--inplace` which will build the library
into the root. Run pytest from the same root directory and the new pyodbc library you built
will be in the path for your test:

python setup.py build_ext --inplace
pytest test/test_postgresql.py -vxk test_text

If a segmentation fault occurs while running tests, pytest will have eaten the output. Add
-s to the command line:

python setup.py build_ext --inplace -D PYODBC_TRACE
pytest test/test_postgresql.py -vxk test_text -vs


# Notes

## uint16_t

You'll notice we use uint16_t instead of SQLWCHAR. The unixODBC headers would define SQLWCHAR
as wchar_t even when wchar_t as defined by the C library as uint32_t. The data in the buffer
was still 16 bit however.

3 changes: 1 addition & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
include src/*.h
include src/*.cpp
include tests2/*
include tests3/*
include tests/*
include README.*
include LICENSE.txt

Expand Down
20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
# pyodbc

[![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)
[![Windows build](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)
[![Ubuntu build](https://github.com/mkleehammer/pyodbc/actions/workflows/ubuntu_build.yml/badge.svg)](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.
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 pyodbc is to use pip:

pip install pyodbc
python -m pip install pyodbc

On Macs, you should probably install unixODBC first if you don't already have an ODBC
driver manager installed, e.g. using `Homebrew`:
driver manager installed. For example, using the [homebrew](https://brew.sh/) package manager:

brew install unixodbc
pip install pyodbc
python -m 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)
Expand All @@ -25,12 +24,9 @@ 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.
pyodbc contains C++ extensions so you will need a suitable C++ compiler when building from
source. 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.
20 changes: 2 additions & 18 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ environment:
APVYR_RUN_POSTGRES_TESTS: "true"
APVYR_RUN_MYSQL_TESTS: "true"
APVYR_GENERATE_WHEELS: "false"
APVYR_VERBOSE: "false"
APVYR_VERBOSE: "true"
# SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the
# /E:ON and /V:ON options are not enabled in the batch script interpreter
# http://stackoverflow.com/a/13751649/163740
Expand All @@ -53,23 +53,6 @@ environment:
# all the Python versions to be tested, both 32-bit and 64-bit
# ref: https://www.appveyor.com/docs/windows-images-software/#python

# Python 2.7 must be built with Visual Studio 9.0, which is available only
# on AppVeyor Windows images Visual Studio 2013 and Visual Studio 2015

- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
PYTHON_HOME: "C:\\Python27"

- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
PYTHON_HOME: "C:\\Python27-x64"

# Python 3.5+ need at least the Visual Studio 2015 image

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

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

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

Expand Down Expand Up @@ -105,6 +88,7 @@ cache:

install:
- ps: .\appveyor\install.ps1
- call .\appveyor\install.cmd

# ref: https://www.appveyor.com/docs/services-databases/
services:
Expand Down
7 changes: 4 additions & 3 deletions appveyor/after_test.cmd
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
IF "%APVYR_GENERATE_WHEELS%" == "true" (
ECHO *** pip install the "wheel" module
"%PYTHON_HOME%\python" -m pip install wheel --quiet --no-warn-script-location
ECHO *** pip install build/wheel modules
"%PYTHON_HOME%\python" -m pip install build wheel --quiet --no-warn-script-location
ECHO.
ECHO *** Generate the wheel file
%WITH_COMPILER% "%PYTHON_HOME%\python" setup.py bdist_wheel
%WITH_COMPILER% "%PYTHON_HOME%\python" -m build --wheel --no-isolation
ECHO.
ECHO *** \dist directory listing:
DIR /B dist
ECHO.
) ELSE (
ECHO *** Skipping generation of the wheel file
ECHO.
Expand Down
8 changes: 0 additions & 8 deletions appveyor/build_script.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ IF ERRORLEVEL 1 (
)
"%PYTHON_HOME%\python" -m pip freeze --all

ECHO.
ECHO *** Building the pyodbc module...
%WITH_COMPILER% "%PYTHON_HOME%\python" setup.py build
IF ERRORLEVEL 1 (
ECHO *** ERROR: pyodbc build failed
EXIT 1
)

ECHO.
ECHO *** Installing pyodbc...
"%PYTHON_HOME%\python" -m pip install .
Expand Down
12 changes: 8 additions & 4 deletions appveyor/compile.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,14 @@ IF %PYTHON_MAJOR_VERSION% EQU 2 (
) ELSE (
IF %PYTHON_MAJOR_VERSION% EQU 3 (
SET WINDOWS_SDK_VERSION="v7.1"
SET SET_SDK_64=N
IF EXIST "%WIN_WDK%" (
:: See: https://connect.microsoft.com/VisualStudio/feedback/details/1610302/
REN "%WIN_WDK%" 0wdf
IF %PYTHON_MINOR_VERSION% LEQ 4 (
SET SET_SDK_64=Y
) ELSE (
SET SET_SDK_64=N
IF EXIST "%WIN_WDK%" (
:: See: https://connect.microsoft.com/VisualStudio/feedback/details/1610302/
REN "%WIN_WDK%" 0wdf
)
)
) ELSE (
ECHO Unsupported Python version: "%PYTHON_MAJOR_VERSION%"
Expand Down
3 changes: 3 additions & 0 deletions appveyor/install.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ECHO *** pip install pytest and other dev requirements ***
"%PYTHON_HOME%\python" -m pip install -r requirements-dev.txt --quiet --no-warn-script-location
ECHO.
Loading

0 comments on commit 16d10e5

Please sign in to comment.