]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Test both the c and the python implementation on tox
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 11 May 2020 06:35:58 +0000 (18:35 +1200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 17 May 2020 09:29:34 +0000 (21:29 +1200)
.travis.yml
setup.py
tox.ini

index 89e1e56424acbd5ac7718b548886f76f75a6e6a1..a23c2b4dd54f8864c537903c6105e1362d35856c 100644 (file)
@@ -26,8 +26,9 @@ matrix:
             - postgresql-client-9.5
       env:
         - TOXENV=py36
-        - PGPORT=5432
         - PGVER=9.5
+        - PSYCOPG3_IMPL=c
+        - PGPORT=5432
 
     - python: 3.6
       addons:
@@ -37,8 +38,9 @@ matrix:
             - postgresql-client-9.6
       env:
         - TOXENV=py36
-        - PGPORT=5432
         - PGVER=9.6
+        - PSYCOPG3_IMPL=ctypes
+        - PGPORT=5432
 
     - python: 3.7
       addons:
@@ -48,10 +50,11 @@ matrix:
             - postgresql-client-10
       env:
         - TOXENV=py37
-        - PGPORT=5432
         - PGVER=10
+        - PSYCOPG3_IMPL=c
+        - PGPORT=5432
 
-    - python: 3.8
+    - python: 3.7
       addons:
         postgresql: '11'
         apt:
@@ -59,9 +62,10 @@ matrix:
             - postgresql-11
             - postgresql-client-11
       env:
-        - TOXENV=py38
-        - PGPORT=5433
+        - TOXENV=py37
         - PGVER=11
+        - PSYCOPG3_IMPL=ctypes
+        - PGPORT=5433
 
     - python: 3.8
       addons:
@@ -72,8 +76,22 @@ matrix:
             - postgresql-client-12
       env:
         - TOXENV=py38
+        - PGVER=12
+        - PSYCOPG3_IMPL=c
         - PGPORT=5433
+
+    - python: 3.8
+      addons:
+        postgresql: '12'
+        apt:
+          packages:
+            - postgresql-12
+            - postgresql-client-12
+      env:
+        - TOXENV=py38
         - PGVER=12
+        - PSYCOPG3_IMPL=ctypes
+        - PGPORT=5433
 
 install:
   - pip install tox
index 81020776a0c68f5f553c81b797b763fd4ccd8e57..0bc13ac6ddc75a5d0c76e9a7b2bbd59116a6ca8c 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -44,15 +44,15 @@ Topic :: Software Development :: Libraries :: Python Modules
 """
 
 
-class our_build_ext(build_ext):
+class psycopg3_build_ext(build_ext):
     def finalize_options(self) -> None:
         self._setup_ext_build()
         super().finalize_options()
 
-    def run(self) -> None:
-        super().run()
-
     def _setup_ext_build(self) -> None:
+        # Clear the dummy so if we can't build it's no drama
+        self.distribution.ext_modules = None
+
         try:
             from Cython.Build import cythonize
         except ImportError:
@@ -109,5 +109,7 @@ setup(
         "Issue Tracker": "https://github.com/psycopg/psycopg3/issues",
         "Download": "https://pypi.org/project/psycopg3/",
     },
-    cmdclass={"build_ext": our_build_ext},
+    cmdclass={"build_ext": psycopg3_build_ext},
+    # hack to run build_ext. It will be replaced by real the stuff
+    ext_modules=[Extension("psycopg3.dummy", ["dummy.c"])],
 )
diff --git a/tox.ini b/tox.ini
index 80d9b1e1374b498839b10c2578f9702337bfa49f..6239af8105caa5c794f28c43933b89c177d8c4fc 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -2,8 +2,14 @@
 envlist = py{36,37,38}, black, flake8, mypy
 
 [testenv]
-commands = pytest {posargs}
-passenv = PG* PSYCOPG3_TEST_DSN PYTEST_ADDOPTS
+# run setup.py develop to build the c extension in place.
+# if this doesn't happen, psycopg3 will be imported from the root directory
+# anyway rather than from the tox environment, because pytest adds the
+# root dir to the pythonpath. It sucks but I don't see a way around.
+commands =
+    python setup.py develop
+    pytest {posargs}
+passenv = PG* PSYCOPG3_TEST_DSN PYTEST_ADDOPTS PSYCOPG3_IMPL
 deps = pytest >= 5.3,<6
 
 [testenv:black]