diff options
| author | Pattems <patrick@crandol.com> | 2026-12-01 10:04:53 +0000 |
|---|---|---|
| committer | Kai Knoblich <kai@FreeBSD.org> | 2026-12-01 10:10:59 +0000 |
| commit | 62fff813767f9e95cf759460ee3affc286e23f65 (patch) (diff) | |
| tree | 278ba68c215006c8dbccd77e0a5af2c81255f0b5 /www/py-django-bitfield | |
| download | ports-2026Q4.tar.gz | |
| previous commit | 70b0c428bcec9ebb56c6cd3b0956aa7b1bcdd3ae (net-mgmt/py-netutils: Update to 1.19.3) | |
www/py-django-bitfield: Update to 2.4.0
HEAD2026Q4
* bitfield/types.py registers its PostgreSQL adapters through
Database.extensions, which only psycopg2 has. Django's postgresql
backend uses psycopg 3 when it is installed, so "import bitfield"
fails with AttributeError: module 'psycopg' has no attribute
'extensions'. Keep the psycopg2 path and register int dumpers for
Bit and BitHandler with psycopg 3 otherwise; 2.4.0 still has the
psycopg2-only code.
* Since Django 5.0 FieldListFilter.used_parameters holds lists, so the
admin changelist fails with TypeError in BitHandler as soon as the
bitfield filter is used. Take the last value, as Django's own
filters do; 2.4.0 has the same code.
* Switch to the PEP517 build framework to make the port future-proof.
While here, add concurrent to USE_PYTHON, expand pkg-descr and switch
to the more preferred DISTVERSION.
PR: 300115
MFH: 2026Q4
With hat python
Co-Authored-By: Kai Knoblich <kai@FreeBSD.org>
(cherry picked from commit 1c4d5aeabf8003916ef1c578bcf7dc8e371ed4f6)
Diffstat (limited to 'www/py-django-bitfield') [Complete diffstat for commit ]
| -rw-r--r-- | www/py-django-bitfield/Makefile | [diff] [file] | 11 | ||||
| -rw-r--r-- | www/py-django-bitfield/distinfo | [diff] [file] | 6 | ||||
| -rw-r--r-- | www/py-django-bitfield/files/patch-bitfield_admin.py | [diff] [file] | 21 | ||||
| -rw-r--r-- | www/py-django-bitfield/files/patch-bitfield_types.py | [diff] [file] | 38 | ||||
| -rw-r--r-- | www/py-django-bitfield/pkg-descr | [diff] [file] | 8 |
5 files changed, 75 insertions, 9 deletions
diff --git a/www/py-django-bitfield/Makefile b/www/py-django-bitfield/Makefile index 1ae1b564c36a..839a40b232b8 100644 --- a/www/py-django-bitfield/Makefile +++ b/www/py-django-bitfield/Makefile @@ -1,9 +1,9 @@ PORTNAME= django-bitfield -PORTVERSION= 2.2.0 -PORTREVISION= 3 +DISTVERSION= 2.4.0 CATEGORIES= www python MASTER_SITES= PYPI PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} +DISTNAME= ${PORTNAME:S/-/_/}-${DISTVERSION} MAINTAINER= python@FreeBSD.org COMMENT= BitField in Django @@ -12,11 +12,12 @@ WWW= https://github.com/disqus/django-bitfield LICENSE= APACHE20 LICENSE_FILE= ${WRKSRC}/LICENSE -RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}django52>=1.11.29:www/py-django52@${PY_FLAVOR} \ - ${PYTHON_PKGNAMEPREFIX}six>=0:devel/py-six@${PY_FLAVOR} +BUILD_DEPENDS= ${PYTHON_PKGNAMEPREFIX}setuptools>=0:devel/py-setuptools@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}wheel>=0:devel/py-wheel@${PY_FLAVOR} +RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}django52>=1.11.29:www/py-django52@${PY_FLAVOR} USES= python -USE_PYTHON= autoplist distutils +USE_PYTHON= autoplist concurrent pep517 NO_ARCH= yes diff --git a/www/py-django-bitfield/distinfo b/www/py-django-bitfield/distinfo index 63986c64982a..d60bda95d0cf 100644 --- a/www/py-django-bitfield/distinfo +++ b/www/py-django-bitfield/distinfo @@ -1,3 +1,3 @@ -TIMESTAMP = 1657719124 -SHA256 (django-bitfield-2.2.0.tar.gz) = 1b21262acc4ec0af3f82ed04498a056cd9d5452532ac02771e004835a34e0b1b -SIZE (django-bitfield-2.2.0.tar.gz) = 17365 +TIMESTAMP = 1792185495 +SHA256 (django_bitfield-2.4.0.tar.gz) = 64449791a5d84aaca02fe83f35a0641fd7e22f35bd46e95a3e4b7ed995235888 +SIZE (django_bitfield-2.4.0.tar.gz) = 14856 diff --git a/www/py-django-bitfield/files/patch-bitfield_admin.py b/www/py-django-bitfield/files/patch-bitfield_admin.py new file mode 100644 index 000000000000..99de24f2fc28 --- /dev/null +++ b/www/py-django-bitfield/files/patch-bitfield_admin.py @@ -0,0 +1,21 @@ +Description: Since Django 5.0 the values of FieldListFilter.used_parameters + are lists, so BitFieldListFilter.queryset() passed a list to BitHandler + and the admin changelist failed with TypeError once the filter was used. + Take the last value, as Django's own filters do. +Issue ID: https://github.com/disqus/django-bitfield/pull/140 +Changeset: none +TODO: Drop once a release includes the fix. + +--- bitfield/admin.py.orig 2026-01-19 20:10:21 UTC ++++ bitfield/admin.py +@@ -26,8 +26,9 @@ class BitFieldListFilter(FieldListFilter + field, request, params, model, model_admin, field_path) + + def queryset(self, request, queryset): ++ # Since Django 5.0 the values of used_parameters are lists + filter_kwargs = dict( +- (p, BitHandler(v, ())) ++ (p, BitHandler(v[-1] if isinstance(v, list) else v, ())) + for p, v in self.used_parameters.items() + ) + if not filter_kwargs: diff --git a/www/py-django-bitfield/files/patch-bitfield_types.py b/www/py-django-bitfield/files/patch-bitfield_types.py new file mode 100644 index 000000000000..79384d03e4fd --- /dev/null +++ b/www/py-django-bitfield/files/patch-bitfield_types.py @@ -0,0 +1,38 @@ +Description: Register int dumpers for Bit and BitHandler with psycopg 3, + keeping the psycopg2 path. +Issue ID: https://github.com/disqus/django-bitfield/pull/139 +Changeset: none +TODO: Drop once a release includes the fix. + +--- bitfield/types.py.orig 2026-01-19 20:10:21 UTC ++++ bitfield/types.py +@@ -253,7 +253,27 @@ except ImproperlyConfigured: + + try: + from django.db.backends.postgresql.base import Database +- Database.extensions.register_adapter(Bit, lambda x: Database.extensions.AsIs(int(x))) +- Database.extensions.register_adapter(BitHandler, lambda x: Database.extensions.AsIs(int(x))) ++ if hasattr(Database, 'extensions'): ++ # psycopg2 ++ Database.extensions.register_adapter(Bit, lambda x: Database.extensions.AsIs(int(x))) ++ Database.extensions.register_adapter(BitHandler, lambda x: Database.extensions.AsIs(int(x))) ++ else: ++ # psycopg 3 ++ from psycopg.types.numeric import Int8BinaryDumper, Int8Dumper ++ ++ class _IntDumper(Int8Dumper): ++ def dump(self, obj): ++ return super().dump(int(obj)) ++ ++ def quote(self, obj): ++ return super().quote(int(obj)) ++ ++ class _IntBinaryDumper(Int8BinaryDumper): ++ def dump(self, obj): ++ return super().dump(int(obj)) ++ ++ for _cls in (Bit, BitHandler): ++ Database.adapters.register_dumper(_cls, _IntDumper) ++ Database.adapters.register_dumper(_cls, _IntBinaryDumper) + except ImproperlyConfigured: + pass diff --git a/www/py-django-bitfield/pkg-descr b/www/py-django-bitfield/pkg-descr index 853d1198b3f7..39d6562b900e 100644 --- a/www/py-django-bitfield/pkg-descr +++ b/www/py-django-bitfield/pkg-descr @@ -1 +1,7 @@ -Provides a BitField like class (using a BigIntegerField) for your Django models. +Provides a BitField like class (using a BigIntegerField) for your Django +models. + +Each BitField stores a set of named flags in a single integer column. +Flags can be tested and set on model instances, and used in querysets +with bitwise operations to filter and update rows. A form field and an +admin list filter are included. |
