From 94f693747dab3e0b6586ce26021ef3148e03dc5c Mon Sep 17 00:00:00 2001 From: Michael Kleehammer Date: Sat, 26 Aug 2023 14:07:42 -0500 Subject: [PATCH] Fixes to allow build artifacts - Removed a delegating ctor which fails on macOS gcc with error "delegating constructors are permitted only in C++11". - Add version to toml file, required by cibuildwheel (and pyproject.toml specification, I think) and have setup.py file extract it dynamically so we only have to maintain one. I need to determine if the setup keywords are even required or if it will pick up items from the toml file. --- .github/workflows/artifacts_build.yml | 1 - pyproject.toml | 35 +++++++++++++++++++++++++++ setup.py | 24 ++++++++++++++++-- src/textenc.h | 2 +- 4 files changed, 58 insertions(+), 4 deletions(-) diff --git a/.github/workflows/artifacts_build.yml b/.github/workflows/artifacts_build.yml index 461bab9f..34ffaad9 100644 --- a/.github/workflows/artifacts_build.yml +++ b/.github/workflows/artifacts_build.yml @@ -34,7 +34,6 @@ jobs: # 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 os: [windows-2019, macos-11, ubuntu-22.04] - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v3 diff --git a/pyproject.toml b/pyproject.toml index fed528d4..e73f8b7f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,38 @@ +[project] +name = "pyodbc" +version = "5.0.0a2" + +requires-python = ">=3.7" +# This is used by the Github action that builds release artifacts using cibuildwheel. +# cibuildwheel reads this directly: +# +# https://cibuildwheel.readthedocs.io/en/stable/options/#requires-python + +description = "DB API module for ODBC" +readme = "README.md" +license = {text = "MIT License"} + +authors = [{name = "Michael Kleehammer", email="michael@kleehammer.com"}] + +maintainers = [{name = "Michael Kleehammer", email="michael@kleehammer.com"}] +# There are a lot of contributors and I'd like to include everyone that puts in a lot of +# effort, but is this for the more technical meaning of who makes builds? Would adding +# contributors cause confusion. + +classifiers=['Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'License :: OSI Approved :: MIT License', + 'Operating System :: Microsoft :: Windows', + 'Operating System :: POSIX', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Topic :: Database', + ] + +[project.urls] +Homepage = "https://github.com/mkleehammer/pyodbc" + [build-system] requires = ["setuptools"] build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py index b5c9ce34..eaf6d0cb 100755 --- a/setup.py +++ b/setup.py @@ -1,14 +1,34 @@ #!/usr/bin/env python -import sys, os, shlex +import sys, os, shlex, re from os.path import exists, join, isdir, relpath, expanduser +from pathlib import Path from inspect import cleandoc from setuptools import setup from setuptools.extension import Extension -VERSION = '5.0.0a1' +def _getversion(): + # CAREFUL: We need the version in this file so we can set it in a C macro to set + # pyodbc.__version__, plus the setup function might require it. We also need it in the + # toml file or cibuildwheel will fail. Instead of requiring a toml parser for older + # versions of Python, we'll parse it out with a regexp, which is very simple. + path = Path(__file__).parent / 'pyproject.toml' + assert path.exists(), f'Cannot find {path}' + text = path.read_text(encoding='utf8') + m = re.search( + r""" + ^ \s* version \s*=\s* "([^"]+)" + """, + text, + flags=re.VERBOSE | re.MULTILINE | re.IGNORECASE) + if not m: + sys.exit(f'Did not find version in {path}') + return m.group(1) + + +VERSION = _getversion() def main(): diff --git a/src/textenc.h b/src/textenc.h index 08557da6..19214023 100644 --- a/src/textenc.h +++ b/src/textenc.h @@ -84,8 +84,8 @@ class SQLWChar } SQLWChar(PyObject* src, const TextEnc* penc) - : SQLWChar(src, *penc) { + init(src, *penc); } SQLWChar(PyObject* src, const TextEnc& enc)