Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn about leading and trailing slashes in filename patterns #37

Closed
mgedmin opened this issue Dec 18, 2014 · 1 comment
Closed

Warn about leading and trailing slashes in filename patterns #37

mgedmin opened this issue Dec 18, 2014 · 1 comment

Comments

@mgedmin
Copy link
Owner

mgedmin commented Dec 18, 2014

I validated a MANIFEST.in with check-manifest, commited, and then woke up to a failing build because the MANIFEST.in contained a line

purge docs/_build/

with a trailing slash.

The traceback was:

Traceback (most recent call last):
  File "c:\temp\tmpe9f4zn", line 14, in <module>
    exec(compile(f.read(), 'c:\\buildslave\\transaction\\build\\.\\setup.py', 'exec'))
  File "c:\buildslave\transaction\build\.\setup.py", line 73, in <module>
    """
  File "c:\Python26_32\lib\distutils\core.py", line 152, in setup
    dist.run_commands()
  File "c:\Python26_32\lib\distutils\dist.py", line 975, in run_commands
    self.run_command(cmd)
  File "c:\Python26_32\lib\distutils\dist.py", line 995, in run_command
    cmd_obj.run()
  File "build\bdist.win32\egg\setuptools\command\develop.py", line 32, in run
  File "build\bdist.win32\egg\setuptools\command\develop.py", line 113, in install_for_development
  File "c:\Python26_32\lib\distutils\cmd.py", line 333, in run_command
    self.distribution.run_command(command)
  File "c:\Python26_32\lib\distutils\dist.py", line 995, in run_command
    cmd_obj.run()
  File "build\bdist.win32\egg\setuptools\command\egg_info.py", line 180, in run
  File "build\bdist.win32\egg\setuptools\command\egg_info.py", line 205, in find_sources
  File "build\bdist.win32\egg\setuptools\command\egg_info.py", line 291, in run
  File "build\bdist.win32\egg\setuptools\command\sdist.py", line 127, in __read_template_hack
  File "c:\Python26_32\lib\distutils\command\sdist.py", line 336, in read_template
    self.filelist.process_template_line(line)
  File "c:\Python26_32\lib\distutils\filelist.py", line 129, in process_template_line
    (action, patterns, dir, dir_pattern) = self._parse_template_line(line)
  File "c:\Python26_32\lib\distutils\filelist.py", line 112, in _parse_template_line
    dir_pattern = convert_path(words[1])
  File "c:\Python26_32\lib\distutils\util.py", line 201, in convert_path
    raise ValueError, "path '%s' cannot end with '/'" % pathname
ValueError: path 'docs/_build/' cannot end with '/'

I'm unable to reproduce this locally with Python 2.6.9. Which would be because I'm on Linux.

Here's the convert_path() from the current hg tip of Python 3.x:

def convert_path (pathname):
    """Return 'pathname' as a name that will work on the native filesystem,
    i.e. split it on '/' and put it back together again using the current
    directory separator.  Needed because filenames in the setup script are
    always supplied in Unix style, and have to be converted to the local
    convention before we can actually use them in the filesystem.  Raises
    ValueError on non-Unix-ish systems if 'pathname' either starts or
    ends with a slash.
    """
    if os.sep == '/':
        return pathname
    if not pathname:
        return pathname
    if pathname[0] == '/':
        raise ValueError("path '%s' cannot be absolute" % pathname)
    if pathname[-1] == '/':
        raise ValueError("path '%s' cannot end with '/'" % pathname)

    paths = pathname.split('/')
    while '.' in paths:
        paths.remove('.')
    if not paths:
        return os.curdir
    return os.path.join(*paths)

The pathname must not begin or end with a /, but this is verified only on non-Linux platforms.

@mgedmin
Copy link
Owner Author

mgedmin commented Dec 18, 2014

convert_path() is applied to the arguments of the following directives:

  • include
  • exclude
  • global-include
  • global-exclude
  • graft
  • prune

In other words, all of them.

@mgedmin mgedmin changed the title Warn about trailing slashes in purge Warn about leading and trailing slashes in filename patterns Dec 18, 2014
@mgedmin mgedmin closed this as completed Dec 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant