Skip to content

Commit 20cd266

Browse files
committed
Fix setupbase path issues
1 parent d016867 commit 20cd266

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

setupbase.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -502,13 +502,20 @@ def run(self):
502502
return FileHandler
503503

504504

505-
def _get_data_files(data_specs, existing):
505+
def _glob_pjoin(*parts):
506+
"""Join paths for glob processing"""
507+
if parts[0] in ('.', ''):
508+
parts = parts[1:]
509+
return pjoin(*parts).replace(os.sep, '/')
510+
511+
512+
def _get_data_files(data_specs, existing, top=HERE):
506513
"""Expand data file specs into valid data files metadata.
507514
508515
Parameters
509516
----------
510517
data_specs: list of tuples
511-
See [createcmdclass] for description.
518+
See [create_cmdclass] for description.
512519
existing: list of tuples
513520
The existing distrubution data_files metadata.
514521
@@ -524,14 +531,16 @@ def _get_data_files(data_specs, existing):
524531
# Extract the files and assign them to the proper data
525532
# files path.
526533
for (path, dname, pattern) in data_specs or []:
534+
if os.path.isabs(dname):
535+
dname = os.path.relpath(dname, top)
527536
dname = dname.replace(os.sep, '/')
528-
offset = len(dname) + 1
529-
530-
files = _get_files(pjoin(dname, pattern))
537+
offset = 0 if dname in ('.', '') else len(dname) + 1
538+
files = _get_files(_glob_pjoin(dname, pattern), top=top)
531539
for fname in files:
532540
# Normalize the path.
533541
root = os.path.dirname(fname)
534-
full_path = '/'.join([path, root[offset:]])
542+
full_path = _glob_pjoin(path, root[offset:])
543+
print(dname, root, full_path, offset)
535544
if full_path.endswith('/'):
536545
full_path = full_path[:-1]
537546
file_data[full_path].append(fname)
@@ -576,7 +585,8 @@ def _get_files(file_patterns, top=HERE):
576585
dirnames.remove('node_modules')
577586
for m in matchers:
578587
for filename in filenames:
579-
fn = os.path.relpath(pjoin(root, filename), top)
588+
fn = os.path.relpath(_glob_pjoin(root, filename), top)
589+
fn = fn.replace(os.sep, '/')
580590
if m(fn):
581591
files.add(fn.replace(os.sep, '/'))
582592

@@ -601,7 +611,7 @@ def _get_package_data(root, file_patterns=None):
601611
"""
602612
if file_patterns is None:
603613
file_patterns = ['*']
604-
return _get_files(file_patterns, pjoin(HERE, root))
614+
return _get_files(file_patterns, _glob_pjoin(HERE, root))
605615

606616

607617
def _compile_pattern(pat, ignore_case=True):

0 commit comments

Comments
 (0)