Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/pymysql/
Date: Thu, 07 Jan 2021 09:16:19
Message-Id: 1610010964.38c97b264cec88015d30f14f944ceb47d646164e.mgorny@gentoo
1 commit: 38c97b264cec88015d30f14f944ceb47d646164e
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Thu Jan 7 08:45:58 2021 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Thu Jan 7 09:16:04 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=38c97b26
7
8 dev-python/pymysql: Bump to 1.0.0
9
10 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
11
12 dev-python/pymysql/Manifest | 1 +
13 dev-python/pymysql/pymysql-1.0.0.ebuild | 144 ++++++++++++++++++++++++++++++++
14 2 files changed, 145 insertions(+)
15
16 diff --git a/dev-python/pymysql/Manifest b/dev-python/pymysql/Manifest
17 index 8ff259cd603..f72aad94927 100644
18 --- a/dev-python/pymysql/Manifest
19 +++ b/dev-python/pymysql/Manifest
20 @@ -1 +1,2 @@
21 DIST pymysql-0.10.1.tar.gz 86441 BLAKE2B 8e33fbba0544dad68c3eeb5bd538c4bce121222b4660ad06c3c0224b5db6a6c9f45d6697a98d5f0ba20429afa204d46c9ce57a4d9696dbc2a35649c6253a645b SHA512 edc702c54a33350f75648765c60d4cf455449e88818948b018585d557bea280e626d23b1279a410765f2de8e35b3c22ea5c8e0ef3dc72588b674c93a2124a224
22 +DIST pymysql-1.0.0.tar.gz 85033 BLAKE2B 792b472c2a230e823cca9deed5adc03a004e34b09594d998c1df332769b93dde3f0b84a11f1b1ac83b6be34fe661194d3c780d6a5bb0facf193d2f46a807a7b8 SHA512 52c4ad45f31725bcbb313d4d1bea52bb52c82ad9573a58dd8cca14e844ff9d7e3831debb3bd08d00a07cc32625b15692138947ccd9ad3bed7f869a7bd69357b3
23
24 diff --git a/dev-python/pymysql/pymysql-1.0.0.ebuild b/dev-python/pymysql/pymysql-1.0.0.ebuild
25 new file mode 100644
26 index 00000000000..6bd9ec18f00
27 --- /dev/null
28 +++ b/dev-python/pymysql/pymysql-1.0.0.ebuild
29 @@ -0,0 +1,144 @@
30 +# Copyright 1999-2021 Gentoo Authors
31 +# Distributed under the terms of the GNU General Public License v2
32 +
33 +EAPI=7
34 +
35 +PYTHON_COMPAT=( python3_{6..9} pypy3 )
36 +
37 +inherit distutils-r1
38 +
39 +MY_PN="PyMySQL"
40 +MY_P="${MY_PN}-${PV}"
41 +
42 +DESCRIPTION="Pure-Python MySQL Driver"
43 +HOMEPAGE="https://github.com/PyMySQL/PyMySQL"
44 +SRC_URI="https://github.com/${MY_PN}/${MY_PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
45 +S=${WORKDIR}/${MY_P}
46 +
47 +LICENSE="MIT"
48 +SLOT="0"
49 +KEYWORDS="~amd64 ~arm ~arm64 ~x86"
50 +
51 +# TODO: support other mysql variants
52 +BDEPEND="
53 + test? (
54 + dev-db/mariadb[server]
55 + dev-python/mock[${PYTHON_USEDEP}]
56 + )"
57 +
58 +distutils_enable_tests pytest
59 +
60 +src_prepare() {
61 + # Auth tests don't support socket auth
62 + find tests/ -name '*_auth.py' -delete || die
63 +
64 + distutils-r1_src_prepare
65 +}
66 +
67 +src_test() {
68 + if [[ -z "${USER}" ]] ; then
69 + # Tests require system user
70 + local -x USER="$(whoami)"
71 + einfo "USER set to '${USER}'"
72 + fi
73 +
74 + local PIDFILE="${T}/mysqld.pid"
75 + if pkill -0 -F "${PIDFILE}" &>/dev/null ; then
76 + einfo "Killing already running mysqld process ..."
77 + pkill -F "${PIDFILE}"
78 + fi
79 +
80 + if [[ -d "${T}/mysql" ]] ; then
81 + einfo "Removing already existing mysqld data dir ..."
82 + rm -rf "${T}/mysql" || die
83 + fi
84 +
85 + einfo "Creating mysql test instance ..."
86 + mkdir -p "${T}"/mysql || die
87 + "${BROOT}"/usr/share/mariadb/scripts/mysql_install_db \
88 + --no-defaults \
89 + --auth-root-authentication-method=normal \
90 + --basedir="${BROOT}/usr" \
91 + --datadir="${T}"/mysql 1>"${T}"/mysqld_install.log \
92 + || die
93 +
94 + einfo "Starting mysql test instance ..."
95 + # TODO: random port
96 + mysqld \
97 + --no-defaults \
98 + --character-set-server=utf8 \
99 + --bind-address=127.0.0.1 \
100 + --port=43306 \
101 + --pid-file="${T}"/mysqld.pid \
102 + --socket="${T}"/mysqld.sock \
103 + --datadir="${T}"/mysql 1>"${T}"/mysqld.log 2>&1 &
104 +
105 + # wait for it to start
106 + local i
107 + for (( i = 0; i < 10; i++)); do
108 + [[ -S ${T}/mysqld.sock ]] && break
109 + sleep 1
110 + done
111 + [[ -S ${T}/mysqld.sock ]] || die "mysqld failed to start"
112 +
113 + einfo "Configuring test mysql instance ..."
114 +
115 + # create test user for auth tests
116 + mysql -uroot --socket="${T}"/mysqld.sock -s -e '
117 + INSTALL SONAME "auth_ed25519";
118 + CREATE FUNCTION ed25519_password RETURNS STRING SONAME "auth_ed25519.so";
119 + ' || die "Failed to set up auth_ed25519"
120 +
121 + mysql -uroot --socket="${T}"/mysqld.sock -s -e "
122 + SELECT CONCAT('CREATE USER nopass_ed25519 IDENTIFIED VIA ed25519 USING \"',ed25519_password(\"\"),'\";');
123 + SELECT CONCAT('CREATE USER user_ed25519 IDENTIFIED VIA ed25519 USING \"',ed25519_password(\"pass_ed25519\"),'\";');
124 + " || die "Failed to create ed25519 test users"
125 +
126 + # create test databases
127 + mysql -uroot --socket="${T}"/mysqld.sock -s -e '
128 + create database test1 DEFAULT CHARACTER SET utf8mb4;
129 + create database test2 DEFAULT CHARACTER SET utf8mb4;
130 +
131 + create user test2 identified by "some password";
132 + grant all on test2.* to test2;
133 +
134 + create user test2@localhost identified by "some password";
135 + grant all on test2.* to test2@localhost;
136 + ' || die "Failed to create test databases"
137 +
138 + cat > pymysql/tests/databases.json <<-EOF || die
139 + [{
140 + "host": "localhost",
141 + "user": "root",
142 + "password": "",
143 + "database": "test1",
144 + "use_unicode": true,
145 + "local_infile": true,
146 + "unix_socket": "${T}/mysqld.sock"
147 + }, {
148 + "host": "localhost",
149 + "user": "root",
150 + "password": "",
151 + "database": "test2",
152 + "unix_socket": "${T}/mysqld.sock"
153 + }]
154 + EOF
155 +
156 + distutils-r1_src_test
157 +
158 + if pkill -0 -F "${PIDFILE}" &>/dev/null ; then
159 + einfo "Stopping mysql test instance ..."
160 + pkill -F "${PIDFILE}"
161 + fi
162 +}
163 +
164 +python_test() {
165 + local excludes=(
166 + # requires some dialog plugin
167 + pymysql/tests/test_connection.py::TestAuthentication::testDialogAuthThreeAttemptsQuestionsInstallPlugin
168 + pymysql/tests/test_connection.py::TestAuthentication::testDialogAuthTwoQuestionsInstallPlugin
169 + )
170 +
171 + PYTHONPATH=. pytest -vv ${excludes[@]/#/--deselect } ||
172 + die "Tests failed with ${EPYTHON}"
173 +}