Search code examples
pythonsetuptools

How can escape spaces in directory names in a MANIFEST.in files?


I've inherited some code that has directory names with embedded spaces, and I don't have the option of renaming the directory. Let's say the name of the directory is "embedded spaces"

Now I'm trying to access some files from this directory in a MANIFEST.in file

I've tried the following:

recursive-include 'embedded spaces' *.dat
recursive-include "embedded spaces" *.dat
recursive-include embedded\ spaces *.dat

These all give errors something along the lines of "warning: no files found matching 'spaces' under directory 'embedded'

I have a workaround which is

recursive-include embedded* *.dat

but I was wondering if there's a less hackish way to encode spaces in MANIFEST.in directory names.


Solution

  • No it would appear not. Inspecting the source of distutils.filelist, which does the work of parsing the MANIFEST.in shows that the line is split purely on whitespace to determine the action and its parameters

    Here is the source (in python 2,7)

    def _parse_template_line(self, line):
        words = line.split()
        action = words[0]
    
        ...
    
        if action in ('include', 'exclude',
                      'global-include', 'global-exclude'):
            ...
        elif action in ('recursive-include', 'recursive-exclude'):
            if len(words) < 3:
                raise DistutilsTemplateError, \
                      "'%s' expects <dir> <pattern1> <pattern2> ..." % action
    
            dir = convert_path(words[1])
            patterns = map(convert_path, words[2:])
    
        ...