dcwatson / django-pgcrypto

Python and Django utilities for encrypted fields using pgcrypto.
BSD 2-Clause "Simplified" License
67 stars 22 forks source link

Do not require Django configured for installing django-pgcrypto #11

Closed playpauseandstop closed 9 years ago

playpauseandstop commented 9 years ago

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 "<string>", line 17, in <module>
      File "/home/playpauseandstop/Projects/getgoing/airborne/venv/src/django-pgcrypto/setup.py", line 2, in <module>
        import pgcrypto
      File "pgcrypto/__init__.py", line 18, in <module>
        from .fields import *
      File "pgcrypto/fields.py", line 5, in <module>
        from django.db import models
      File "/home/playpauseandstop/Projects/getgoing/airborne/venv/lib/python2.7/site-packages/django/db/__init__.py", line 11, in <module>
        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 "<string>", line 17, in <module>

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

    import pgcrypto

  File "pgcrypto/__init__.py", line 18, in <module>

    from .fields import *

  File "pgcrypto/fields.py", line 5, in <module>

    from django.db import models

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

    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.

dcwatson commented 9 years ago

Thanks! I've addressed most of these issues with the last couple commits, and will be releasing 1.2.0 this evening - it's been sitting unreleased for too long.