fusionbox / django-pyscss

Makes it easier to use PyScss in Django
https://pypi.python.org/pypi/django-pyscss
BSD 2-Clause "Simplified" License
19 stars 13 forks source link

@import doesn't find files from STATICFILES_DIRS #14

Closed deshipu closed 10 years ago

deshipu commented 10 years ago

I'm probably doing something wrong, because this is what django-pyscss is supposed to do, but I can't get it to work with STATICFILES_DIRS. Long story short, we have removed our bootstrap scss files from our repository, and packaged them in a separate packaged, which we then import in settings.py and add the directory with all the files to STATICFILES_DIRS with correct prefix. Django-pyscss fails to find those files. It also fails to report the failure and just behaves as if everything went fine -- until you try to use any of the variables defined in those files.

Here is a link to the patch with the issue: https://review.openstack.org/#/c/116583/

I will prepare a minimal Django app that demonstrates the problem.

deshipu commented 10 years ago

Hmm, seems like my minimal example works just fine. There must be some other problem.

rockymeza commented 10 years ago

Hi @deshipu,

If I remember correctly, django-pyscss will log a warning if it can't find a file to import. If you turn up the logging level to DEBUG, you can also see the search paths that it's doing for the imports.

I wish I could throw exceptions, but I wanted to keep the style that PyScss had.

deshipu commented 10 years ago

Thank you for the advice, I will try it again tomorrow. You guys are great with the quick responses.

deshipu commented 10 years ago

All I'm getting is:

File to import not found or unreadable: '/bootstrap/scss/bootstrap' (<string u'// bootstrap overrides:\n$icon-font-path: "../../bo'...>:0)

But if I go to http://myserver/static/scss/bootstrap.scss I get the file correctly...

I will investigate further...

gavinwahl commented 10 years ago

Are there any DEBUG level messages? _find_source_file logs the paths it's searching.

deshipu commented 10 years ago

Well, it shows all the possible filename extensions, but those are not absolute filesystem paths, so I have no way of verifying that it looks in the right directory.

I noticed that it works fine if the prefix in STATICFILES_DIRS is set to "" (empty string). This is most likely some interaction with our particular setup or one of the libraries that we use -- I wrote a small Django app that works correctly even with non-empty prefixes.

deshipu commented 10 years ago

I finally have a working minimal example that reproduces the issue, but I still don't see how to fix it. The code is here: https://github.com/deshipu/django-pyscss-test

To see the problem:

git clone https://github.com/deshipu/django-pyscss-test
cd django-pyscss-test
virtualenv --system-site-packages venv
venv/bin/python manage.py runserver
xdg-open http://127.0.0.1:8080

The text should be red, but is not. You can also run:

venv/bin/python manage.py compress --force

To see that the generated css has no rules.

The interesting part is that if you remove "blue" both from the @import and from STATICFILES_DIRS, it works fine.

deshipu commented 10 years ago

I just discovered that it also works when you remove "blue" just from the @import and leave it in STATICFILES_DIRS. Looks like django-pyscss is just ignoring those prefixes.