﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
27830	Use distutils.version.LooseVersion instead of custom version parsing	NotSqrt	ChillarAnand	"Hi !

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 !"	Bug	closed	Core (Other)	1.10	Normal	fixed		anand21nanda@…	Accepted	1	0	0	1	0	0
