Tom Carrick
Tom Carrick

Reputation: 6616

Django Pipeline compiler not working

I'm trying to get django-pipeline working locally on Windows. When I run collecstatic or runserver and go to the site, I get the following error:

NotADirectoryError at /
[WinError 267] The directory name is invalid

On the site it happens when {% compressed_css 'main' %} is called in the template.

Looking at the traceback it seems to be happening in pipeline\compilers\__init__.py on this line: return list(executor.map(_compile, paths)), with local vars:

futures         <module 'concurrent.futures' from 'C:\\Python34\\Lib\\concurrent\\futures\\__init__.py'>
force           False
_compile        <function Compiler.compile.<locals>._compile at 0x0387A858>
paths           ['sass/main.sass']
multiprocessing <module 'multiprocessing' from 'C:\\Python34\\Lib\\multiprocessing\\__init__.py'>
executor        <concurrent.futures.thread.ThreadPoolExecutor object at 0x0387B970>
self            <pipeline.compilers.Compiler object at 0x0387B870>

Relevant chunk of settings.py:

STATIC_ROOT = 'staticfiles'
STATIC_URL = '/static/'
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'

STATICFILES_DIRS = (
    (os.path.join(BASE_DIR, 'static/common')),
)

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'pipeline.finders.PipelineFinder',
)


# Pipeline
PIPELINE_SASS_BINARY = 'sass'
PIPELINE_YUGLIFY_BINARY = 'yuglify'

PIPELINE_COMPILERS = (
    'pipeline.compilers.sass.SASSCompiler',
)

PIPELINE_CSS = {
    'main': {
        'source_filenames': (
            'sass/main.sass',
        ),
        'output_filename': 'css/main.css'
    }
}

Both sass and yuglify work from the command line.

Relevant filesystem structure:

myproject/
    ...
    settings.py
static/
    common/
        sass/
            main.sass

If I take out PIPELINE_COMPILERS = (...) and just use it to minify a regular CSS file, it works perfectly.

Upvotes: 3

Views: 1460

Answers (2)

Mijamo
Mijamo

Reputation: 3516

I had the same error.

It came from the compressor : when DEBUG = True, django-pipeline does not compress your files, but it stills try to compile them. So if you have any file needing to be compressed you must set the path for Windows (the default path is for linux). Otherwise you can also put the compilers only in production and use browser-compilation (my choice with LESS).

In your case, you need to set PIPELINE_SASS_BINARY

Upvotes: 1

Arjen
Arjen

Reputation: 1321

I'm not familiar with django-pipelines, but I'm guessing it's caused by using Unix-style paths in a Windows environment. E.g. sass/main.sass and css/main.css should probably be written as 'sass\\main.sass' and 'css\\main.css'

Upvotes: 0

Related Questions