@@ -212,7 +212,12 @@ def run(cmd, **kwargs):
212
212
kwargs .setdefault ('shell' , os .name == 'nt' )
213
213
if not isinstance (cmd , (list , tuple )) and os .name != 'nt' :
214
214
cmd = shlex .split (cmd )
215
- cmd [0 ] = which (cmd [0 ])
215
+ cmd_path = which (cmd [0 ])
216
+ if not cmd_path :
217
+ sys .exit ("Aborting. Could not find cmd (%s) in path. "
218
+ "If command is not expected to be in user's path, "
219
+ "use an absolute path." % cmd [0 ])
220
+ cmd [0 ] = cmd_path
216
221
return subprocess .check_call (cmd , ** kwargs )
217
222
218
223
@@ -499,13 +504,20 @@ def run(self):
499
504
return FileHandler
500
505
501
506
502
- def _get_data_files (data_specs , existing ):
507
+ def _glob_pjoin (* parts ):
508
+ """Join paths for glob processing"""
509
+ if parts [0 ] in ('.' , '' ):
510
+ parts = parts [1 :]
511
+ return pjoin (* parts ).replace (os .sep , '/' )
512
+
513
+
514
+ def _get_data_files (data_specs , existing , top = HERE ):
503
515
"""Expand data file specs into valid data files metadata.
504
516
505
517
Parameters
506
518
----------
507
519
data_specs: list of tuples
508
- See [createcmdclass ] for description.
520
+ See [create_cmdclass ] for description.
509
521
existing: list of tuples
510
522
The existing distrubution data_files metadata.
511
523
@@ -521,14 +533,16 @@ def _get_data_files(data_specs, existing):
521
533
# Extract the files and assign them to the proper data
522
534
# files path.
523
535
for (path , dname , pattern ) in data_specs or []:
536
+ if os .path .isabs (dname ):
537
+ dname = os .path .relpath (dname , top )
524
538
dname = dname .replace (os .sep , '/' )
525
- offset = len (dname ) + 1
526
-
527
- files = _get_files (pjoin (dname , pattern ))
539
+ offset = 0 if dname in ('.' , '' ) else len (dname ) + 1
540
+ files = _get_files (_glob_pjoin (dname , pattern ), top = top )
528
541
for fname in files :
529
542
# Normalize the path.
530
543
root = os .path .dirname (fname )
531
- full_path = '/' .join ([path , root [offset :]])
544
+ full_path = _glob_pjoin (path , root [offset :])
545
+ print (dname , root , full_path , offset )
532
546
if full_path .endswith ('/' ):
533
547
full_path = full_path [:- 1 ]
534
548
file_data [full_path ].append (fname )
@@ -573,7 +587,8 @@ def _get_files(file_patterns, top=HERE):
573
587
dirnames .remove ('node_modules' )
574
588
for m in matchers :
575
589
for filename in filenames :
576
- fn = os .path .relpath (pjoin (root , filename ), top )
590
+ fn = os .path .relpath (_glob_pjoin (root , filename ), top )
591
+ fn = fn .replace (os .sep , '/' )
577
592
if m (fn ):
578
593
files .add (fn .replace (os .sep , '/' ))
579
594
@@ -598,7 +613,7 @@ def _get_package_data(root, file_patterns=None):
598
613
"""
599
614
if file_patterns is None :
600
615
file_patterns = ['*' ]
601
- return _get_files (file_patterns , pjoin (HERE , root ))
616
+ return _get_files (file_patterns , _glob_pjoin (HERE , root ))
602
617
603
618
604
619
def _compile_pattern (pat , ignore_case = True ):
0 commit comments