From a757bb504e7a624288543879db4ee5ca2215525d Mon Sep 17 00:00:00 2001 From: Keith Erskine Date: Wed, 9 Nov 2022 17:27:39 -0600 Subject: [PATCH 1/8] set version id in CICD --- .gitignore | 5 ++++- pyproject.toml | 3 +++ setup.py | 13 +++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 pyproject.toml diff --git a/.gitignore b/.gitignore index d153bb85..f7b64769 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,10 @@ x86/ # Executables *.exe +# Linters +.flake8 +.pylintrc + # Other pyodbc.conf tmp @@ -54,4 +58,3 @@ tags # The Access unit tests copy empty.accdb and empty.mdb to these names and use them. test.accdb test.mdb - diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..fed528d4 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py index e84fab42..a246781c 100755 --- a/setup.py +++ b/setup.py @@ -19,6 +19,10 @@ OFFICIAL_BUILD = 9999 +# This version identifier should refer to the NEXT release version, not the +# current one. After each release, the version should be incremented. +VERSION = '4.0.35' + def _print(s): # Python 2/3 compatibility @@ -270,6 +274,15 @@ def get_version(): name = None # branch/feature name. Should be None for official builds. numbers = None # The 4 integers that make up the version. + # If we are in the CICD pipeline, use the VERSION, not least because there is no tagging + # information available (Github Actions fetches the repo with the --no-tags and --depth=1 options). + + # All CICD engines (Github Actions / Travis / CircleCI / AppVeyor) set CI to "True"/"true" + if os.getenv('CI', 'false').lower() == 'true': + name = VERSION + numbers = [int(p) for p in VERSION.split('.')] + return name, numbers + # If this is a source release the version will have already been assigned and be in the PKG-INFO file. name, numbers = _get_version_pkginfo() From ebdaf2dab94714fafe0e126b1cc816c67c4ef283 Mon Sep 17 00:00:00 2001 From: Keith Erskine Date: Wed, 9 Nov 2022 18:35:44 -0600 Subject: [PATCH 2/8] broaden env var check --- setup.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index a246781c..c97e8744 100755 --- a/setup.py +++ b/setup.py @@ -277,8 +277,11 @@ def get_version(): # If we are in the CICD pipeline, use the VERSION, not least because there is no tagging # information available (Github Actions fetches the repo with the --no-tags and --depth=1 options). - # All CICD engines (Github Actions / Travis / CircleCI / AppVeyor) set CI to "True"/"true" - if os.getenv('CI', 'false').lower() == 'true': + # All CI providers (Github Actions / Travis / CircleCI / AppVeyor / etc.) set CI to + # "true" (or similar) but just in case, check for the provider directly as well. + if os.getenv('CI', 'false').lower() in ('true', 't', 'yes', 'y', 'on', '1') or \ + 'GITHUB_ACTIONS' in os.environ or \ + 'APPVEYOR' in os.environ: name = VERSION numbers = [int(p) for p in VERSION.split('.')] return name, numbers From 081741e9136aa894545ef5b8b86c608bffc40b4e Mon Sep 17 00:00:00 2001 From: Keith Erskine Date: Wed, 9 Nov 2022 19:30:24 -0600 Subject: [PATCH 3/8] add build verbosity --- .github/workflows/ubuntu_build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ubuntu_build.yml b/.github/workflows/ubuntu_build.yml index b4dc12d8..e3b7b41f 100644 --- a/.github/workflows/ubuntu_build.yml +++ b/.github/workflows/ubuntu_build.yml @@ -225,6 +225,8 @@ jobs: uses: pypa/cibuildwheel@v2.11.2 # https://cibuildwheel.readthedocs.io/en/stable/options/#options-summary env: + CIBW_BUILD_VERBOSITY: 2 + # Windows - both 64-bit and 32-bit builds CIBW_ARCHS_WINDOWS: "AMD64 x86" From e4b0f49714187406c972e8babdd280ae4a40d94a Mon Sep 17 00:00:00 2001 From: Keith Erskine Date: Wed, 9 Nov 2022 19:55:22 -0600 Subject: [PATCH 4/8] test available env vars --- .github/workflows/ubuntu_build.yml | 2 +- setup.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ubuntu_build.yml b/.github/workflows/ubuntu_build.yml index e3b7b41f..33822f94 100644 --- a/.github/workflows/ubuntu_build.yml +++ b/.github/workflows/ubuntu_build.yml @@ -225,7 +225,7 @@ jobs: uses: pypa/cibuildwheel@v2.11.2 # https://cibuildwheel.readthedocs.io/en/stable/options/#options-summary env: - CIBW_BUILD_VERBOSITY: 2 + CIBW_BUILD_VERBOSITY: 1 # Windows - both 64-bit and 32-bit builds CIBW_ARCHS_WINDOWS: "AMD64 x86" diff --git a/setup.py b/setup.py index c97e8744..684aa084 100755 --- a/setup.py +++ b/setup.py @@ -277,6 +277,10 @@ def get_version(): # If we are in the CICD pipeline, use the VERSION, not least because there is no tagging # information available (Github Actions fetches the repo with the --no-tags and --depth=1 options). + _print([{e: os.getenv(e)} for e in ('CI', 'ci', 'GITHUB_ACTIONS')]) + _print([{e: os.getenv(e)} for e in os.environ if e.startswith('CIBW')]) + _print([{e: os.getenv(e)} for e in os.environ if e.startswith('GITHUB')]) + # All CI providers (Github Actions / Travis / CircleCI / AppVeyor / etc.) set CI to # "true" (or similar) but just in case, check for the provider directly as well. if os.getenv('CI', 'false').lower() in ('true', 't', 'yes', 'y', 'on', '1') or \ From a1adefbb13c1e3d1969b4d36910a413ed80f3d4f Mon Sep 17 00:00:00 2001 From: Keith Erskine Date: Wed, 9 Nov 2022 20:03:33 -0600 Subject: [PATCH 5/8] test env vars again --- setup.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 684aa084..836be509 100755 --- a/setup.py +++ b/setup.py @@ -277,9 +277,8 @@ def get_version(): # If we are in the CICD pipeline, use the VERSION, not least because there is no tagging # information available (Github Actions fetches the repo with the --no-tags and --depth=1 options). - _print([{e: os.getenv(e)} for e in ('CI', 'ci', 'GITHUB_ACTIONS')]) - _print([{e: os.getenv(e)} for e in os.environ if e.startswith('CIBW')]) - _print([{e: os.getenv(e)} for e in os.environ if e.startswith('GITHUB')]) + for e in os.environ: + _print(str({e: os.getenv(e)})) # All CI providers (Github Actions / Travis / CircleCI / AppVeyor / etc.) set CI to # "true" (or similar) but just in case, check for the provider directly as well. From cafa37e846e09b36ebf821ac69b6f7d35f423baa Mon Sep 17 00:00:00 2001 From: Keith Erskine Date: Wed, 9 Nov 2022 20:30:23 -0600 Subject: [PATCH 6/8] using CIBUILDWHEEL env var --- .github/workflows/ubuntu_build.yml | 2 -- setup.py | 13 ++++--------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ubuntu_build.yml b/.github/workflows/ubuntu_build.yml index 33822f94..b4dc12d8 100644 --- a/.github/workflows/ubuntu_build.yml +++ b/.github/workflows/ubuntu_build.yml @@ -225,8 +225,6 @@ jobs: uses: pypa/cibuildwheel@v2.11.2 # https://cibuildwheel.readthedocs.io/en/stable/options/#options-summary env: - CIBW_BUILD_VERBOSITY: 1 - # Windows - both 64-bit and 32-bit builds CIBW_ARCHS_WINDOWS: "AMD64 x86" diff --git a/setup.py b/setup.py index 836be509..5183342e 100755 --- a/setup.py +++ b/setup.py @@ -275,16 +275,11 @@ def get_version(): numbers = None # The 4 integers that make up the version. # If we are in the CICD pipeline, use the VERSION, not least because there is no tagging - # information available (Github Actions fetches the repo with the --no-tags and --depth=1 options). + # information available (Github Actions fetches the repo with the options --no-tags and --depth=1). - for e in os.environ: - _print(str({e: os.getenv(e)})) - - # All CI providers (Github Actions / Travis / CircleCI / AppVeyor / etc.) set CI to - # "true" (or similar) but just in case, check for the provider directly as well. - if os.getenv('CI', 'false').lower() in ('true', 't', 'yes', 'y', 'on', '1') or \ - 'GITHUB_ACTIONS' in os.environ or \ - 'APPVEYOR' in os.environ: + # CI providers (Github Actions / Travis / CircleCI / AppVeyor / etc.) usually set CI to "true", but + # in cibuildwheel linux containers, the usual CI env vars are not available, only CIBUILDWHEEL. + if os.getenv('CI', 'false').lower() == 'true' or 'CIBUILDWHEEL' in os.environ: name = VERSION numbers = [int(p) for p in VERSION.split('.')] return name, numbers From 4742e1f168301718b04f09d2069c9853ffa14791 Mon Sep 17 00:00:00 2001 From: Keith Erskine Date: Sat, 12 Nov 2022 11:25:29 -0600 Subject: [PATCH 7/8] linux wheel filenames must be repaired ..or else PyPi will reject them: Binary wheel 'pyodbc-4.0.35-cp36-cp36m-linux_x86_64.whl' has an unsupported platform tag 'linux_x86_64' If repairing, must "exclude" all the .so files from the wheel so they don't interfere with any existing installations. --- .github/workflows/ubuntu_build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ubuntu_build.yml b/.github/workflows/ubuntu_build.yml index b4dc12d8..bfff9254 100644 --- a/.github/workflows/ubuntu_build.yml +++ b/.github/workflows/ubuntu_build.yml @@ -236,8 +236,8 @@ jobs: # https://github.com/pypa/manylinux#docker-images CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 CIBW_ARCHS_LINUX: x86_64 - CIBW_BEFORE_ALL_LINUX: yum -y install unixODBC-devel && odbcinst -j - CIBW_REPAIR_WHEEL_COMMAND_LINUX: "" + CIBW_BEFORE_ALL_LINUX: yum -y install unixODBC-devel + 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*" From c9a6031cab546ca1e0f202d70e77a209865cd531 Mon Sep 17 00:00:00 2001 From: Keith Erskine Date: Sun, 13 Nov 2022 08:11:39 -0600 Subject: [PATCH 8/8] more comments --- .github/workflows/ubuntu_build.yml | 11 ++++++++++- appveyor/test_script.cmd | 1 + setup.py | 8 ++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ubuntu_build.yml b/.github/workflows/ubuntu_build.yml index bfff9254..270afd27 100644 --- a/.github/workflows/ubuntu_build.yml +++ b/.github/workflows/ubuntu_build.yml @@ -230,14 +230,23 @@ jobs: # 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 + # 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 - CIBW_REPAIR_WHEEL_COMMAND_LINUX: "auditwheel repair --exclude libodbc.so.2 --exclude libltdl.so.7 --wheel-dir {dest_dir} {wheel}" + # 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*" diff --git a/appveyor/test_script.cmd b/appveyor/test_script.cmd index 92741d1c..43ce3c0b 100644 --- a/appveyor/test_script.cmd +++ b/appveyor/test_script.cmd @@ -9,6 +9,7 @@ ECHO *** Available ODBC Drivers: REM check if any testing should be done at all IF NOT "%APVYR_RUN_TESTS%" == "true" ( + ECHO. ECHO *** Skipping all the unit tests GOTO :end ) diff --git a/setup.py b/setup.py index 5183342e..312c5069 100755 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ OFFICIAL_BUILD = 9999 -# This version identifier should refer to the NEXT release version, not the +# This version identifier should refer to the NEXT release, not the # current one. After each release, the version should be incremented. VERSION = '4.0.35' @@ -274,10 +274,10 @@ def get_version(): name = None # branch/feature name. Should be None for official builds. numbers = None # The 4 integers that make up the version. - # If we are in the CICD pipeline, use the VERSION, not least because there is no tagging - # information available (Github Actions fetches the repo with the options --no-tags and --depth=1). + # If we are in the CICD pipeline, use the VERSION. There is no tagging information available + # because Github Actions fetches the repo with the options --no-tags and --depth=1. - # CI providers (Github Actions / Travis / CircleCI / AppVeyor / etc.) usually set CI to "true", but + # CI providers (Github Actions / Travis / CircleCI / AppVeyor / etc.) typically set CI to "true", but # in cibuildwheel linux containers, the usual CI env vars are not available, only CIBUILDWHEEL. if os.getenv('CI', 'false').lower() == 'true' or 'CIBUILDWHEEL' in os.environ: name = VERSION