Commit 150889de authored by PJ Eby's avatar PJ Eby

Backport absolute path trapping to the 0.6 branch.

--HG--
branch : setuptools-0.6
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4045416
parent fd9c8228
...@@ -84,18 +84,20 @@ class build_py(_build_py): ...@@ -84,18 +84,20 @@ class build_py(_build_py):
self.manifest_files = mf = {} self.manifest_files = mf = {}
if not self.distribution.include_package_data: if not self.distribution.include_package_data:
return return
src_dirs = {} src_dirs = {}
for package in self.packages or (): for package in self.packages or ():
# Locate package source directory # Locate package source directory
src_dirs[self.get_package_dir(package)] = package src_dirs[assert_relative(self.get_package_dir(package))] = package
self.run_command('egg_info') self.run_command('egg_info')
ei_cmd = self.get_finalized_command('egg_info') ei_cmd = self.get_finalized_command('egg_info')
for path in ei_cmd.filelist.files: for path in ei_cmd.filelist.files:
if path.endswith('.py'): continue if path.endswith('.py'):
d,f = os.path.split(path) continue
while d and d not in src_dirs: d,f = os.path.split(assert_relative(path))
prev = None
while d and d!=prev and d not in src_dirs:
prev = d
d, df = os.path.split(d) d, df = os.path.split(d)
f = os.path.join(df, f) f = os.path.join(df, f)
if d in src_dirs: if d in src_dirs:
...@@ -119,8 +121,6 @@ class build_py(_build_py): ...@@ -119,8 +121,6 @@ class build_py(_build_py):
for filename in filenames for filename in filenames
] ]
def check_package(self, package, package_dir): def check_package(self, package, package_dir):
"""Check namespace packages' __init__ for declare_namespace""" """Check namespace packages' __init__ for declare_namespace"""
try: try:
...@@ -177,19 +177,19 @@ class build_py(_build_py): ...@@ -177,19 +177,19 @@ class build_py(_build_py):
return [f for f in files if f not in bad] return [f for f in files if f not in bad]
def assert_relative(path):
if not os.path.isabs(path):
return path
from distutils.errors import DistutilsSetupError
raise DistutilsSetupError(
"""Error: setup script specifies an absolute path:
%s
setup() arguments must *always* be /-separated paths relative to the
setup.py directory, *never* absolute paths.
""" % path
)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment