summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2023-03-30 17:12:15 +0200
committerMichał Górny <mgorny@gentoo.org>2023-03-30 17:41:23 +0200
commit046013556bccd396ceb57127b701e2be195c36d2 (patch)
tree9f74af09a5f2365ac488438e962a8da8347ffad1 /dev-python
parentpackage.mask: Mask broken dev-util/spirv-llvm-translator-16.0.0 (diff)
downloadgentoo-046013556bccd396ceb57127b701e2be195c36d2.tar.gz
gentoo-046013556bccd396ceb57127b701e2be195c36d2.tar.bz2
gentoo-046013556bccd396ceb57127b701e2be195c36d2.zip
dev-python/django: Backport py3.11 fixes to 3.2.18-r1
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'dev-python')
-rw-r--r--dev-python/django/django-3.2.18-r1.ebuild110
-rw-r--r--dev-python/django/files/django-3.2.18-py311.patch153
2 files changed, 263 insertions, 0 deletions
diff --git a/dev-python/django/django-3.2.18-r1.ebuild b/dev-python/django/django-3.2.18-r1.ebuild
new file mode 100644
index 000000000000..bc404dde5670
--- /dev/null
+++ b/dev-python/django/django-3.2.18-r1.ebuild
@@ -0,0 +1,110 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DISTUTILS_USE_PEP517=setuptools
+PYTHON_COMPAT=( python3_{9..11} )
+PYTHON_REQ_USE='sqlite?,threads(+)'
+
+inherit bash-completion-r1 distutils-r1 optfeature verify-sig
+
+DESCRIPTION="High-level Python web framework"
+HOMEPAGE="
+ https://www.djangoproject.com/
+ https://github.com/django/django/
+ https://pypi.org/project/Django/
+"
+SRC_URI="
+ https://media.djangoproject.com/releases/$(ver_cut 1-2)/${P^}.tar.gz
+ verify-sig? ( https://media.djangoproject.com/pgp/${P^}.checksum.txt )
+"
+S="${WORKDIR}/${P^}"
+
+LICENSE="BSD"
+# admin fonts: Roboto (media-fonts/roboto)
+LICENSE+=" Apache-2.0"
+# admin icons, jquery, xregexp.js
+LICENSE+=" MIT"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~riscv ~sparc ~x86 ~x64-macos"
+IUSE="doc sqlite test"
+RESTRICT="!test? ( test )"
+
+RDEPEND="
+ >=dev-python/asgiref-3.3.4[${PYTHON_USEDEP}]
+ dev-python/pytz[${PYTHON_USEDEP}]
+ >=dev-python/sqlparse-0.2.2[${PYTHON_USEDEP}]
+"
+BDEPEND="
+ test? (
+ $(python_gen_impl_dep sqlite)
+ ${RDEPEND}
+ dev-python/docutils[${PYTHON_USEDEP}]
+ dev-python/jinja[${PYTHON_USEDEP}]
+ dev-python/numpy[${PYTHON_USEDEP}]
+ dev-python/pillow[webp,${PYTHON_USEDEP}]
+ dev-python/pyyaml[${PYTHON_USEDEP}]
+ dev-python/selenium[${PYTHON_USEDEP}]
+ dev-python/tblib[${PYTHON_USEDEP}]
+ sys-devel/gettext
+ !!<dev-python/ipython-7.21.0-r1
+ !!=dev-python/ipython-7.22.0-r0
+ )
+ verify-sig? ( >=sec-keys/openpgp-keys-django-20201201 )
+"
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-3.1-bashcomp.patch
+ "${FILESDIR}"/django-3.2.18-py311.patch
+)
+
+distutils_enable_sphinx docs --no-autodoc
+
+VERIFY_SIG_OPENPGP_KEY_PATH=${BROOT}/usr/share/openpgp-keys/django.asc
+
+src_unpack() {
+ if use verify-sig; then
+ cd "${DISTDIR}" || die
+ verify-sig_verify_signed_checksums \
+ "${P^}.checksum.txt" sha256 "${P^}.tar.gz"
+ cd "${WORKDIR}" || die
+ fi
+
+ default
+}
+
+python_prepare_all() {
+ # Fails because of warnings
+ sed -i 's/test_dumpdata_proxy_with_concrete/_&/' tests/fixtures/tests.py || die
+ # TODO: this suddenly started failing
+ sed -i -e 's:test_custom_fields:_&:' tests/inspectdb/tests.py || die
+
+ distutils-r1_python_prepare_all
+}
+
+python_test() {
+ # Tests have non-standard assumptions about PYTHONPATH,
+ # and don't work with ${BUILD_DIR}/lib.
+ PYTHONPATH=. "${EPYTHON}" tests/runtests.py --settings=test_sqlite -v2 ||
+ die "Tests fail with ${EPYTHON}"
+}
+
+python_install_all() {
+ newbashcomp extras/django_bash_completion ${PN}-admin
+ bashcomp_alias ${PN}-admin django-admin.py
+
+ distutils-r1_python_install_all
+}
+
+pkg_postinst() {
+ optfeature_header "Additional Backend support can be enabled via:"
+ optfeature "MySQL backend support" dev-python/mysqlclient
+ optfeature "PostgreSQL backend support" dev-python/psycopg:2
+ optfeature_header
+ optfeature "GEO Django" "sci-libs/gdal[geos]"
+ optfeature "Memcached support" dev-python/pylibmc dev-python/python-memcached
+ optfeature "ImageField Support" dev-python/pillow
+ optfeature "Password encryption" dev-python/bcrypt
+ optfeature "High-level abstractions for Django forms" dev-python/django-formtools
+}
diff --git a/dev-python/django/files/django-3.2.18-py311.patch b/dev-python/django/files/django-3.2.18-py311.patch
new file mode 100644
index 000000000000..2cebb8cc817b
--- /dev/null
+++ b/dev-python/django/files/django-3.2.18-py311.patch
@@ -0,0 +1,153 @@
+From 2882cf6f184c7578219e2b5266623e82c0e9b8a2 Mon Sep 17 00:00:00 2001
+From: Mariusz Felisiak <felisiak.mariusz@gmail.com>
+Date: Thu, 7 Apr 2022 07:02:21 +0200
+Subject: [PATCH] Refs #33173 -- Fixed test_runner/test_utils tests on Python
+ 3.11+.
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Python 3.11 uses fully qualified test name in unittest output. See
+https://github.com/python/cpython/commit/755be9b1505af591b9f2ee424a6525b6c2b65ce9
+
+(rebased by Michał Górny)
+---
+ django/utils/version.py | 1 +
+ tests/test_runner/test_debug_sql.py | 30 ++++++++++++++++++-----------
+ tests/test_runner/test_parallel.py | 11 ++++++++---
+ tests/test_utils/tests.py | 9 +++++++--
+ 4 files changed, 35 insertions(+), 16 deletions(-)
+
+diff --git a/django/utils/version.py b/django/utils/version.py
+index 74c327525e..0c2bfc626e 100644
+--- a/django/utils/version.py
++++ b/django/utils/version.py
+@@ -15,6 +15,7 @@ PY37 = sys.version_info >= (3, 7)
+ PY38 = sys.version_info >= (3, 8)
+ PY39 = sys.version_info >= (3, 9)
+ PY310 = sys.version_info >= (3, 10)
++PY311 = sys.version_info >= (3, 11)
+
+
+ def get_version(version=None):
+diff --git a/tests/test_runner/test_debug_sql.py b/tests/test_runner/test_debug_sql.py
+index 0e8e4207d6..2b5fed7a76 100644
+--- a/tests/test_runner/test_debug_sql.py
++++ b/tests/test_runner/test_debug_sql.py
+@@ -4,6 +4,7 @@ from io import StringIO
+ from django.db import connection
+ from django.test import TestCase
+ from django.test.runner import DiscoverRunner
++from django.utils.version import PY311
+
+ from .models import Person
+
+@@ -100,20 +101,27 @@ class TestDebugSQL(unittest.TestCase):
+ '''"test_runner_person"."first_name" = 'subtest-fail';'''),
+ ]
+
++ # Python 3.11 uses fully qualified test name in the output.
++ method_name = ".runTest" if PY311 else ""
++ test_class_path = "test_runner.test_debug_sql.TestDebugSQL"
+ verbose_expected_outputs = [
+- 'runTest (test_runner.test_debug_sql.TestDebugSQL.FailingTest) ... FAIL',
+- 'runTest (test_runner.test_debug_sql.TestDebugSQL.ErrorTest) ... ERROR',
+- 'runTest (test_runner.test_debug_sql.TestDebugSQL.PassingTest) ... ok',
++ f"runTest ({test_class_path}.FailingTest{method_name}) ... FAIL",
++ f"runTest ({test_class_path}.ErrorTest{method_name}) ... ERROR",
++ f"runTest ({test_class_path}.PassingTest{method_name}) ... ok",
+ # If there are errors/failures in subtests but not in test itself,
+ # the status is not written. That behavior comes from Python.
+- 'runTest (test_runner.test_debug_sql.TestDebugSQL.FailingSubTest) ...',
+- 'runTest (test_runner.test_debug_sql.TestDebugSQL.ErrorSubTest) ...',
+- ('''SELECT COUNT(*) AS "__count" '''
+- '''FROM "test_runner_person" WHERE '''
+- '''"test_runner_person"."first_name" = 'pass';'''),
+- ('''SELECT COUNT(*) AS "__count" '''
+- '''FROM "test_runner_person" WHERE '''
+- '''"test_runner_person"."first_name" = 'subtest-pass';'''),
++ f"runTest ({test_class_path}.FailingSubTest{method_name}) ...",
++ f"runTest ({test_class_path}.ErrorSubTest{method_name}) ...",
++ (
++ """SELECT COUNT(*) AS "__count" """
++ """FROM "test_runner_person" WHERE """
++ """"test_runner_person"."first_name" = 'pass';"""
++ ),
++ (
++ """SELECT COUNT(*) AS "__count" """
++ """FROM "test_runner_person" WHERE """
++ """"test_runner_person"."first_name" = 'subtest-pass';"""
++ ),
+ ]
+
+ def test_setupclass_exception(self):
+diff --git a/tests/test_runner/test_parallel.py b/tests/test_runner/test_parallel.py
+index c1a89bd0f0..0f1adcf208 100644
+--- a/tests/test_runner/test_parallel.py
++++ b/tests/test_runner/test_parallel.py
+@@ -2,7 +2,7 @@ import unittest
+
+ from django.test import SimpleTestCase
+ from django.test.runner import RemoteTestResult
+-from django.utils.version import PY37
++from django.utils.version import PY37, PY311
+
+ try:
+ import tblib
+@@ -78,8 +78,13 @@ class RemoteTestResultTest(SimpleTestCase):
+ self.assertEqual(len(events), 4)
+
+ event = events[1]
+- self.assertEqual(event[0], 'addSubTest')
+- self.assertEqual(str(event[2]), 'dummy_test (test_runner.test_parallel.SampleFailingSubtest) (index=0)')
++ self.assertEqual(event[0], "addSubTest")
++ self.assertEqual(
++ str(event[2]),
++ "dummy_test (test_runner.test_parallel.SampleFailingSubtest%s) (index=0)"
++ # Python 3.11 uses fully qualified test name in the output.
++ % (".dummy_test" if PY311 else ""),
++ )
+ trailing_comma = '' if PY37 else ','
+ self.assertEqual(repr(event[3][1]), "AssertionError('0 != 1'%s)" % trailing_comma)
+
+diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py
+index 9255315e98..8f72057afe 100644
+--- a/tests/test_utils/tests.py
++++ b/tests/test_utils/tests.py
+@@ -26,6 +26,7 @@ from django.test.utils import (
+ )
+ from django.urls import NoReverseMatch, path, reverse, reverse_lazy
+ from django.utils.deprecation import RemovedInDjango41Warning
++from django.utils.version import PY311
+
+ from .models import Car, Person, PossessedCar
+ from .views import empty_response
+@@ -78,9 +79,11 @@ class SkippingTestCase(SimpleTestCase):
+ SkipTestCase('test_foo').test_foo,
+ ValueError,
+ "skipUnlessDBFeature cannot be used on test_foo (test_utils.tests."
+- "SkippingTestCase.test_skip_unless_db_feature.<locals>.SkipTestCase) "
++ "SkippingTestCase.test_skip_unless_db_feature.<locals>.SkipTestCase%s) "
+ "as SkippingTestCase.test_skip_unless_db_feature.<locals>.SkipTestCase "
+ "doesn't allow queries against the 'default' database."
++ # Python 3.11 uses fully qualified test name in the output.
++ % (".test_foo" if PY311 else ""),
+ )
+
+ def test_skip_if_db_feature(self):
+@@ -122,9 +125,11 @@ class SkippingTestCase(SimpleTestCase):
+ SkipTestCase('test_foo').test_foo,
+ ValueError,
+ "skipIfDBFeature cannot be used on test_foo (test_utils.tests."
+- "SkippingTestCase.test_skip_if_db_feature.<locals>.SkipTestCase) "
++ "SkippingTestCase.test_skip_if_db_feature.<locals>.SkipTestCase%s) "
+ "as SkippingTestCase.test_skip_if_db_feature.<locals>.SkipTestCase "
+ "doesn't allow queries against the 'default' database."
++ # Python 3.11 uses fully qualified test name in the output.
++ % (".test_foo" if PY311 else ""),
+ )
+
+
+--
+2.40.0
+