dcwatson/django-pgcrypto — pull request #11 by playpauseandstop (2014-11-12 13:43:50+00:00)
Title: Do not require Django configured for installing django-pgcrypto

I've installed ``django-pgcrypto==1.1.1`` without problems, but was impressed with further changes in 1.2.0 (especially Django 1.7 and Python 3 support) that tried to reinstall it from source, but cannot complete installation cause of ``DJANGO_SETTINGS_MODULE`` env var not supplied on time of installation (which is expected behavior):

(venv)$ pip install -e git+https://github.com/dcwatson/django-pgcrypto.git@8d3a5929210a3e9fd81d9be49c8cff2fca2119f4#egg=django-pgcrypto
Obtaining django-pgcrypto from git+https://github.com/dcwatson/django-pgcrypto.git@8d3a5929210a3e9fd81d9be49c8cff2fca2119f4#egg=django-pgcrypto
Cloning https://github.com/dcwatson/django-pgcrypto.git (to 8d3a5929210a3e9fd81d9be49c8cff2fca2119f4) to ./venv/src/django-pgcrypto
Could not find a tag or branch '8d3a5929210a3e9fd81d9be49c8cff2fca2119f4', assuming commit.
Running setup.py (path:/home/playpauseandstop/Projects/getgoing/airborne/venv/src/django-pgcrypto/setup.py) egg_info for package django-pgcrypto
Traceback (most recent call last):
File "", line 17, in
File "/home/playpauseandstop/Projects/getgoing/airborne/venv/src/django-pgcrypto/setup.py", line 2, in
import pgcrypto
File "pgcrypto/__init__.py", line 18, in
from .fields import *
File "pgcrypto/fields.py", line 5, in
from django.db import models
File "/home/playpauseandstop/Projects/getgoing/airborne/venv/lib/python2.7/site-packages/django/db/__init__.py", line 11, in
if settings.DATABASES and DEFAULT_DB_ALIAS not in settings.DATABASES:
File "/home/playpauseandstop/Projects/getgoing/airborne/venv/lib/python2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__
self._setup(name)
File "/home/playpauseandstop/Projects/getgoing/airborne/venv/lib/python2.7/site-packages/django/conf/__init__.py", line 46, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting DATABASES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "", line 17, in

File "/home/playpauseandstop/Projects/getgoing/airborne/venv/src/django-pgcrypto/setup.py", line 2, in

import pgcrypto

File "pgcrypto/__init__.py", line 18, in

from .fields import *

File "pgcrypto/fields.py", line 5, in

from django.db import models

File "/home/playpauseandstop/Projects/getgoing/airborne/venv/lib/python2.7/site-packages/django/db/__init__.py", line 11, in

if settings.DATABASES and DEFAULT_DB_ALIAS not in settings.DATABASES:

File "/home/playpauseandstop/Projects/getgoing/airborne/venv/lib/python2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__

self._setup(name)

File "/home/playpauseandstop/Projects/getgoing/airborne/venv/lib/python2.7/site-packages/django/conf/__init__.py", line 46, in _setup

% (desc, ENVIRONMENT_VARIABLE))

django.core.exceptions.ImproperlyConfigured: Requested setting DATABASES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /home/playpauseandstop/Projects/getgoing/airborne/venv/src/django-pgcrypto
Storing debug log for failure in /home/playpauseandstop/.pip/pip.log

So I created this pull request, where instead of importing ``pgcrypto`` in setup script I reading version info from module content and making version number from it.