Skip to content

Commit 7661d51

Browse files
authored
Merge pull request #17 from vidartf/update-setupbase
Update setupbase
2 parents 9f378b1 + 9e6df6e commit 7661d51

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

{{cookiecutter.github_project_name}}/setupbase.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,12 @@ def run(cmd, **kwargs):
212212
kwargs.setdefault('shell', os.name == 'nt')
213213
if not isinstance(cmd, (list, tuple)) and os.name != 'nt':
214214
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
216221
return subprocess.check_call(cmd, **kwargs)
217222

218223

@@ -499,13 +504,20 @@ def run(self):
499504
return FileHandler
500505

501506

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):
503515
"""Expand data file specs into valid data files metadata.
504516
505517
Parameters
506518
----------
507519
data_specs: list of tuples
508-
See [createcmdclass] for description.
520+
See [create_cmdclass] for description.
509521
existing: list of tuples
510522
The existing distrubution data_files metadata.
511523
@@ -521,14 +533,16 @@ def _get_data_files(data_specs, existing):
521533
# Extract the files and assign them to the proper data
522534
# files path.
523535
for (path, dname, pattern) in data_specs or []:
536+
if os.path.isabs(dname):
537+
dname = os.path.relpath(dname, top)
524538
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)
528541
for fname in files:
529542
# Normalize the path.
530543
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)
532546
if full_path.endswith('/'):
533547
full_path = full_path[:-1]
534548
file_data[full_path].append(fname)
@@ -573,7 +587,8 @@ def _get_files(file_patterns, top=HERE):
573587
dirnames.remove('node_modules')
574588
for m in matchers:
575589
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, '/')
577592
if m(fn):
578593
files.add(fn.replace(os.sep, '/'))
579594

@@ -598,7 +613,7 @@ def _get_package_data(root, file_patterns=None):
598613
"""
599614
if file_patterns is None:
600615
file_patterns = ['*']
601-
return _get_files(file_patterns, pjoin(HERE, root))
616+
return _get_files(file_patterns, _glob_pjoin(HERE, root))
602617

603618

604619
def _compile_pattern(pat, ignore_case=True):

{{cookiecutter.github_project_name}}/src/widget.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Distributed under the terms of the Modified BSD License.
33

44
import {
5-
DOMWidgetModel, DOMWidgetView
5+
DOMWidgetModel, DOMWidgetView, ISerializers
66
} from '@jupyter-widgets/base';
77

88
import {
@@ -24,7 +24,7 @@ class ExampleModel extends DOMWidgetModel {
2424
};
2525
}
2626

27-
static serializers = {
27+
static serializers: ISerializers = {
2828
...DOMWidgetModel.serializers,
2929
// Add any extra serializers here
3030
}

0 commit comments

Comments
 (0)