Can't use psycopg2 2.7b1 with django

54 views
Skip to first unread message

not...@gmail.com

unread,
Feb 10, 2017, 5:58:29 AM2/10/17
to Django users
Hi !

psycopg2 is preparing a new release, and currently the git project uses PEP 440-compatible version numbers : 2.7b1,  2.7b2.dev0 (see https://github.com/psycopg/psycopg2/blob/master/setup.py#L67

In https://github.com/django/django/blob/master/django/db/backends/postgresql/base.py, django parses that version string to check if it is greater than 2.4.5.

But the psycopg2_version function can't handle version strings like 2.7b1, and returns (2,).

Any ideas to improve django ?

The "packaging" package could be used for that : https://packaging.pypa.io/en/latest/version/, a correct version parser does not seem simple !
Or "from distutils.version import LooseVersion"

Thanks,
NotSqrt

not...@gmail.com

unread,
Feb 10, 2017, 6:08:45 AM2/10/17
to Django users
packaging is a dependency of setuptools (previously included in its vendor libs), so very probably installed everywhere !

Tim Graham

unread,
Feb 10, 2017, 2:40:42 PM2/10/17
to Django users
I think distutils.version.LooseVersion should be safe to use (django-cms is using it, for example). Not sure about "packaging". Do you want to create a Trac ticket for this issue? Probably the same technique could also be used in other places.

not...@gmail.com

unread,
Feb 13, 2017, 4:31:40 AM2/13/17
to Django users
Hi Tim,

Ticket created at https://code.djangoproject.com/ticket/27830, with some additional info, and other potential places needed to be fixed.

Thanks,
Reply all
Reply to author
Forward
0 new messages