From: Federico Caselli Date: Wed, 15 Mar 2023 20:49:13 +0000 (+0100) Subject: Improved wheel pipeline X-Git-Tag: rel_2_0_7~4^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1a5f0c0be11fa30296f20a1742807a57e2ff5459;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Improved wheel pipeline - ensure that the compiled extensions are used - speed up job by parallelizing more Fixes: #9434 Change-Id: Ief750b28733ba24bb5ff8c105e1a4c9b7b928700 --- diff --git a/.github/workflows/create-wheels.yaml b/.github/workflows/create-wheels.yaml index cc312dd931..4c871ba62d 100644 --- a/.github/workflows/create-wheels.yaml +++ b/.github/workflows/create-wheels.yaml @@ -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 diff --git a/lib/sqlalchemy/testing/plugin/pytestplugin.py b/lib/sqlalchemy/testing/plugin/pytestplugin.py index d590ecbe43..b5d2485524 100644 --- a/lib/sqlalchemy/testing/plugin/pytestplugin.py +++ b/lib/sqlalchemy/testing/plugin/pytestplugin.py @@ -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) diff --git a/lib/sqlalchemy/util/_has_cy.py b/lib/sqlalchemy/util/_has_cy.py index 1fe8cbe6a2..37f716ad3b 100644 --- a/lib/sqlalchemy/util/_has_cy.py +++ b/lib/sqlalchemy/util/_has_cy.py @@ -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 diff --git a/pyproject.toml b/pyproject.toml index ecf030a42c..ae4c1fb136 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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