Skip to content

Commit 631b077

Browse files
authored
Merge pull request #161 from vidartf/auto-conf
Add configuration dir data files
2 parents d016867 + 95232c2 commit 631b077

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"load_extensions": {
3+
"jupyter-threejs/extension": true
4+
}
5+
}

setup.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,17 @@
3131
'js',
3232
data_files_spec=[
3333
('share/jupyter/nbextensions/jupyter-threejs',
34-
name + '/static', '*.js'),
34+
name + '/static',
35+
'*.js'),
3536
('share/jupyter/nbextensions/jupyter-threejs',
36-
name + '/static', '*.js.map'),
37+
name + '/static',
38+
'*.js.map'),
3739
('share/jupyter/lab/extensions',
38-
'js/lab-dist', 'jupyter-threejs-*.tgz'),
40+
'js/lab-dist',
41+
'jupyter-threejs-*.tgz'),
42+
('etc/jupyter/nbconfig',
43+
'jupyter-config',
44+
'**/*.json'),
3945
],
4046
)
4147
cmdclass['js'] = combine_commands(

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)