Skip to content

Commit 38dca3a

Browse files
committed
Fix sync for nested libraries
1 parent c5f06ac commit 38dca3a

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

nbdev/sync.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from fastcore.xtras import *
2020

2121
import ast
22-
from importlib import import_module
22+
import importlib
2323

2424
# %% ../nbs/api/06_sync.ipynb
2525
def absolute_import(name, fname, level):
@@ -32,7 +32,10 @@ def absolute_import(name, fname, level):
3232
# %% ../nbs/api/06_sync.ipynb
3333
@functools.lru_cache(maxsize=None)
3434
def _mod_files():
35-
midx = import_module(f'{get_config().lib_path.name}._modidx')
35+
midx_spec = importlib.util.spec_from_file_location("_modidx", get_config().lib_path / "_modidx.py")
36+
midx = importlib.util.module_from_spec(midx_spec)
37+
midx_spec.loader.exec_module(midx)
38+
3639
return L(files for mod in midx.d['syms'].values() for _,files in mod.values()).unique()
3740

3841
# %% ../nbs/api/06_sync.ipynb

nbs/api/06_sync.ipynb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"from fastcore.xtras import *\n",
4747
"\n",
4848
"import ast\n",
49-
"from importlib import import_module"
49+
"import importlib"
5050
]
5151
},
5252
{
@@ -98,7 +98,10 @@
9898
"#|export\n",
9999
"@functools.lru_cache(maxsize=None)\n",
100100
"def _mod_files():\n",
101-
" midx = import_module(f'{get_config().lib_path.name}._modidx')\n",
101+
" midx_spec = importlib.util.spec_from_file_location(\"_modidx\", get_config().lib_path / \"_modidx.py\")\n",
102+
" midx = importlib.util.module_from_spec(midx_spec)\n",
103+
" midx_spec.loader.exec_module(midx)\n",
104+
"\n",
102105
" return L(files for mod in midx.d['syms'].values() for _,files in mod.values()).unique()"
103106
]
104107
},

0 commit comments

Comments
 (0)