gnu: python-psycopg: Update to 3.2.4.

* gnu/packages/databases.scm (python-psycopg): Update to 3.2.4.
[build-system]: Use pyproject-build-system.
[arguments]: Simplify phases; restore 'sanity-check.
[native-inputs]: Add python-setuptools and python-wheel.

Change-Id: Iec2949c7e01e0dff2893181c3a49e8e3a3319446
This commit is contained in:
Ricardo Wurmus 2025-01-17 10:42:04 +01:00
parent 0ffc5b3afb
commit 0e028beceb
No known key found for this signature in database
GPG key ID: 197A5888235FACAC

View file

@ -4366,7 +4366,7 @@ with the @code{psycopg} PostgreSQL driver.")
(define-public python-psycopg (define-public python-psycopg
(package (package
(name "python-psycopg") (name "python-psycopg")
(version "3.1.10") (version "3.2.4")
(source (origin (source (origin
;; Fetch from git because PyPI contains only cythonized sources. ;; Fetch from git because PyPI contains only cythonized sources.
(method git-fetch) (method git-fetch)
@ -4376,54 +4376,41 @@ with the @code{psycopg} PostgreSQL driver.")
(file-name (git-file-name name version)) (file-name (git-file-name name version))
(sha256 (sha256
(base32 (base32
"0hqk45wlaflz69cy1r0hbv11bwb89p6hjb7zmgqas26gdhg37n0r")))) "0fb83fhaa3saapqv37901hlv017bj40q0dmkxd79aaq442sjf9w2"))))
(build-system python-build-system) (build-system pyproject-build-system)
(arguments (arguments
(list #:phases (list
#~(modify-phases %standard-phases #:test-flags
(add-before 'build 'change-directory '(list "-o" "asyncio_mode=auto"
(lambda _ ;; FIXME: Many of the typing tests are failing,
(chdir "psycopg"))) ;; conveniently tagged as slow...
(add-after 'build 'build-c-extensions "-k" "not slow" "..")
(lambda _ #:phases
(with-directory-excursion "../psycopg_c" #~(modify-phases %standard-phases
((assoc-ref %standard-phases 'build))))) (add-before 'build 'change-directory
(add-after 'install 'install-c-extensions (lambda _ (chdir "psycopg")))
(lambda* (#:key inputs outputs #:allow-other-keys) (add-after 'build 'build-c-extensions
;; For some reason setup.py refuses to install if the (lambda _
;; installation directory is not on PYTHONPATH. (with-directory-excursion "../psycopg_c"
(setenv "PYTHONPATH" (site-packages inputs outputs)) ((assoc-ref %standard-phases 'build)))))
(with-directory-excursion "../psycopg_c" (add-after 'install 'install-c-extensions
((assoc-ref %standard-phases 'install) (lambda* (#:key inputs outputs #:allow-other-keys)
#:inputs inputs (with-directory-excursion "../psycopg_c"
#:outputs outputs)))) ((assoc-ref %standard-phases 'install)
(add-before 'check 'start-postgresql #:inputs inputs #:outputs outputs))))
(lambda _ (add-before 'check 'start-postgresql
(let ((dbdir (string-append (getcwd) "/../pgdir"))) (lambda* (#:key inputs tests? #:allow-other-keys)
(invoke "initdb" "-D" dbdir) (when tests?
(invoke "pg_ctl" "-D" dbdir (setenv "TZDIR" (search-input-directory inputs
"-o" (string-append "-k " dbdir) "share/zoneinfo"))
"-l" (string-append dbdir "/db.log") (let ((dbdir (string-append (getcwd) "/../pgdir")))
"start") (invoke "initdb" "-D" dbdir)
(invoke "pg_ctl" "-D" dbdir
(invoke "psql" "-h" dbdir "-d" "postgres" "-o" (string-append "-k " dbdir)
"-c" "CREATE DATABASE nixbld;")))) "-l" (string-append dbdir "/db.log")
(replace 'check "start")
(lambda* (#:key inputs tests? #:allow-other-keys) (invoke "psql" "-h" dbdir "-d" "postgres"
(when tests? "-c" "CREATE DATABASE nixbld;"))))))))
(setenv "TZDIR" (search-input-directory inputs
"share/zoneinfo"))
(with-directory-excursion ".."
(invoke "pytest" "-vv"
"-o" "asyncio_mode=auto"
;; FIXME: Many of the typing tests are failing,
;; conveniently tagged as slow...
"-k" "not slow")))))
;; The sanity check phase attempts loading the C extension
;; before the Python library, which results in the following:
;; <ImportError: the psycopg package should be imported
;; before psycopg_c>.
(delete 'sanity-check))))
(native-inputs (native-inputs
(list python-cython-3 (list python-cython-3
python-mypy python-mypy
@ -4431,7 +4418,9 @@ with the @code{psycopg} PostgreSQL driver.")
python-pytest python-pytest
python-pytest-asyncio python-pytest-asyncio
python-anyio python-anyio
python-setuptools
python-tenacity python-tenacity
python-wheel
pproxy pproxy
tzdata-for-tests)) tzdata-for-tests))
(inputs (inputs