fastai / nbdev

Create delightful software with Jupyter Notebooks
https://nbdev.fast.ai/
Apache License 2.0
4.9k stars 487 forks source link

Nested `lib_path` values break module -> notebook sync #1393

Closed scwe closed 3 days ago

scwe commented 9 months ago

When running nbdev_update on a project that uses a nested lib_path setting (i.e. path/to/file) the update will fail

Minimal reproduceable example is available here. The exact error I get here is

Traceback (most recent call last):
  File "/home/scott/.local/bin/nbdev_update", line 8, in <module>
    sys.exit(nbdev_update())
  File "/home/scott/.local/lib/python3.10/site-packages/fastcore/script.py", line 119, in _f
    return tfunc(**merge(args, args_from_prog(func, xtra)))
  File "/home/scott/.local/lib/python3.10/site-packages/nbdev/sync.py", line 79, in nbdev_update
    files = files.filter(lambda x: str(Path(x).absolute().relative_to(lib_dir) in _mod_files()))
  File "/home/scott/.local/lib/python3.10/site-packages/fastcore/foundation.py", line 162, in filter
    return self._new(filter_ex(self, f=f, negate=negate, gen=False, **kwargs))
  File "/home/scott/.local/lib/python3.10/site-packages/fastcore/basics.py", line 642, in filter_ex
    return list(res)
  File "/home/scott/.local/lib/python3.10/site-packages/nbdev/sync.py", line 79, in <lambda>
    files = files.filter(lambda x: str(Path(x).absolute().relative_to(lib_dir) in _mod_files()))
  File "/home/scott/.local/lib/python3.10/site-packages/nbdev/sync.py", line 38, in _mod_files
    midx = import_module(f'{get_config().lib_path.name}._modidx')
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'nested'