charettes / django-colorful

Extension to the Django web framework that provides database and form color fields
https://pypi.python.org/pypi/django-colorful
MIT License
169 stars 58 forks source link

Importing django in __init__.py breaks pip installation (in some cases) #45

Closed evildmp closed 6 years ago

evildmp commented 6 years ago

https://github.com/charettes/django-colorful/blob/master/colorful/__init__.py#L3 means that Django already needs to be available before installing, and installation fails when it's not. For example:

Collecting django-colorful
  Downloading https://files.pythonhosted.org/packages/bc/5a/ef813bdfa9e9f4acd3efb363317b2e17b9ff67fb37e3880b7a3019037e29/django-colorful-1.2.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-wheel-zs0hbc37/django-colorful/setup.py", line 4, in <module>
        import colorful
      File "/tmp/pip-wheel-zs0hbc37/django-colorful/colorful/__init__.py", line 3, in <module>
        from django.utils import version
    ModuleNotFoundError: No module named 'django'

Maybe the technique used at https://github.com/GaretJax/django-click/blob/master/setup.py#L87-L97 would be a work-around.

charettes commented 6 years ago

Hello Daniel, could you provide more details about what version of pip you are using when you encounter this issue? The install_requires directive should make sure Django always gets installed before installing this package.

https://github.com/charettes/django-colorful/blob/9bf995a26154453d4890478767ffb28af2f85657/setup.py#L14-L16

I'm asking because I see from your provided stdout that you're installing from an sdist instead of a wheel.