From: Mike Bayer Date: Mon, 26 Jul 2021 22:06:41 +0000 (-0400) Subject: limit greenlet dependency to pypi-listed platforms X-Git-Tag: rel_1_4_23~12^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=214c6d6fc4b90f8f62996dfdbdfa80216d9b0a2f;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git limit greenlet dependency to pypi-listed platforms The setup requirements have been modified such ``greenlet`` is a default requirement only for those platforms that are well known for ``greenlet`` to be installable and for which there is already a pre-built binary on pypi; the current list is ``x86_64 aarch64 ppc64le amd64 win32``. For other platforms, greenlet will not install by default, which should enable installation and test suite running of SQLAlchemy 1.4 on platforms that don't support ``greenlet``, excluding any asyncio features. In order to install with the ``greenlet`` dependency included on a machine architecture outside of the above list, the ``[asyncio]`` extra may be included by running ``pip install sqlalchemy[asyncio]`` which will then attempt to install ``greenlet``. Additionally, the test suite has been repaired so that tests can complete fully when greenlet is not installed, with appropriate skips for asyncio-related tests. Fixes: #6136 Change-Id: I8f3a1c00a4a8b6a273484af1da1f7aaadf588ae7 --- diff --git a/doc/build/changelog/unreleased_14/6136.rst b/doc/build/changelog/unreleased_14/6136.rst new file mode 100644 index 0000000000..de3b2feb1e --- /dev/null +++ b/doc/build/changelog/unreleased_14/6136.rst @@ -0,0 +1,19 @@ +.. change:: + :tags: bug, general + :tickets: 6136 + + The setup requirements have been modified such ``greenlet`` is a default + requirement only for those platforms that are well known for ``greenlet`` + to be installable and for which there is already a pre-built binary on + pypi; the current list is ``x86_64 aarch64 ppc64le amd64 win32``. For other + platforms, greenlet will not install by default, which should enable + installation and test suite running of SQLAlchemy 1.4 on platforms that + don't support ``greenlet``, excluding any asyncio features. In order to + install with the ``greenlet`` dependency included on a machine architecture + outside of the above list, the ``[asyncio]`` extra may be included by + running ``pip install sqlalchemy[asyncio]`` which will then attempt to + install ``greenlet``. + + Additionally, the test suite has been repaired so that tests can complete + fully when greenlet is not installed, with appropriate skips for + asyncio-related tests. \ No newline at end of file diff --git a/doc/build/intro.rst b/doc/build/intro.rst index 8b2135b7d5..01e33df034 100644 --- a/doc/build/intro.rst +++ b/doc/build/intro.rst @@ -109,6 +109,16 @@ SQLAlchemy has been tested against the following platforms: :ref:`change_5634` +AsyncIO Support +---------------- + +SQLAlchemy's ``asyncio`` support depends upon the +`greenlet `_ project. This dependency +will be installed by default on common machine platforms, however is not +supported on every architecture and also may not install by default on +less common architectures. See the section :ref:`asyncio_install` for +additional details on ensuring asyncio support is present. + Supported Installation Methods ------------------------------- diff --git a/doc/build/orm/extensions/asyncio.rst b/doc/build/orm/extensions/asyncio.rst index 4509ee350e..c5fc356d12 100644 --- a/doc/build/orm/extensions/asyncio.rst +++ b/doc/build/orm/extensions/asyncio.rst @@ -8,14 +8,11 @@ included, using asyncio-compatible dialects. .. versionadded:: 1.4 -The asyncio extension requires at least Python version 3.6. - .. note:: The asyncio extension as of SQLAlchemy 1.4.3 can now be considered to be **beta level** software. API details are subject to change however at this point it is unlikely for there to be significant backwards-incompatible changes. - .. seealso:: :ref:`change_3414` - initial feature announcement @@ -23,6 +20,25 @@ The asyncio extension requires at least Python version 3.6. :ref:`examples_asyncio` - example scripts illustrating working examples of Core and ORM use within the asyncio extension. +.. _asyncio_install: + +Asyncio Platform Installation Notes +------------------------------------ + +The asyncio extension requires at least Python version 3.6. It also depends +upon the `greenlet `_ library. This +dependency is installed by default on common machine platforms including:: + + x86_64 aarch64 ppc64le amd64 win32 + +For the above platforms, ``greenlet`` is known to supply pre-built wheel files. +To ensure the ``greenlet`` dependency is present on other platforms, the +``[asyncio]`` extra may be installed as follows, which will include an attempt +to build and install ``greenlet``:: + + pip install sqlalchemy[asyncio] + + Synopsis - Core --------------- diff --git a/lib/sqlalchemy/testing/requirements.py b/lib/sqlalchemy/testing/requirements.py index 702a40fe29..4fa701b10e 100644 --- a/lib/sqlalchemy/testing/requirements.py +++ b/lib/sqlalchemy/testing/requirements.py @@ -1319,6 +1319,18 @@ class SuiteRequirements(Requirements): return exclusions.closed() + @property + def greenlet(self): + def go(config): + try: + import greenlet # noqa F401 + except ImportError: + return False + else: + return True + + return exclusions.only_if(go) + @property def computed_columns(self): "Supports computed columns" diff --git a/setup.cfg b/setup.cfg index 846b728489..cc204072dd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -40,7 +40,7 @@ package_dir = install_requires = importlib-metadata;python_version<"3.8" - greenlet != 0.4.17;python_version>="3" + greenlet != 0.4.17;python_version>="3" and platform_machine in 'x86_64 aarch64 ppc64le amd64 win32' [options.extras_require] asyncio = diff --git a/test/base/test_concurrency_py3k.py b/test/base/test_concurrency_py3k.py index 45a0eb90e1..0b648aa30b 100644 --- a/test/base/test_concurrency_py3k.py +++ b/test/base/test_concurrency_py3k.py @@ -33,6 +33,8 @@ def go(*fns): class TestAsyncioCompat(fixtures.TestBase): + __requires__ = ("greenlet",) + @async_test async def test_ok(self): @@ -186,7 +188,7 @@ class TestAsyncioCompat(fixtures.TestBase): class TestAsyncAdaptedQueue(fixtures.TestBase): # uses asyncio.run() in alternate threads which is not available # in Python 3.6 - __requires__ = ("python37",) + __requires__ = ("python37", "greenlet") def test_lazy_init(self): run = [False] diff --git a/tox.ini b/tox.ini index 6c77ab95c8..5df14fe67c 100644 --- a/tox.ini +++ b/tox.ini @@ -19,9 +19,7 @@ deps= pytest>=4.6.11,<5.0; python_version < '3' pytest>=6.2; python_version >= '3' pytest-xdist - greenlet != 0.4.17 mock; python_version < '3.3' - importlib_metadata; python_version < '3.8' sqlite: .[aiosqlite] sqlite_file: .[aiosqlite]