linux: # {{{
runs-on: ubuntu-20.04
+ env:
+ LIBPQ_VERSION: "14.3"
+ OPENSSL_VERSION: "1.1.1o"
+
strategy:
fail-fast: false
matrix:
uses: actions/cache@v3
with:
path: /tmp/libpq.build
- key: libpq-14.3-${{ matrix.platform }}-${{ matrix.arch }}-1
+ key: libpq-${{ env.LIBPQ_VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}-1
- name: Create the binary package source tree
run: python3 ./tools/build/copy_to_binary.py
CIBW_TEST_REQUIRES: ./psycopg[test] ./psycopg_pool
CIBW_TEST_COMMAND: >-
pytest {project}/tests -m 'not slow and not flakey' --color yes
+ CIBW_ENVIRONMENT_PASS_LINUX: LIBPQ_VERSION OPENSSL_VERSION
CIBW_ENVIRONMENT: >-
PSYCOPG_IMPL=binary
PSYCOPG_TEST_DSN='host=172.17.0.1 user=postgres'
LIBPQ_BUILD_PREFIX=/host/tmp/libpq.build
PATH="$LIBPQ_BUILD_PREFIX/bin:$PATH"
LD_LIBRARY_PATH="$LIBPQ_BUILD_PREFIX/lib"
+ PSYCOPG_TEST_WANT_LIBPQ_BUILD=${{ env.LIBPQ_VERSION }}
+ PSYCOPG_TEST_WANT_LIBPQ_IMPORT=${{ env.LIBPQ_VERSION }}
- uses: actions/upload-artifact@v2
with:
CIBW_ENVIRONMENT: >-
PSYCOPG_IMPL=binary
PSYCOPG_TEST_DSN='dbname=postgres'
+ PSYCOPG_TEST_WANT_LIBPQ_BUILD=">= 14"
+ PSYCOPG_TEST_WANT_LIBPQ_IMPORT=">= 14"
- uses: actions/upload-artifact@v2
with:
PSYCOPG_IMPL=binary
PATH="C:\\Program Files\\PostgreSQL\\14\\bin;$PATH"
PSYCOPG_TEST_DSN="host=127.0.0.1 user=postgres"
+ PSYCOPG_TEST_WANT_LIBPQ_BUILD=">= 14"
+ PSYCOPG_TEST_WANT_LIBPQ_IMPORT=">= 14"
- uses: actions/upload-artifact@v2
with:
-python -bb -m pytest {posargs}
-python -bb -m pytest --lf --lfnf=none --no-collect-ok --randomly-seed=last {posargs}
python -bb -m pytest --lf --lfnf=none --no-collect-ok --randomly-seed=last {posargs}
-passenv = PG* PSYCOPG_TEST_DSN PYTEST_ADDOPTS PSYCOPG_IMPL PIP_CONSTRAINT
+passenv = PG* PSYCOPG_TEST_* PYTEST_ADDOPTS PSYCOPG_IMPL PIP_CONSTRAINT
extras = test
deps =
-e {toxinidir}/../psycopg_pool
-python -bb -m pytest {posargs}
-python -bb -m pytest --lf --lfnf=none --no-collect-ok --randomly-seed=last {posargs}
python -bb -m pytest --lf --lfnf=none --no-collect-ok --randomly-seed=last {posargs}
-passenv = PG* PSYCOPG_TEST_DSN PYTEST_ADDOPTS PSYCOPG_IMPL PIP_CONSTRAINT
+passenv = PG* PSYCOPG_TEST_* PYTEST_ADDOPTS PSYCOPG_IMPL PIP_CONSTRAINT
deps =
-e {toxinidir}/../psycopg[test]
-e {toxinidir}/../psycopg_pool
+import os
+
+import pytest
+
import psycopg
from psycopg import pq
+from ..utils import check_libpq_version
+
def test_version():
rv = pq.version()
assert False, f"unexpected libpq implementation: {pq.__impl__}"
+@pytest.mark.skipif("not os.environ.get('PSYCOPG_TEST_WANT_LIBPQ_BUILD')")
+def test_want_built_version():
+ want = os.environ["PSYCOPG_TEST_WANT_LIBPQ_BUILD"]
+ got = pq.__build_version__
+ assert not check_libpq_version(got, want)
+
+
+@pytest.mark.skipif("not os.environ.get('PSYCOPG_TEST_WANT_LIBPQ_IMPORT')")
+def test_want_import_version():
+ want = os.environ["PSYCOPG_TEST_WANT_LIBPQ_IMPORT"]
+ got = pq.version()
+ assert not check_libpq_version(got, want)
+
+
def test_pipeline_supported():
# Note: This test is here because pipeline tests are skipped on libpq < 14
if pq.__impl__ == "python":
def _check_version(got, want, whose_version):
+ """Check that a postgres-style version matches a desired spec.
+
+ - The postgres-style version is a number such as 90603 for 9.6.3.
+ - The want version is a spec string such as "> 9.6"
+ """
# convert 90603 to (9, 6, 3), 120003 to (12, 3)
got, got_fix = divmod(got, 100)
got_maj, got_min = divmod(got, 100)
got = (got_maj, got_min, got_fix)
# Parse a spec like "> 9.6"
- m = re.match(r"^\s*(>=|<=|>|<)\s*(?:(\d+)(?:\.(\d+)(?:\.(\d+))?)?)?\s*$", want)
+ m = re.match(
+ r"^\s*(>=|<=|>|<|==)?\s*(?:(\d+)(?:\.(\d+)(?:\.(\d+))?)?)?\s*$",
+ want,
+ )
if m is None:
pytest.fail(f"bad wanted version spec: {want}")
else:
want = (want_maj, want_min, want_fix)
- op = getattr(operator, {">=": "ge", "<=": "le", ">": "gt", "<": "lt"}[m.group(1)])
+ opnames = {">=": "ge", "<=": "le", ">": "gt", "<": "lt", "==": "eq"}
+ op = getattr(operator, opnames[m.group(1) or "=="])
if not op(got, want):
- revops = {">=": "<", "<=": ">", ">": "<=", "<": ">="}
+ revops = {">=": "<", "<=": ">", ">": "<=", "<": ">=", "==": "!="}
return (
- f"skipping test: {whose_version} version is {'.'.join(map(str, got))}"
+ f"{whose_version} version is {'.'.join(map(str, got))}"
f" {revops[m.group(1)]} {'.'.join(map(str, want))}"
)
set -euo pipefail
set -x
+# Last release: https://www.postgresql.org/ftp/source/
# IMPORTANT! Change the cache key in packages.yml when upgrading libraries
-postgres_version="14.3"
-openssl_version="1.1.1o"
+postgres_version="${LIBPQ_VERSION:-14.3}"
+
+# last release: https://www.openssl.org/source/
+openssl_version="${OPENSSL_VERSION:-1.1.1o}"
+
+# last release: https://openldap.org/software/download/
ldap_version="2.6.2"
+
+# last release: https://github.com/cyrusimap/cyrus-sasl/releases
sasl_version="2.1.28"
export LIBPQ_BUILD_PREFIX=${LIBPQ_BUILD_PREFIX:-/tmp/libpq.build}