diff --git a/.gitignore b/.gitignore index 2c019b0..9ee2a81 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /databases-0.5.1.tar.gz /databases-0.5.2.tar.gz /databases-0.5.3.tar.gz +/databases-0.5.5.tar.gz diff --git a/databases-0.5.5-pr-470.patch b/databases-0.5.5-pr-470.patch new file mode 100644 index 0000000..249e8c3 --- /dev/null +++ b/databases-0.5.5-pr-470.patch @@ -0,0 +1,12 @@ +diff -Naur databases-0.5.5-original/setup.py databases-0.5.5/setup.py +--- databases-0.5.5-original/setup.py 2022-01-20 16:14:37.000000000 -0500 ++++ databases-0.5.5/setup.py 2022-03-03 10:50:57.176276169 -0500 +@@ -47,7 +47,7 @@ + author_email="tom@tomchristie.com", + packages=get_packages("databases"), + package_data={"databases": ["py.typed"]}, +- install_requires=["sqlalchemy>=1.4,<1.5", 'aiocontextvars;python_version<"3.7"'], ++ install_requires=["sqlalchemy[asyncio]>=1.4,<1.5", 'aiocontextvars;python_version<"3.7"'], + extras_require={ + "postgresql": ["asyncpg"], + "mysql": ["aiomysql"], diff --git a/python-databases.spec b/python-databases.spec index 05ce846..00a9907 100644 --- a/python-databases.spec +++ b/python-databases.spec @@ -1,17 +1,27 @@ -%global forgeurl https://github.com/encode/databases - # When bootstrapping, break circular dependency on starlette in the tests. %bcond_with bootstrap +# MySQL tests require interacting with a temporary MySQL database. We are able +# to do this, but leave a build conditional in case it breaks. +%bcond_without mysql_tests + Name: python-databases Summary: Async database support for Python -Version: 0.5.3 +Version: 0.5.5 Release: %autorelease License: BSD URL: https://www.encode.io/databases/ +%global forgeurl https://github.com/encode/databases Source0: %{forgeurl}/archive/%{version}/databases-%{version}.tar.gz +# Dependency on sqlalchemy should include asyncio extra +# https://github.com/encode/databases/issues/469 +# Depend on sqlalchemy[asyncio] instead of just sqlalchemy +# https://github.com/encode/databases/pull/470 +# (rebased to 0.5.5) +Patch0: databases-0.5.5-pr-470.patch + BuildArch: noarch BuildRequires: python3-devel @@ -33,11 +43,10 @@ BuildRequires: python3dist(starlette) # Used only as a soft dependency of starlette BuildRequires: python3dist(requests) %endif -# Work around RHBZ#2012590, in which python3-sqlalchemy fails to depend on -# python3-greenlet on some architectures, by adding a direct dependency. -BuildRequires: python3dist(greenlet) -Obsoletes: python-databases-doc < 0.5.2-4 +%if %{with mysql_tests} +BuildRequires: mariadb-server +%endif %global common_description %{expand: Databases gives you simple asyncio support for a range of databases. @@ -77,23 +86,25 @@ Recommends: python3dist(psycopg2) %description -n python3-databases+postgresql This is a metapackage bringing in postgresql extras requires for -python3-databases. -It makes sure the dependencies are installed. +python3-databases. It makes sure the dependencies are installed. %files -n python3-databases+postgresql -f %{_pyproject_ghost_distinfo} -%package -n python3-databases+mysql -Summary: Metapackage for python3-databases: mysql extras +%package -n python3-databases+mysql_asyncmy +Summary: Metapackage for python3-databases: mysql_asyncmy extras Recommends: python3dist(pymysql) Requires: python3-databases = %{version}-%{release} +# pymysql tests only work with pymysql<=1.0 +# https://github.com/encode/databases/issues/330 +Obsoletes: python3-databases+mysql < 0.5.5-1 -%description -n python3-databases+mysql -This is a metapackage bringing in mysql extras requires for python3-databases. -It makes sure the dependencies are installed. +%description -n python3-databases+mysql_asyncmy +This is a metapackage bringing in mysql_asyncmy extras requires for +python3-databases. It makes sure the dependencies are installed. -%files -n python3-databases+mysql -f %{_pyproject_ghost_distinfo} +%files -n python3-databases+mysql_asyncmy -f %{_pyproject_ghost_distinfo} %package -n python3-databases+postgresql_aiopg @@ -104,8 +115,7 @@ Recommends: python3dist(psycopg2) %description -n python3-databases+postgresql_aiopg This is a metapackage bringing in postgresql_aiopg extras requires for -python3-databases. -It makes sure the dependencies are installed. +python3-databases. It makes sure the dependencies are installed. %files -n python3-databases+postgresql_aiopg -f %{_pyproject_ghost_distinfo} @@ -113,33 +123,17 @@ It makes sure the dependencies are installed. %package -n python3-databases Summary: %{summary} -# Work around RHBZ#2012590, in which python3-sqlalchemy fails to depend on -# python3-greenlet on some architectures, by adding a direct dependency. -Requires: python3dist(greenlet) +Obsoletes: python-databases-doc < 0.5.2-4 %description -n python3-databases %{common_description} %prep -%autosetup -n databases-%{version} -# The following is equivalent to the former patch file -# databases-0.4.3-wayward-license-file.patch, but the sed expression works -# regardless of whether databases-pr-299-40c41c2b.patch has affected nearby -# lines or not. -# -# Without this patch, the LICENSE.md file is installed under the prefix -# (generally, /usr/local or /usr), or when installed into a virtualenv, in the -# root of the virtualenv directory. Neither is correct. -# -# Upstream doesn’t want bug reports or PR’s in general -# (https://github.com/encode/.github/blob/ -# e018bb630a92efd4609c2b60955e9c4678cd6c11/CONTRIBUTING.md), -# so I raised the issue in the Gitter chat on 2021-04-26. -sed -i -r '/data_files=\[\("", \["LICENSE.md"\]\)\],/d' setup.py +%autosetup -n databases-%{version} -p1 %generate_buildrequires -%pyproject_buildrequires -x postgresql,mysql,sqlite,postgresql_aiopg +%pyproject_buildrequires -x postgresql,mysql_asyncmy,sqlite,postgresql_aiopg %build @@ -164,7 +158,62 @@ touch tests/__init__.py # user. The following environment variable is a comma-separated list. export TEST_DATABASE_URLS="sqlite:///testsuite, sqlite+aiosqlite:///testsuite" -%pytest +%if %{with mysql_tests} +# Based on rubygem-mysql2 packaging; see also python-asyncmy + +# Use a randomized port in case the standard mysqld port 3306 is occupied, and +# to account for multiple simultaneous builds on the same host. +# https://src.fedoraproject.org/rpms/rubygem-pg/pull-request/3 +MYSQL_PORT="$((13306 + ${RANDOM} % 1000))" +MYSQL_USER="$(whoami)" +MYSQL_DATA_DIR="${PWD}/data" +MYSQL_SOCKET="${PWD}/mysql.sock" +MYSQL_LOG="${PWD}/mysql.log" +MYSQL_PID_FILE="${PWD}/mysql.pid" + +mkdir "${MYSQL_DATA_DIR}" +mysql_install_db --datadir="${MYSQL_DATA_DIR}" --log-error="${MYSQL_LOG}" + +%{_libexecdir}/mysqld --port="${MYSQL_PORT}" --ssl \ + --datadir="${MYSQL_DATA_DIR}" --log-error="${MYSQL_LOG}" \ + --socket="${MYSQL_SOCKET}" --pid-file="${MYSQL_PID_FILE}" & : + +echo "Waiting for server… ${i}" 1>&2 +TIMEOUT=30 +while ! grep -q 'ready for connections.' "${MYSQL_LOG}" +do + sleep 1 + TIMEOUT=$((TIMEOUT - 1)) + if [[ "${TIMEOUT}" = '0' ]] + then + echo 'Timed out' 1>&2 + exit 1 + fi +done + +echo 'Ready' 1>&2 +trap "kill $(cat "${MYSQL_PID_FILE}")" INT TERM EXIT + +# See https://github.com/brianmario/mysql2/blob/master/.travis_setup.sh +mysql -u "${MYSQL_USER}" -S "${MYSQL_SOCKET}" -P "${MYSQL_PORT}" \ + -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';" +mysql -u 'root' --password='123456' \ + --protocol='TCP' -h 'localhost' -P "${MYSQL_PORT}" \ + -e 'CREATE DATABASE testsuite;' + +for url in \ + "mysql://root:123456@localhost:${MYSQL_PORT}/testsuite" \ + "mysql+asyncmy://root:123456@localhost:${MYSQL_PORT}/testsuite" +do + export TEST_DATABASE_URLS="${TEST_DATABASE_URLS}, ${url}" +done +%endif + +%pytest --verbose + +# Since we can’t test all backends, at least do an import “smoke test,” but +# note that the “mysql” extra/backend is not supported, so we must exclude it. +%pyproject_check_import -e 'databases.backends.mysql' %files -n python3-databases -f %{pyproject_files} diff --git a/sources b/sources index 2de5dfc..7e7e663 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (databases-0.5.3.tar.gz) = bd0c4f1bf0f81e017ea55e41a6d4821ee17e0f995b600a50955fba68841443147dd234534b9c72d753b99785a5a08ac6e3d839894ec4760c602372cccbd4c1c0 +SHA512 (databases-0.5.5.tar.gz) = 6a7ecd47d594a9404fa4216913819a8be777090254185ef8b970251ef9bf11452a16d22311fd19f63f4788bf45f6f8831c99ca31bcaacd6c40884fad4a250fd0