As discussed with Tim Graham in [https://groups.google.com/forum/#!topic
/django-users/BM3d679AsyA]
`django/db/backends/postgresql_psycopg2/base.py:psycopg2_version` can't
handle versions like `2.7b1` or
`2.7b2.dev0`([[https://github.com/psycopg/psycopg2/commit/b4b8b5f16440d11f8551be23c3f7517e060cf274|the
current git versions]]), because it only returns `(2, )`, which is lower
than the minimal requirement of `(2, 4, 5)`.
A possibility is to use :
{{{
from distutils.version import LooseVersion
LooseVersion(psycopg2.__version__.split(' ', 1)[0]) >=
LooseVersion('2.4.5')
}}}
Another possibility is
[[https://packaging.pypa.io/en/latest/version/|packaging]], the reference
implementation of [[https://www.python.org/dev/peps/pep-0440/|PEP-440]],
which is a dependency of setuptools (previously included in its vendor
libs), so very probably installed everywhere !
While searching for "version" in the django code base, there appears to be
multiple regex used to parse version strings : mysql, postgresql, gdal,
geos.
This could probably be more DRY, and correct.
I've seen things like `if geos_version_info()['version'] < '3.3.0':`,
which might fail at some point.
Thanks !
--
Ticket URL: <https://code.djangoproject.com/ticket/27830>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* type: Uncategorized => Bug
* component: Uncategorized => Core (Other)
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/27830#comment:1>
* status: new => assigned
* owner: nobody => ChillarAnand
--
Ticket URL: <https://code.djangoproject.com/ticket/27830#comment:2>
* cc: anand21nanda@… (added)
* has_patch: 0 => 1
Comment:
Fixed in [https://github.com/django/django/pull/8068 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/27830#comment:3>
* needs_better_patch: 0 => 1
Comment:
Additional tests are needed.
--
Ticket URL: <https://code.djangoproject.com/ticket/27830#comment:4>
Comment (by ChillarAnand):
Added additional test cases.
--
Ticket URL: <https://code.djangoproject.com/ticket/27830#comment:5>
Comment (by Tim Graham):
I'm doubtful that `packaging` is always available. I created a Python
3.6.1 virtualenv and can import setuptools ('36.0.1') but not packaging.
--
Ticket URL: <https://code.djangoproject.com/ticket/27830#comment:6>
Comment (by ChillarAnand):
Good catch. Replaced it with distutils.version.LooseVersion.
--
Ticket URL: <https://code.djangoproject.com/ticket/27830#comment:7>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/27830#comment:8>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"08bda82c237b9ad071538c2386b8bfc62fef7f7f" 08bda82c]:
{{{
#!CommitTicketReference repository=""
revision="08bda82c237b9ad071538c2386b8bfc62fef7f7f"
Fixed #27830 -- Used distutils.version.LooseVersion for version parsing.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27830#comment:8>