3

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.

Tom Carrick
  • 6,349
  • 13
  • 54
  • 78

2 Answers2

1

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

Mijamo
  • 3,436
  • 1
  • 21
  • 21
0

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'

Arjen
  • 1,321
  • 8
  • 10
  • You'd think so, but I tried with `os.path.join()` and also using escaped backslashes but no luck so far. I also tried the LESS compiler and have the same issue. But yuglify works just fine. – Tom Carrick Sep 22 '14 at 00:48
  • That's too bad. What about using full, absolute paths? – Arjen Sep 22 '14 at 09:42
  • It's not expecting them, the local vars convert this to full paths. The program is even being run correctly, if I run sass or lessc or whatever with the same arguments python is giving it, it works fine in the command line, and fine in the interactive shell. It's rather confusing. – Tom Carrick Sep 22 '14 at 09:47