summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Bakke <marius@gnu.org>2022-01-21 20:55:53 +0100
committerMarius Bakke <marius@gnu.org>2022-01-22 10:23:00 +0100
commit5ec4129907e9f122265ffe5891530fc2e4326e27 (patch)
tree93642b20d6a474a5d68da402e6525d5dad90de4d
parent84bcda58fc2d92f81088eb6f096609e209c94d4b (diff)
downloadguix-patches-5ec4129907e9f122265ffe5891530fc2e4326e27.tar
guix-patches-5ec4129907e9f122265ffe5891530fc2e4326e27.tar.gz
gnu: Add python-psycopg.
* gnu/packages/databases.scm (python-psycopg): New variable.
-rw-r--r--gnu/packages/databases.scm75
1 files changed, 75 insertions, 0 deletions
diff --git a/gnu/packages/databases.scm b/gnu/packages/databases.scm
index 0e0007ef65..4986451d59 100644
--- a/gnu/packages/databases.scm
+++ b/gnu/packages/databases.scm
@@ -115,6 +115,7 @@
#:use-module (gnu packages maths)
#:use-module (gnu packages multiprecision)
#:use-module (gnu packages ncurses)
+ #:use-module (gnu packages networking)
#:use-module (gnu packages onc-rpc)
#:use-module (gnu packages pantheon)
#:use-module (gnu packages parallel)
@@ -3466,6 +3467,80 @@ designed to be easy and intuitive to use.")
with the @code{psycopg} PostgreSQL driver.")
(license license:lgpl3+)))
+(define-public python-psycopg
+ (package
+ (name "python-psycopg")
+ (version "3.0.8")
+ (source (origin
+ ;; Fetch from git because PyPI contains only cythonized sources.
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/psycopg/psycopg")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "16i19jqd9lg9r7bc63ssh527cccrpf49g1nlayikk5qlswpzp75y"))))
+ (build-system python-build-system)
+ (arguments
+ (list #:phases
+ #~(modify-phases %standard-phases
+ (add-before 'build 'change-directory
+ (lambda _
+ (chdir "psycopg")))
+ (add-after 'build 'build-c-extensions
+ (lambda _
+ (with-directory-excursion "../psycopg_c"
+ ((assoc-ref %standard-phases 'build)))))
+ (add-after 'install 'install-c-extensions
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ ;; For some reason setup.py refuses to install if the
+ ;; installation directory is not on PYTHONPATH.
+ (setenv "PYTHONPATH" (site-packages inputs outputs))
+ (with-directory-excursion "../psycopg_c"
+ ((assoc-ref %standard-phases 'install)
+ #:inputs inputs
+ #:outputs outputs))))
+ (add-before 'check 'start-postgresql
+ (lambda _
+ (let ((dbdir (string-append (getcwd) "/../pgdir")))
+ (invoke "initdb" "-D" dbdir)
+ (invoke "pg_ctl" "-D" dbdir
+ "-o" (string-append "-k " dbdir)
+ "-l" (string-append dbdir "/db.log")
+ "start")
+
+ (invoke "psql" "-h" dbdir "-d" "postgres"
+ "-c" "CREATE DATABASE nixbld;"))))
+ (replace 'check
+ (lambda* (#:key inputs tests? #:allow-other-keys)
+ (when tests?
+ (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"))))))))
+ (native-inputs
+ (list python-cython-3
+ python-mypy
+ python-psycopg-pool
+ python-pytest
+ python-pytest-asyncio
+ python-tenacity
+ pproxy
+ tzdata-for-tests))
+ (inputs
+ (list postgresql))
+ (home-page "https://www.psycopg.org/")
+ (synopsis "PostgreSQL driver for Python")
+ (description
+ "Psycopg 3 is a new implementation of the popular @code{psycopg2}
+database adapter for Python.")
+ (license license:lgpl3+)))
+
(define-public python-sadisplay
(package
(name "python-sadisplay")