]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
limit greenlet dependency to pypi-listed platforms
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 26 Jul 2021 22:06:41 +0000 (18:06 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 11 Aug 2021 16:53:20 +0000 (12:53 -0400)
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

doc/build/changelog/unreleased_14/6136.rst [new file with mode: 0644]
doc/build/intro.rst
doc/build/orm/extensions/asyncio.rst
lib/sqlalchemy/testing/requirements.py
setup.cfg
test/base/test_concurrency_py3k.py
tox.ini

diff --git a/doc/build/changelog/unreleased_14/6136.rst b/doc/build/changelog/unreleased_14/6136.rst
new file mode 100644 (file)
index 0000000..de3b2fe
--- /dev/null
@@ -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
index 8b2135b7d556c64d2f16166de79145c78be494a2..01e33df0346927408061438913af6dc8e0836ba6 100644 (file)
@@ -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 <https://pypi.org/project/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
 -------------------------------
 
index 4509ee350e0b4e924f0a817b0631d9a783e3bb8b..c5fc356d1205beda1c7162a3a0385559633944ce 100644 (file)
@@ -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 <https://pypi.org/project/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
 ---------------
 
index 702a40fe29dd35adaefe090e49d097b134950909..4fa701b10e33fab4edc56bba10b8f7eed6b7d709 100644 (file)
@@ -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"
index 846b7284891188d703d4985fa17edb9e3a9fa71b..cc204072dd3f1b182b24baf3e13375be6a4d1082 100644 (file)
--- 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 =
index 45a0eb90e1ba3c2fe65199c1bb5c418a4ee719d6..0b648aa30bdd8ba741351db57ba9f92a1fead99e 100644 (file)
@@ -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 6c77ab95c864b9cb0eb51538ff9311c4e0b73fbc..5df14fe67c6e5829b6f0597579f499952cf3d3b8 100644 (file)
--- 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]