blob: 95bb1c5514c35dccb5edb6f395962001282e21e5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# Maintainer: Chih-Hsuan Yen <yan12125@archlinux.org>
# Contributor: quomoow <quomoow@gmail.com>
pkgname=python-pg8000
# https://raw.githubusercontent.com/tlocke/pg8000/main/README.rst
pkgver=1.31.2
pkgrel=1
_commit=9945228f2cec51727f83058229f59fa7397b4d64
pkgdesc="Pure-Python PostgreSQL database driver, DB-API compatible"
arch=(any)
url='https://github.com/tlocke/pg8000'
# https://github.com/tlocke/pg8000/blob/1.30.4/pyproject.toml#L14
license=('BSD-3-Clause')
makedepends=(git python-build python-installer python-hatchling python-versioningit)
checkdepends=(python-pytest python-pytest-mock python-pytest-benchmark
python-pytz postgresql)
depends=(python python-scramp python-dateutil)
source=("git+https://github.com/tlocke/pg8000.git?signed#commit=$_commit")
sha256sums=('bec9c96595f6f3330e5441782c9687bf0a0c0fcd56eecfa2baef08fa0c1d9cca')
validpgpkeys=(
'D5681B7EC7292511C4CC1450892B00AB699851E8' # Tony Locke <tlocke@tlocke.org.uk>, proven by https://keybase.io/tlocke
)
pkgver() {
cd pg8000
git describe
}
build() {
cd pg8000
python -m build --wheel --no-isolation
}
check() {
cd pg8000
export PGDATA="$srcdir/postgres-testdata"
export PGHOST=127.0.0.1
export PGPORT=$((49152+$RANDOM%10000))
# See https://github.com/tlocke/pg8000#tests about database initialization steps for testing
initdb --username=postgres --auth=trust
openssl req -subj "/CN=self-signed" -nodes -x509 -newkey rsa:4096 -days 1 -keyout "$PGDATA/self-signed.key" -out "$PGDATA/self-signed.crt"
cat <<EOF >> "$PGDATA/postgresql.conf"
ssl = on
ssl_cert_file = 'self-signed.crt'
ssl_key_file = 'self-signed.key'
password_encryption = 'scram-sha-256'
EOF
pg_ctl start -o "-k '' -h $PGHOST -p $PGPORT" -l "$srcdir/postgresql.log"
# Change the password for postgres after password_encryption is specified, so that the role has a valid SCRAM secret
psql -U postgres -c "
CREATE EXTENSION hstore;
ALTER ROLE postgres PASSWORD 'pw';
"
# should overwrite pg_hba.conf, or unexpected matches may happen against existing entries
cat <<EOF > "$PGDATA/pg_hba.conf"
host pg8000_md5 all 127.0.0.1/32 md5
host pg8000_gss all 127.0.0.1/32 gss
host pg8000_password all 127.0.0.1/32 password
host pg8000_scram_sha_256 all 127.0.0.1/32 scram-sha-256
host all all 127.0.0.1/32 trust
EOF
pg_ctl reload
# Upstream tests require LANG=en_GB.UTF-8 or LANG=C.UTF-8 :/
# https://github.com/tlocke/pg8000/blob/1.19.2/test/native/test_typeconversion.py#L455-L458
# test_readme: skipped as many tests need a postgresql instance listening on the default port
# localhost:5432, which may cause conflicts until devtools supports a separate network namespace [1]
# [1] https://gitlab.archlinux.org/archlinux/devtools/-/issues/72
python -m venv --system-site-packages test-env
test-env/bin/python -m installer dist/*.whl
LANG=C.UTF-8 test-env/bin/python -m pytest test -k 'not test_readme'
pg_ctl stop
}
package() {
cd pg8000
python -m installer --destdir="$pkgdir" dist/*.whl
install -Dm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname
}
|