Skip to content

Commit

Permalink
Fix sync for nested libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
scwe committed Aug 29, 2024
1 parent c5f06ac commit 38dca3a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions nbdev/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from fastcore.xtras import *

import ast
from importlib import import_module
import importlib

# %% ../nbs/api/06_sync.ipynb
def absolute_import(name, fname, level):
Expand All @@ -32,7 +32,10 @@ def absolute_import(name, fname, level):
# %% ../nbs/api/06_sync.ipynb
@functools.lru_cache(maxsize=None)
def _mod_files():
midx = import_module(f'{get_config().lib_path.name}._modidx')
midx_spec = importlib.util.spec_from_file_location("_modidx", get_config().lib_path / "_modidx.py")
midx = importlib.util.module_from_spec(midx_spec)
midx_spec.loader.exec_module(midx)

return L(files for mod in midx.d['syms'].values() for _,files in mod.values()).unique()

# %% ../nbs/api/06_sync.ipynb
Expand Down
7 changes: 5 additions & 2 deletions nbs/api/06_sync.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"from fastcore.xtras import *\n",
"\n",
"import ast\n",
"from importlib import import_module"
"import importlib"
]
},
{
Expand Down Expand Up @@ -98,7 +98,10 @@
"#|export\n",
"@functools.lru_cache(maxsize=None)\n",
"def _mod_files():\n",
" midx = import_module(f'{get_config().lib_path.name}._modidx')\n",
" midx_spec = importlib.util.spec_from_file_location(\"_modidx\", get_config().lib_path / \"_modidx.py\")\n",
" midx = importlib.util.module_from_spec(midx_spec)\n",
" midx_spec.loader.exec_module(midx)\n",
"\n",
" return L(files for mod in midx.d['syms'].values() for _,files in mod.values()).unique()"
]
},
Expand Down

0 comments on commit 38dca3a

Please sign in to comment.