From: Daniele Varrazzo Date: Mon, 11 May 2020 06:35:58 +0000 (+1200) Subject: Test both the c and the python implementation on tox X-Git-Tag: 3.0.dev0~528 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e35b028b5c160fdc041b56ba67d5544a03cc3848;p=thirdparty%2Fpsycopg.git Test both the c and the python implementation on tox --- diff --git a/.travis.yml b/.travis.yml index 89e1e5642..a23c2b4dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/setup.py b/setup.py index 81020776a..0bc13ac6d 100644 --- 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 80d9b1e13..6239af810 100644 --- 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]