]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Improved wheel pipeline
authorFederico Caselli <cfederico87@gmail.com>
Wed, 15 Mar 2023 20:49:13 +0000 (21:49 +0100)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 17 Mar 2023 13:43:57 +0000 (09:43 -0400)
- ensure that the compiled extensions are used
- speed up job by parallelizing more

Fixes: #9434
Change-Id: Ief750b28733ba24bb5ff8c105e1a4c9b7b928700

.github/workflows/create-wheels.yaml
lib/sqlalchemy/testing/plugin/pytestplugin.py
lib/sqlalchemy/util/_has_cy.py
pyproject.toml

index cc312dd93109488482336bd6f3187968052d0903..4c871ba62d618479d587da45305cb493b3994238 100644 (file)
@@ -4,32 +4,47 @@ on:
   # run when a release has been created
   release:
     types: [created]
+  # push:
+  #   branches:
+  #     - "go_wheel_*"
 
 # env:
-  # comment TWINE_REPOSITORY_URL to use the real pypi. NOTE: change also the secret used in TWINE_PASSWORD
-  # TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
+  # comment TWINE_REPOSITORY_URL to use the real pypi. NOTE: change also the secret used in TWINE_PASSWORD
+#   TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
 
 jobs:
   build_wheels:
-    name: Build ${{ matrix.wheel_mode }} wheels on ${{ matrix.os }} ${{ matrix.linux_archs }}
+    name: ${{ matrix.wheel_mode }} wheels ${{ matrix.python }} on ${{ matrix.os }} ${{ matrix.os == 'ubuntu-22.04' && matrix.linux_archs || '' }}
     runs-on: ${{ matrix.os }}
     strategy:
       matrix:
+        # emulated wheels on linux take too much time, split wheels into multiple runs
+        python:
+          - "cp37-* cp38-*"
+          - "cp39-* cp310-*"
+          - "cp311-*"
+        wheel_mode:
+          - compiled
+        os:
+          - "windows-2022"
+          - "macos-12"
+          - "ubuntu-22.04"
+        linux_archs:
+          # this is only meaningful on linux. windows and macos ignore exclude all but one arch
+          - "aarch64"
+          - "x86_64"
+
         include:
-          - os: windows-2022
-            wheel_mode: compiled
-          - os: macos-12
-            wheel_mode: compiled
-          # emulated wheels on linux take too much time, so run two jobs
-          - os: ubuntu-22.04
-            wheel_mode: compiled
-            linux_archs: "x86_64"
-          - os: ubuntu-22.04
-            wheel_mode: compiled
-            linux_archs: "aarch64"
           # create pure python build
           - os: ubuntu-22.04
             wheel_mode: pure-python
+            python: "cp-311*"
+
+        exclude:
+          - os: "windows-2022"
+            linux_archs: "aarch64"
+          - os: "macos-12"
+            linux_archs: "aarch64"
 
       fail-fast: false
 
@@ -61,6 +76,9 @@ jobs:
         uses: pypa/cibuildwheel@v2.12.1
         env:
           CIBW_ARCHS_LINUX: ${{ matrix.linux_archs }}
+          CIBW_BUILD: ${{ matrix.python }}
+          # setting it here does not work on linux
+          # PYTHONNOUSERSITE: "1"
 
 
       - name: Set up Python for twine and pure-python wheel
index d590ecbe439e3d86204f24a34340717b11c21108..b5d2485524408841d03f6d0a4ef64d057f32d463 100644 (file)
@@ -10,6 +10,7 @@ import itertools
 import operator
 import os
 import re
+import sys
 import uuid
 
 import pytest
@@ -123,9 +124,42 @@ def collect_types_fixture():
         collect_types.stop()
 
 
+def _log_sqlalchemy_info(session):
+    import sqlalchemy
+    from sqlalchemy import __version__
+    from sqlalchemy.util import has_compiled_ext
+    from sqlalchemy.util._has_cy import _CYEXTENSION_MSG
+
+    greet = "sqlalchemy installation"
+    site = "no user site" if sys.flags.no_user_site else "user site loaded"
+    msgs = [
+        f"SQLAlchemy {__version__} ({site})",
+        f"Path: {sqlalchemy.__file__}",
+    ]
+
+    if has_compiled_ext():
+        from sqlalchemy.cyextension import util
+
+        msgs.append(f"compiled extension enabled, e.g. {util.__file__} ")
+    else:
+        msgs.append(f"compiled extension not enabled; {_CYEXTENSION_MSG}")
+
+    pm = session.config.pluginmanager.get_plugin("terminalreporter")
+    if pm:
+        pm.write_sep("=", greet)
+        for m in msgs:
+            pm.write_line(m)
+    else:
+        # fancy pants reporter not found, fallback to plain print
+        print("=" * 25, greet, "=" * 25)
+        for m in msgs:
+            print(m)
+
+
 def pytest_sessionstart(session):
     from sqlalchemy.testing import asyncio
 
+    _log_sqlalchemy_info(session)
     asyncio._assume_async(plugin_base.post_begin)
 
 
index 1fe8cbe6a22ad4e5985f9632c18bc0e669352819..37f716ad3b90cfc982e673984a0a98caf302e932 100644 (file)
@@ -21,15 +21,19 @@ def _import_cy_extensions():
     return (collections, immutabledict, processors, resultproxy, util)
 
 
+_CYEXTENSION_MSG: str
 if not typing.TYPE_CHECKING:
     if os.environ.get("DISABLE_SQLALCHEMY_CEXT_RUNTIME"):
         HAS_CYEXTENSION = False
+        _CYEXTENSION_MSG = "DISABLE_SQLALCHEMY_CEXT_RUNTIME is set"
     else:
         try:
             _import_cy_extensions()
-        except ImportError:
+        except ImportError as err:
             HAS_CYEXTENSION = False
+            _CYEXTENSION_MSG = str(err)
         else:
+            _CYEXTENSION_MSG = "Loaded"
             HAS_CYEXTENSION = True
 else:
     HAS_CYEXTENSION = False
index ecf030a42c43c28ed19cf95c670f410cf03377db..ae4c1fb136be5767240c0a23964bf34b40e421cc 100644 (file)
@@ -70,7 +70,8 @@ strict = true
 
 [tool.cibuildwheel]
 test-requires = "pytest pytest-xdist"
-test-command = "pytest -c {project}/pyproject.toml -n2 -q --nomemory --notimingintensive --nomypy {project}/test"
+# remove user site, otherwise the local checkout has precedence, disabling cyextensions
+test-command = "python -s -m pytest -c {project}/pyproject.toml -n2 -q --nomemory --notimingintensive --nomypy {project}/test"
 
 build = "*"
 # python 3.6 is no longer supported by sqlalchemy