nbdev 2.4.10__py3-none-any.whl → 2.4.12__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nbdev/__init__.py +1 -1
- nbdev/_modidx.py +1 -0
- nbdev/clean.py +22 -19
- nbdev/cli.py +12 -12
- nbdev/config.py +29 -28
- nbdev/diff.py +9 -9
- nbdev/doclinks.py +29 -31
- nbdev/export.py +7 -7
- nbdev/frontmatter.py +4 -4
- nbdev/maker.py +22 -22
- nbdev/merge.py +10 -10
- nbdev/migrate.py +18 -18
- nbdev/process.py +15 -15
- nbdev/processors.py +26 -26
- nbdev/qmd.py +9 -9
- nbdev/quarto.py +25 -25
- nbdev/release.py +41 -39
- nbdev/serve.py +5 -5
- nbdev/showdoc.py +7 -7
- nbdev/sync.py +14 -11
- nbdev/test.py +5 -5
- {nbdev-2.4.10.dist-info → nbdev-2.4.12.dist-info}/METADATA +2 -2
- nbdev-2.4.12.dist-info/RECORD +30 -0
- nbdev-2.4.10.dist-info/RECORD +0 -30
- {nbdev-2.4.10.dist-info → nbdev-2.4.12.dist-info}/WHEEL +0 -0
- {nbdev-2.4.10.dist-info → nbdev-2.4.12.dist-info}/entry_points.txt +0 -0
- {nbdev-2.4.10.dist-info → nbdev-2.4.12.dist-info}/licenses/LICENSE +0 -0
- {nbdev-2.4.10.dist-info → nbdev-2.4.12.dist-info}/top_level.txt +0 -0
nbdev/release.py
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/18_release.ipynb.
|
|
4
4
|
|
|
5
|
-
# %% auto 0
|
|
6
|
-
__all__ = ['GH_HOST', 'CONDA_WARNING', 'Release', 'changelog', '
|
|
7
|
-
'pypi_details', 'conda_output_path', 'write_conda_meta', 'write_requirements',
|
|
8
|
-
'release_conda', 'chk_conda_rel', 'release_pypi', 'release_both', 'bump_version',
|
|
5
|
+
# %% auto #0
|
|
6
|
+
__all__ = ['GH_HOST', 'CONDA_WARNING', 'Release', 'changelog', 'push_release', 'release_git', 'release_gh', 'pypi_json',
|
|
7
|
+
'latest_pypi', 'pypi_details', 'conda_output_path', 'write_conda_meta', 'write_requirements',
|
|
8
|
+
'anaconda_upload', 'release_conda', 'chk_conda_rel', 'release_pypi', 'release_both', 'bump_version',
|
|
9
|
+
'nbdev_bump_version']
|
|
9
10
|
|
|
10
|
-
# %% ../nbs/api/18_release.ipynb
|
|
11
|
+
# %% ../nbs/api/18_release.ipynb #c35cc2b8
|
|
11
12
|
from fastcore.all import *
|
|
12
13
|
from ghapi.core import *
|
|
13
14
|
|
|
@@ -17,16 +18,16 @@ import shutil,subprocess
|
|
|
17
18
|
|
|
18
19
|
from .doclinks import *
|
|
19
20
|
|
|
20
|
-
# %% ../nbs/api/18_release.ipynb
|
|
21
|
+
# %% ../nbs/api/18_release.ipynb #7e554523
|
|
21
22
|
GH_HOST = "https://api.github.com"
|
|
22
23
|
|
|
23
|
-
# %% ../nbs/api/18_release.ipynb
|
|
24
|
+
# %% ../nbs/api/18_release.ipynb #e220cefa
|
|
24
25
|
def _find_config(cfg_name="settings.ini"):
|
|
25
26
|
cfg_path = Path().absolute()
|
|
26
27
|
while cfg_path != cfg_path.parent and not (cfg_path/cfg_name).exists(): cfg_path = cfg_path.parent
|
|
27
28
|
return Config(cfg_path, cfg_name)
|
|
28
29
|
|
|
29
|
-
# %% ../nbs/api/18_release.ipynb
|
|
30
|
+
# %% ../nbs/api/18_release.ipynb #1972609a
|
|
30
31
|
def _issue_txt(issue):
|
|
31
32
|
res = '- {} ([#{}]({}))'.format(issue.title.strip(), issue.number, issue.html_url)
|
|
32
33
|
if hasattr(issue, 'pull_request'): res += ', thanks to [@{}]({})'.format(issue.user.login, issue.user.html_url)
|
|
@@ -43,7 +44,7 @@ def _load_json(cfg, k):
|
|
|
43
44
|
try: return json.loads(cfg[k])
|
|
44
45
|
except json.JSONDecodeError as e: raise Exception(f"Key: `{k}` in .ini file is not a valid JSON string: {e}")
|
|
45
46
|
|
|
46
|
-
# %% ../nbs/api/18_release.ipynb
|
|
47
|
+
# %% ../nbs/api/18_release.ipynb #0b36471a
|
|
47
48
|
class Release:
|
|
48
49
|
def __init__(self, owner=None, repo=None, token=None, **groups):
|
|
49
50
|
"Create CHANGELOG.md from GitHub issues"
|
|
@@ -65,7 +66,7 @@ class Release:
|
|
|
65
66
|
return self.gh.issues.list_for_repo(state='closed', sort='created', filter='all', since=self.commit_date, labels=label)
|
|
66
67
|
def _issue_groups(self): return parallel(self._issues, self.groups.keys(), progress=False, threadpool=True)
|
|
67
68
|
|
|
68
|
-
# %% ../nbs/api/18_release.ipynb
|
|
69
|
+
# %% ../nbs/api/18_release.ipynb #aa22dfe3
|
|
69
70
|
@patch
|
|
70
71
|
def changelog(self:Release,
|
|
71
72
|
debug=False): # Just print the latest changes, instead of updating file
|
|
@@ -86,7 +87,7 @@ def changelog(self:Release,
|
|
|
86
87
|
self.changefile.write_text(res)
|
|
87
88
|
run(f'git add {self.changefile}')
|
|
88
89
|
|
|
89
|
-
# %% ../nbs/api/18_release.ipynb
|
|
90
|
+
# %% ../nbs/api/18_release.ipynb #068421c6
|
|
90
91
|
@patch
|
|
91
92
|
def release(self:Release):
|
|
92
93
|
"Tag and create a release in GitHub for the current version"
|
|
@@ -95,7 +96,7 @@ def release(self:Release):
|
|
|
95
96
|
self.gh.create_release(ver, branch=self.cfg.branch, body=notes)
|
|
96
97
|
return ver
|
|
97
98
|
|
|
98
|
-
# %% ../nbs/api/18_release.ipynb
|
|
99
|
+
# %% ../nbs/api/18_release.ipynb #22101171
|
|
99
100
|
@patch
|
|
100
101
|
def latest_notes(self:Release):
|
|
101
102
|
"Latest CHANGELOG entry"
|
|
@@ -104,7 +105,7 @@ def latest_notes(self:Release):
|
|
|
104
105
|
if not len(its)>0: return ''
|
|
105
106
|
return '\n'.join(its[1].splitlines()[1:]).strip()
|
|
106
107
|
|
|
107
|
-
# %% ../nbs/api/18_release.ipynb
|
|
108
|
+
# %% ../nbs/api/18_release.ipynb #01cb1ca4
|
|
108
109
|
@call_parse
|
|
109
110
|
def changelog(
|
|
110
111
|
debug:store_true=False, # Print info to be added to CHANGELOG, instead of updating file
|
|
@@ -114,16 +115,18 @@ def changelog(
|
|
|
114
115
|
res = Release(repo=repo).changelog(debug=debug)
|
|
115
116
|
if debug: print(res)
|
|
116
117
|
|
|
117
|
-
# %% ../nbs/api/18_release.ipynb
|
|
118
|
+
# %% ../nbs/api/18_release.ipynb #15b66643
|
|
119
|
+
def push_release(token:str=None):
|
|
120
|
+
"Create a GitHub release (changelog should already be committed/pushed). Returns the release."
|
|
121
|
+
return Release(token=token).release()
|
|
122
|
+
|
|
123
|
+
# %% ../nbs/api/18_release.ipynb #6d3c5cd8
|
|
118
124
|
@call_parse
|
|
119
|
-
def release_git(
|
|
120
|
-
token:str=None # Optional GitHub token (otherwise `token` file is used)
|
|
121
|
-
):
|
|
125
|
+
def release_git(token:str=None):
|
|
122
126
|
"Tag and create a release in GitHub for the current version"
|
|
123
|
-
|
|
124
|
-
print(f"Released {ver}")
|
|
127
|
+
print(f"Released {push_release(token)}")
|
|
125
128
|
|
|
126
|
-
# %% ../nbs/api/18_release.ipynb
|
|
129
|
+
# %% ../nbs/api/18_release.ipynb #94ee72b1
|
|
127
130
|
@call_parse
|
|
128
131
|
def release_gh(
|
|
129
132
|
token:str=None # Optional GitHub token (otherwise `token` file is used)
|
|
@@ -135,10 +138,9 @@ def release_gh(
|
|
|
135
138
|
if not input("Make release now? (y/n) ").lower().startswith('y'): sys.exit(1)
|
|
136
139
|
run('git commit -am release')
|
|
137
140
|
run('git push')
|
|
138
|
-
|
|
139
|
-
print(f"Released {ver}")
|
|
141
|
+
print(f"Released {push_release(token)}")
|
|
140
142
|
|
|
141
|
-
# %% ../nbs/api/18_release.ipynb
|
|
143
|
+
# %% ../nbs/api/18_release.ipynb #5b4d4aa2
|
|
142
144
|
from fastcore.all import *
|
|
143
145
|
from .config import *
|
|
144
146
|
from .cli import *
|
|
@@ -150,18 +152,18 @@ except ImportError: from pip._vendor.packaging.version import parse
|
|
|
150
152
|
|
|
151
153
|
_PYPI_URL = 'https://pypi.org/pypi/'
|
|
152
154
|
|
|
153
|
-
# %% ../nbs/api/18_release.ipynb
|
|
155
|
+
# %% ../nbs/api/18_release.ipynb #4070bbef
|
|
154
156
|
def pypi_json(s):
|
|
155
157
|
"Dictionary decoded JSON for PYPI path `s`"
|
|
156
158
|
return urljson(f'{_PYPI_URL}{s}/json')
|
|
157
159
|
|
|
158
|
-
# %% ../nbs/api/18_release.ipynb
|
|
160
|
+
# %% ../nbs/api/18_release.ipynb #1985c8b1
|
|
159
161
|
def latest_pypi(name):
|
|
160
162
|
"Latest version of `name` on pypi"
|
|
161
163
|
return max(parse(r) for r,o in pypi_json(name)['releases'].items()
|
|
162
164
|
if not parse(r).is_prerelease and not nested_idx(o, 0, 'yanked'))
|
|
163
165
|
|
|
164
|
-
# %% ../nbs/api/18_release.ipynb
|
|
166
|
+
# %% ../nbs/api/18_release.ipynb #ab0bfd9a
|
|
165
167
|
def pypi_details(name):
|
|
166
168
|
"Version, URL, and SHA256 for `name` from pypi"
|
|
167
169
|
ver = str(latest_pypi(name))
|
|
@@ -169,7 +171,7 @@ def pypi_details(name):
|
|
|
169
171
|
rel = [o for o in pypi['urls'] if o['packagetype']=='sdist'][0]
|
|
170
172
|
return ver,rel['url'],rel['digests']['sha256']
|
|
171
173
|
|
|
172
|
-
# %% ../nbs/api/18_release.ipynb
|
|
174
|
+
# %% ../nbs/api/18_release.ipynb #431f625b
|
|
173
175
|
import shlex
|
|
174
176
|
from subprocess import Popen, PIPE, CalledProcessError
|
|
175
177
|
|
|
@@ -183,12 +185,12 @@ def _run(cmd):
|
|
|
183
185
|
if p.returncode != 0: raise CalledProcessError(p.returncode, p.args)
|
|
184
186
|
return res
|
|
185
187
|
|
|
186
|
-
# %% ../nbs/api/18_release.ipynb
|
|
188
|
+
# %% ../nbs/api/18_release.ipynb #6a9d34ab
|
|
187
189
|
def conda_output_path(name, build='build'):
|
|
188
190
|
"Output path for conda build"
|
|
189
191
|
return run(f'conda {build} --output {name}').strip().replace('\\', '/')
|
|
190
192
|
|
|
191
|
-
# %% ../nbs/api/18_release.ipynb
|
|
193
|
+
# %% ../nbs/api/18_release.ipynb #99fb71c2
|
|
192
194
|
def _write_yaml(path, name, d1, d2):
|
|
193
195
|
path = Path(path)
|
|
194
196
|
p = path/name
|
|
@@ -198,7 +200,7 @@ def _write_yaml(path, name, d1, d2):
|
|
|
198
200
|
yaml.safe_dump(d1, f)
|
|
199
201
|
yaml.safe_dump(d2, f)
|
|
200
202
|
|
|
201
|
-
# %% ../nbs/api/18_release.ipynb
|
|
203
|
+
# %% ../nbs/api/18_release.ipynb #5c78f115
|
|
202
204
|
def _get_conda_meta():
|
|
203
205
|
cfg = get_config()
|
|
204
206
|
name,ver = cfg.lib_name,cfg.version
|
|
@@ -240,12 +242,12 @@ def _get_conda_meta():
|
|
|
240
242
|
}
|
|
241
243
|
return name,d1,d2
|
|
242
244
|
|
|
243
|
-
# %% ../nbs/api/18_release.ipynb
|
|
245
|
+
# %% ../nbs/api/18_release.ipynb #b911bd4d
|
|
244
246
|
def write_conda_meta(path='conda'):
|
|
245
247
|
"Writes a `meta.yaml` file to the `conda` directory of the current directory"
|
|
246
248
|
_write_yaml(path, *_get_conda_meta())
|
|
247
249
|
|
|
248
|
-
# %% ../nbs/api/18_release.ipynb
|
|
250
|
+
# %% ../nbs/api/18_release.ipynb #7550557f
|
|
249
251
|
@call_parse
|
|
250
252
|
def write_requirements(path:str=''):
|
|
251
253
|
"Writes a `requirements.txt` file to `directory` based on settings.ini."
|
|
@@ -254,7 +256,7 @@ def write_requirements(path:str=''):
|
|
|
254
256
|
req = '\n'.join([cfg.get(k, '').replace(' ', '\n') for k in ['requirements', 'pip_requirements']])
|
|
255
257
|
(d/'requirements.txt').mk_write(req)
|
|
256
258
|
|
|
257
|
-
# %% ../nbs/api/18_release.ipynb
|
|
259
|
+
# %% ../nbs/api/18_release.ipynb #715ae3ac
|
|
258
260
|
CONDA_WARNING='Conda support for nbdev is deprecated and scheduled for removal in a future version.'
|
|
259
261
|
|
|
260
262
|
def anaconda_upload(name, loc=None, user=None, token=None, env_token=None):
|
|
@@ -267,7 +269,7 @@ def anaconda_upload(name, loc=None, user=None, token=None, env_token=None):
|
|
|
267
269
|
if not loc: raise Exception("Failed to find output")
|
|
268
270
|
return _run(f'anaconda {token} upload {user} {loc} --skip-existing')
|
|
269
271
|
|
|
270
|
-
# %% ../nbs/api/18_release.ipynb
|
|
272
|
+
# %% ../nbs/api/18_release.ipynb #952bc33d
|
|
271
273
|
@call_parse
|
|
272
274
|
def release_conda(
|
|
273
275
|
path:str='conda', # Path where package will be created
|
|
@@ -299,7 +301,7 @@ def release_conda(
|
|
|
299
301
|
if 'anaconda upload' not in res: return print(f"{res}\n\nFailed. Check auto-upload not set in .condarc. Try `--do_build False`.")
|
|
300
302
|
return anaconda_upload(name, loc)
|
|
301
303
|
|
|
302
|
-
# %% ../nbs/api/18_release.ipynb
|
|
304
|
+
# %% ../nbs/api/18_release.ipynb #0500d972
|
|
303
305
|
def chk_conda_rel(
|
|
304
306
|
nm:str, # Package name on pypi
|
|
305
307
|
apkg:str=None, # Anaconda Package (defaults to {nm})
|
|
@@ -313,7 +315,7 @@ def chk_conda_rel(
|
|
|
313
315
|
pypitag = latest_pypi(nm)
|
|
314
316
|
if force or not condatag or pypitag > max(condatag): return f'{pypitag}'
|
|
315
317
|
|
|
316
|
-
# %% ../nbs/api/18_release.ipynb
|
|
318
|
+
# %% ../nbs/api/18_release.ipynb #bf55df9b
|
|
317
319
|
@call_parse
|
|
318
320
|
def release_pypi(
|
|
319
321
|
repository:str="pypi" # Respository to upload to (defined in ~/.pypirc)
|
|
@@ -323,7 +325,7 @@ def release_pypi(
|
|
|
323
325
|
system(f'cd {_dir} && rm -rf dist build && python -m build')
|
|
324
326
|
system(f'twine upload --repository {repository} {_dir}/dist/*')
|
|
325
327
|
|
|
326
|
-
# %% ../nbs/api/18_release.ipynb
|
|
328
|
+
# %% ../nbs/api/18_release.ipynb #06edfcb0
|
|
327
329
|
@call_parse
|
|
328
330
|
def release_both(
|
|
329
331
|
path:str='conda', # Path where package will be created
|
|
@@ -339,7 +341,7 @@ def release_both(
|
|
|
339
341
|
release_conda.__wrapped__(path, do_build=do_build, build_args=build_args, skip_upload=skip_upload, mambabuild=mambabuild, upload_user=upload_user)
|
|
340
342
|
nbdev_bump_version.__wrapped__()
|
|
341
343
|
|
|
342
|
-
# %% ../nbs/api/18_release.ipynb
|
|
344
|
+
# %% ../nbs/api/18_release.ipynb #6380dd5a
|
|
343
345
|
def bump_version(version, part=2, unbump=False):
|
|
344
346
|
version = version.split('.')
|
|
345
347
|
incr = -1 if unbump else 1
|
|
@@ -347,7 +349,7 @@ def bump_version(version, part=2, unbump=False):
|
|
|
347
349
|
for i in range(part+1, 3): version[i] = '0'
|
|
348
350
|
return '.'.join(version)
|
|
349
351
|
|
|
350
|
-
# %% ../nbs/api/18_release.ipynb
|
|
352
|
+
# %% ../nbs/api/18_release.ipynb #c0f64b2c
|
|
351
353
|
@call_parse
|
|
352
354
|
def nbdev_bump_version(
|
|
353
355
|
part:int=2, # Part of version to bump
|
nbdev/serve.py
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/17_serve.ipynb.
|
|
4
4
|
|
|
5
|
-
# %% auto 0
|
|
5
|
+
# %% auto #0
|
|
6
6
|
__all__ = ['proc_nbs']
|
|
7
7
|
|
|
8
|
-
# %% ../nbs/api/17_serve.ipynb
|
|
8
|
+
# %% ../nbs/api/17_serve.ipynb #6899a335
|
|
9
9
|
import ast,subprocess,threading,sys
|
|
10
10
|
from shutil import rmtree,copy2
|
|
11
11
|
|
|
@@ -19,7 +19,7 @@ from .doclinks import nbglob_cli,nbglob
|
|
|
19
19
|
from .processors import FilterDefaults
|
|
20
20
|
import nbdev.serve_drv
|
|
21
21
|
|
|
22
|
-
# %% ../nbs/api/17_serve.ipynb
|
|
22
|
+
# %% ../nbs/api/17_serve.ipynb #65766a33
|
|
23
23
|
def _is_qpy(path:Path):
|
|
24
24
|
"Is `path` a py script starting with frontmatter?"
|
|
25
25
|
path = Path(path)
|
|
@@ -34,7 +34,7 @@ def _is_qpy(path:Path):
|
|
|
34
34
|
vl = v.splitlines()
|
|
35
35
|
if vl[0]=='---' and vl[-1]=='---': return '\n'.join(vl[1:-1])
|
|
36
36
|
|
|
37
|
-
# %% ../nbs/api/17_serve.ipynb
|
|
37
|
+
# %% ../nbs/api/17_serve.ipynb #abc3835a
|
|
38
38
|
def _proc_file(s, cache, path, mtime=None):
|
|
39
39
|
skips = ('_proc', '_docs', '_site', 'settings.ini')
|
|
40
40
|
if not s.is_file() or any(o[0]=='.' or o in skips for o in s.parts): return
|
|
@@ -51,7 +51,7 @@ def _proc_file(s, cache, path, mtime=None):
|
|
|
51
51
|
if md is not None: return s,d,md.strip()
|
|
52
52
|
else: copy2(s,d)
|
|
53
53
|
|
|
54
|
-
# %% ../nbs/api/17_serve.ipynb
|
|
54
|
+
# %% ../nbs/api/17_serve.ipynb #14463227
|
|
55
55
|
@delegates(nbglob_cli)
|
|
56
56
|
def proc_nbs(
|
|
57
57
|
path:str='', # Path to notebooks
|
nbdev/showdoc.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/08_showdoc.ipynb.
|
|
4
4
|
|
|
5
|
-
# %% ../nbs/api/08_showdoc.ipynb
|
|
5
|
+
# %% ../nbs/api/08_showdoc.ipynb #7f371f15
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
from .doclinks import *
|
|
8
8
|
from .config import get_config
|
|
@@ -16,10 +16,10 @@ from collections import OrderedDict
|
|
|
16
16
|
from textwrap import fill
|
|
17
17
|
from types import FunctionType
|
|
18
18
|
|
|
19
|
-
# %% auto 0
|
|
19
|
+
# %% auto #0
|
|
20
20
|
__all__ = ['BasicMarkdownRenderer', 'show_doc', 'doc', 'showdoc_nm', 'colab_link']
|
|
21
21
|
|
|
22
|
-
# %% ../nbs/api/08_showdoc.ipynb
|
|
22
|
+
# %% ../nbs/api/08_showdoc.ipynb #abe98f5c
|
|
23
23
|
def _ext_link(url, txt, xtra=""): return f'[{txt}]({url}){{target="_blank" {xtra}}}'
|
|
24
24
|
|
|
25
25
|
class BasicMarkdownRenderer(MarkdownRenderer):
|
|
@@ -32,7 +32,7 @@ class BasicMarkdownRenderer(MarkdownRenderer):
|
|
|
32
32
|
doc += f'{h} {self.nm}\n\n'
|
|
33
33
|
return doc+super()._repr_markdown_()
|
|
34
34
|
|
|
35
|
-
# %% ../nbs/api/08_showdoc.ipynb
|
|
35
|
+
# %% ../nbs/api/08_showdoc.ipynb #1256ef79
|
|
36
36
|
def show_doc(sym, # Symbol to document
|
|
37
37
|
renderer=None, # Optional renderer (defaults to markdown)
|
|
38
38
|
name:str|None=None, # Optionally override displayed name of `sym`
|
|
@@ -47,17 +47,17 @@ def show_doc(sym, # Symbol to document
|
|
|
47
47
|
elif isinstance_str(sym, "TypeDispatch"): pass # use _str as TypeDispatch will be removed from fastcore
|
|
48
48
|
else:return renderer(sym or show_doc, name=name, title_level=title_level)
|
|
49
49
|
|
|
50
|
-
# %% ../nbs/api/08_showdoc.ipynb
|
|
50
|
+
# %% ../nbs/api/08_showdoc.ipynb #eb1f0530
|
|
51
51
|
def doc(elt):
|
|
52
52
|
"Show `show_doc` info along with link to docs"
|
|
53
53
|
return BasicMarkdownRenderer(elt)
|
|
54
54
|
|
|
55
|
-
# %% ../nbs/api/08_showdoc.ipynb
|
|
55
|
+
# %% ../nbs/api/08_showdoc.ipynb #35043aa7-6b60-4ddf-8949-39a78577f23d
|
|
56
56
|
def showdoc_nm(tree):
|
|
57
57
|
"Get the fully qualified name for showdoc."
|
|
58
58
|
return ifnone(patch_name(tree), tree.name)
|
|
59
59
|
|
|
60
|
-
# %% ../nbs/api/08_showdoc.ipynb
|
|
60
|
+
# %% ../nbs/api/08_showdoc.ipynb #e947414d
|
|
61
61
|
def colab_link(path):
|
|
62
62
|
"Get a link to the notebook at `path` on Colab"
|
|
63
63
|
from IPython.display import Markdown
|
nbdev/sync.py
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/06_sync.ipynb.
|
|
4
4
|
|
|
5
|
-
# %% auto 0
|
|
5
|
+
# %% auto #0
|
|
6
6
|
__all__ = ['absolute_import', 'nbdev_update']
|
|
7
7
|
|
|
8
|
-
# %% ../nbs/api/06_sync.ipynb
|
|
8
|
+
# %% ../nbs/api/06_sync.ipynb #ea6a935c
|
|
9
9
|
from .imports import *
|
|
10
10
|
from .config import *
|
|
11
11
|
from .maker import *
|
|
@@ -21,7 +21,7 @@ from fastcore.xtras import *
|
|
|
21
21
|
import ast
|
|
22
22
|
import importlib
|
|
23
23
|
|
|
24
|
-
# %% ../nbs/api/06_sync.ipynb
|
|
24
|
+
# %% ../nbs/api/06_sync.ipynb #fde5667d
|
|
25
25
|
def absolute_import(name, fname, level):
|
|
26
26
|
"Unwarps a relative import in `name` according to `fname`"
|
|
27
27
|
if not level: return name
|
|
@@ -29,7 +29,7 @@ def absolute_import(name, fname, level):
|
|
|
29
29
|
if not name: return '.'.join(mods)
|
|
30
30
|
return '.'.join(mods[:len(mods)-level+1]) + f".{name}"
|
|
31
31
|
|
|
32
|
-
# %% ../nbs/api/06_sync.ipynb
|
|
32
|
+
# %% ../nbs/api/06_sync.ipynb #54ab1e17
|
|
33
33
|
@functools.lru_cache(maxsize=None)
|
|
34
34
|
def _mod_files():
|
|
35
35
|
midx_spec = importlib.util.spec_from_file_location("_modidx", get_config().lib_path / "_modidx.py")
|
|
@@ -38,41 +38,44 @@ def _mod_files():
|
|
|
38
38
|
|
|
39
39
|
return L(files for mod in midx.d['syms'].values() for _,files in mod.values()).unique()
|
|
40
40
|
|
|
41
|
-
# %% ../nbs/api/06_sync.ipynb
|
|
41
|
+
# %% ../nbs/api/06_sync.ipynb #64d51ab6
|
|
42
42
|
_re_import = re.compile(r"from\s+\S+\s+import\s+\S")
|
|
43
43
|
|
|
44
|
-
# %% ../nbs/api/06_sync.ipynb
|
|
44
|
+
# %% ../nbs/api/06_sync.ipynb #9075f993
|
|
45
45
|
def _to_absolute(code, py_path, lib_dir):
|
|
46
46
|
if not _re_import.search(code): return code
|
|
47
47
|
res = update_import(code, ast.parse(code).body, str(py_path.relative_to(lib_dir).parent), absolute_import)
|
|
48
48
|
return ''.join(res) if res else code
|
|
49
49
|
|
|
50
|
-
# %% ../nbs/api/06_sync.ipynb
|
|
50
|
+
# %% ../nbs/api/06_sync.ipynb #27ae8834
|
|
51
51
|
def _update_nb(nb_path, cells, lib_dir):
|
|
52
52
|
"Update notebook `nb_path` with contents from `cells`"
|
|
53
53
|
nbp = NBProcessor(nb_path, ExportModuleProc(), rm_directives=False)
|
|
54
54
|
nbp.process()
|
|
55
|
+
# Build a dict of cell_id -> cell for fast lookup
|
|
56
|
+
nb_cells_by_id = {c['id']: c for c in nbp.nb.cells if c.get('id')}
|
|
55
57
|
for cell in cells:
|
|
56
58
|
assert cell.nb_path == nb_path
|
|
57
|
-
nbcell =
|
|
59
|
+
nbcell = nb_cells_by_id.get(cell.cell_id)
|
|
60
|
+
if nbcell is None:
|
|
61
|
+
raise ValueError(f"Cell ID '{cell.cell_id}' not found in notebook '{nb_path}'")
|
|
58
62
|
dirs,_ = _partition_cell(nbcell, 'python')
|
|
59
63
|
nbcell.source = ''.join(dirs) + _to_absolute(cell.code, cell.py_path, lib_dir)
|
|
60
64
|
write_nb(nbp.nb, nb_path)
|
|
61
65
|
|
|
62
|
-
# %% ../nbs/api/06_sync.ipynb
|
|
66
|
+
# %% ../nbs/api/06_sync.ipynb #46c9e605
|
|
63
67
|
def _update_mod(py_path, lib_dir):
|
|
64
68
|
"Propagate changes from cells in module `py_path` to corresponding notebooks"
|
|
65
69
|
py_cells = L(_iter_py_cells(py_path)).filter(lambda o: o.nb != 'auto')
|
|
66
70
|
for nb_path,cells in groupby(py_cells, 'nb_path').items(): _update_nb(nb_path, cells, lib_dir)
|
|
67
71
|
|
|
68
|
-
# %% ../nbs/api/06_sync.ipynb
|
|
72
|
+
# %% ../nbs/api/06_sync.ipynb #60b5b528
|
|
69
73
|
@call_parse
|
|
70
74
|
def nbdev_update(fname:str=None): # A Python file name to update
|
|
71
75
|
"Propagate change in modules matching `fname` to notebooks that created them"
|
|
72
76
|
if fname and fname.endswith('.ipynb'): raise ValueError("`nbdev_update` operates on .py files. If you wish to convert notebooks instead, see `nbdev_export`.")
|
|
73
77
|
if os.environ.get('IN_TEST',0): return
|
|
74
78
|
cfg = get_config()
|
|
75
|
-
if not cfg.cell_number: raise ValueError("`nbdev_update` does not support without cell_number in .py files. Please check your settings.ini")
|
|
76
79
|
fname = Path(fname or cfg.lib_path)
|
|
77
80
|
lib_dir = cfg.lib_path.parent
|
|
78
81
|
files = globtastic(fname, file_glob='*.py', skip_folder_re='^[_.]').filter(lambda x: str(Path(x).absolute().relative_to(lib_dir) in _mod_files()))
|
nbdev/test.py
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/12_test.ipynb.
|
|
4
4
|
|
|
5
|
-
# %% auto 0
|
|
5
|
+
# %% auto #0
|
|
6
6
|
__all__ = ['test_nb', 'nbdev_test']
|
|
7
7
|
|
|
8
|
-
# %% ../nbs/api/12_test.ipynb
|
|
8
|
+
# %% ../nbs/api/12_test.ipynb #45e10c3f
|
|
9
9
|
import time,os,sys,traceback,contextlib, inspect
|
|
10
10
|
from fastcore.basics import *
|
|
11
11
|
from fastcore.imports import *
|
|
@@ -22,7 +22,7 @@ from .frontmatter import FrontmatterProc
|
|
|
22
22
|
from execnb.nbio import *
|
|
23
23
|
from execnb.shell import *
|
|
24
24
|
|
|
25
|
-
# %% ../nbs/api/12_test.ipynb
|
|
25
|
+
# %% ../nbs/api/12_test.ipynb #3f4fa1ad
|
|
26
26
|
def test_nb(fn, # file name of notebook to test
|
|
27
27
|
skip_flags=None, # list of flags marking cells to skip
|
|
28
28
|
force_flags=None, # list of flags marking cells to always run
|
|
@@ -57,7 +57,7 @@ def test_nb(fn, # file name of notebook to test
|
|
|
57
57
|
if do_print: print(f'- Completed {fn}')
|
|
58
58
|
return res,time.time()-start
|
|
59
59
|
|
|
60
|
-
# %% ../nbs/api/12_test.ipynb
|
|
60
|
+
# %% ../nbs/api/12_test.ipynb #d8bf1f1b-935d-4b69-ba96-827c5d7213f0
|
|
61
61
|
def _keep_file(p:Path, # filename for which to check for `indicator_fname`
|
|
62
62
|
ignore_fname:str # filename that will result in siblings being ignored
|
|
63
63
|
) -> bool:
|
|
@@ -65,7 +65,7 @@ def _keep_file(p:Path, # filename for which to check for `indicator_fname`
|
|
|
65
65
|
if p.exists(): return not bool(p.parent.ls().attrgot('name').filter(lambda x: x == ignore_fname))
|
|
66
66
|
else: True
|
|
67
67
|
|
|
68
|
-
# %% ../nbs/api/12_test.ipynb
|
|
68
|
+
# %% ../nbs/api/12_test.ipynb #f8cc6a61-a48e-4ab1-89a9-18316ca795d6
|
|
69
69
|
@call_parse
|
|
70
70
|
@delegates(nbglob_cli)
|
|
71
71
|
def nbdev_test(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nbdev
|
|
3
|
-
Version: 2.4.
|
|
3
|
+
Version: 2.4.12
|
|
4
4
|
Summary: Create delightful software with Jupyter Notebooks
|
|
5
5
|
Home-page: https://github.com/AnswerDotAI/nbdev
|
|
6
6
|
Author: Jeremy Howard and Hamel Husain
|
|
@@ -20,7 +20,7 @@ Requires-Python: >=3.9
|
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
21
|
License-File: LICENSE
|
|
22
22
|
Requires-Dist: packaging
|
|
23
|
-
Requires-Dist: fastcore>=1.
|
|
23
|
+
Requires-Dist: fastcore>=1.12.1
|
|
24
24
|
Requires-Dist: execnb>=0.1.12
|
|
25
25
|
Requires-Dist: astunparse
|
|
26
26
|
Requires-Dist: ghapi>=1.0.3
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
nbdev/__init__.py,sha256=wJvo0zLx3LH6VkyN8kEpzNsHxxT5O1-D3CLqwlnDi6w,90
|
|
2
|
+
nbdev/_modidx.py,sha256=9Ha0XafZNcnsUIju5aJx7GVqkgwX35vVGanoCgfbN-s,38372
|
|
3
|
+
nbdev/clean.py,sha256=rTLJsz_gNqd9TdTBLmEuexXN6lZPCq6PVS_Xd4JGMZ0,9748
|
|
4
|
+
nbdev/cli.py,sha256=csOPIFIz8fouyjTx-OX_0it1Fts-Z_c72dnIOxXxGDc,7588
|
|
5
|
+
nbdev/config.py,sha256=01DWLwkfdsn7TkYklO52LagvzI8UenfEga1GwyAxc-o,13760
|
|
6
|
+
nbdev/diff.py,sha256=8vzFbmk8jmn4LW66wXEDJVxsJTf4eegNMbBVV4jI708,3794
|
|
7
|
+
nbdev/doclinks.py,sha256=_t7frF7hdboJLJmYoPfjOiSvkSBtTKlh4AcjyTeD3XQ,12806
|
|
8
|
+
nbdev/export.py,sha256=CVJGQ8suzO2LZHqVCzJKjmoR42R5yTRWA76KY1sWnQA,4122
|
|
9
|
+
nbdev/extract_attachments.py,sha256=O4mS4EFIOXL_yQ3jmsnBStrWxGR_nPNvxLYXHtLeimw,2208
|
|
10
|
+
nbdev/frontmatter.py,sha256=CdJj6B1NyodH--uOCfWhGK0vI7gnKp-i2EzKce47kQQ,2820
|
|
11
|
+
nbdev/imports.py,sha256=f5Ynco14hsJyFCf43-uP_YARMhHADe6lM-20Mc_vXhw,95
|
|
12
|
+
nbdev/maker.py,sha256=OG0l-L-_zzErA5boWpt-0Ozi8eZU_2SSbY_-peo13_E,10011
|
|
13
|
+
nbdev/merge.py,sha256=WOjbqKwDfNK16L9P-eZ-IPUTgC1brOWg6jaKfDziDIc,4432
|
|
14
|
+
nbdev/migrate.py,sha256=uhmkStmHPb082VDKnAPlD2vOVUi1iYOYdKzqHwF12cc,7902
|
|
15
|
+
nbdev/process.py,sha256=cSKAdQ-KDPv6UNLqii61SnmFsw8qmcY-YwBPUbwRd18,6163
|
|
16
|
+
nbdev/processors.py,sha256=SL4Y4ha1ZQU-dV1nZyyb68viq0X2tE2PfBX26_LEzYY,12364
|
|
17
|
+
nbdev/qmd.py,sha256=4_paV81SjRh2TmDS5tyu8Y2TW1X_yg0PYGAi6fOw3ek,3129
|
|
18
|
+
nbdev/quarto.py,sha256=Hfxj_bCrm0OlKGh6S954d1E2BCfPL1q0901RRvC4bCA,14119
|
|
19
|
+
nbdev/release.py,sha256=-cSl2u_SW6eGrppd3KyaMRmfeAv1QSw9PEhAzdw-9NA,14985
|
|
20
|
+
nbdev/serve.py,sha256=XqTB9Mjgs_X3U5VNJ-vPbx2rs8ayBog5cfPiFumBPt4,3187
|
|
21
|
+
nbdev/serve_drv.py,sha256=IZ2acem_KKsXYYe0iUECiR_orkYLBkT1ZG_258ZS7SQ,657
|
|
22
|
+
nbdev/showdoc.py,sha256=rgVpHGVQi14RBdLYnh3ukPPG9EEKGyTMW_zGAH7HM7o,2657
|
|
23
|
+
nbdev/sync.py,sha256=eMYZYzu3RMDWjY-apr2TyzB7cTEB9v5-svF_Z--xyj8,3391
|
|
24
|
+
nbdev/test.py,sha256=74rkaOEY4KOeosB84V3DYvUsv-klVDdubuw_SWL7-vo,4532
|
|
25
|
+
nbdev-2.4.12.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
26
|
+
nbdev-2.4.12.dist-info/METADATA,sha256=aoC_LZaEl9-RYtyhOVobGdRMdUrZ_ZvzUXdso5DRinU,10829
|
|
27
|
+
nbdev-2.4.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
28
|
+
nbdev-2.4.12.dist-info/entry_points.txt,sha256=1ADLbIIJxZeLgOD8NpizkPULSsd_fgUQxwAkbGk45b8,1453
|
|
29
|
+
nbdev-2.4.12.dist-info/top_level.txt,sha256=3cWYLMuaXsZjz3TQRGEkWGs9Z8ieEDmYcq8TZS3y3vU,6
|
|
30
|
+
nbdev-2.4.12.dist-info/RECORD,,
|
nbdev-2.4.10.dist-info/RECORD
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
nbdev/__init__.py,sha256=6pmhzoYJxTVV23XmtU6yYznRmk1Lt_Yn1G7IKpaXyjU,90
|
|
2
|
-
nbdev/_modidx.py,sha256=v15TNw1xI8HShoTH1aNwH-Rt_c5-uYfcmf2nlNuSGFI,38256
|
|
3
|
-
nbdev/clean.py,sha256=Ge3Hke1c1ArJ9-6P-Z11dXUfnQ7ZrYRnHHXPTAbJG4I,9412
|
|
4
|
-
nbdev/cli.py,sha256=ntu9hqDVD8t32AuveuJ-1xBGn_-KD3AUX1TG37K00w8,7309
|
|
5
|
-
nbdev/config.py,sha256=KmPAtLwsX819gA7TVJ40v-B4ok978b79pbqMF5WnAJE,13500
|
|
6
|
-
nbdev/diff.py,sha256=gSJNvjqbcuNlGD6d_BOlp7uQ0yLCLEfspCSIxOwnRuE,3713
|
|
7
|
-
nbdev/doclinks.py,sha256=fDnlqKaRHCBCS1CVbmqhGNsiaKeEMF2hS-pNFHc8JYE,12632
|
|
8
|
-
nbdev/export.py,sha256=y3AmFyAZ6gNYDMmxgIooyLkvjx02xU9DDaT0Wur00i8,4061
|
|
9
|
-
nbdev/extract_attachments.py,sha256=O4mS4EFIOXL_yQ3jmsnBStrWxGR_nPNvxLYXHtLeimw,2208
|
|
10
|
-
nbdev/frontmatter.py,sha256=i195bhDLWd-WUEzQT9JBoA4Ee3j6gD1dKMT8yk5fF4Y,2761
|
|
11
|
-
nbdev/imports.py,sha256=f5Ynco14hsJyFCf43-uP_YARMhHADe6lM-20Mc_vXhw,95
|
|
12
|
-
nbdev/maker.py,sha256=oDs5jOZBcGWRcj6hy7zhKpSfASZqQrni_d8pIjDmFYE,9859
|
|
13
|
-
nbdev/merge.py,sha256=xmT7LMY_mQGOGl0ynqkB13M6HwJfUOTis1Xl--YDXR8,4341
|
|
14
|
-
nbdev/migrate.py,sha256=YJTtWC6TPaZpZTcD0Jex6stOSumjju2QrUozF9rvl0Y,7311
|
|
15
|
-
nbdev/process.py,sha256=NZlJnGaEoDMNAROktBNbW5BAqX_tMyPOcDF5rP5HeZg,5854
|
|
16
|
-
nbdev/processors.py,sha256=fS4WrowC8bi6sFJJUVA9r9IRgmk-gffrJ9zNfb7vpIM,11973
|
|
17
|
-
nbdev/qmd.py,sha256=VAxE-c1sT7y26VdyreB6j9fge-CuLbHWocRE_WbnYXg,2994
|
|
18
|
-
nbdev/quarto.py,sha256=n6Pytml1gwpn45vNzoc4_JRPRkC4pYE3BiVRNODpBtI,13796
|
|
19
|
-
nbdev/release.py,sha256=Oxqz5X61Zgs9DILNn9h0Njr0Q21fc3XTWJQ8jeZ3Y44,14572
|
|
20
|
-
nbdev/serve.py,sha256=HcYoNQiSROdMS1J8YlOlyTya-LmmrR-8v3ho5D9g700,3146
|
|
21
|
-
nbdev/serve_drv.py,sha256=IZ2acem_KKsXYYe0iUECiR_orkYLBkT1ZG_258ZS7SQ,657
|
|
22
|
-
nbdev/showdoc.py,sha256=BqbrmS2dUpfocRTtTu5tD7-EiQ07rxHoiZCETeMJEtc,2570
|
|
23
|
-
nbdev/sync.py,sha256=ld-lSOmlX1FdnTOzaSHcxKyIuIguI_SpluqfPSH2BZ8,3201
|
|
24
|
-
nbdev/test.py,sha256=_ECBd5fvfGEICIfkTI2S8w8YatL5CaPltCeDSsiH6yw,4435
|
|
25
|
-
nbdev-2.4.10.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
26
|
-
nbdev-2.4.10.dist-info/METADATA,sha256=X9nDa0z81SKL_GqX2I4Tv7m_AdYW-7JKpZQ8_01jA8c,10829
|
|
27
|
-
nbdev-2.4.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
28
|
-
nbdev-2.4.10.dist-info/entry_points.txt,sha256=1ADLbIIJxZeLgOD8NpizkPULSsd_fgUQxwAkbGk45b8,1453
|
|
29
|
-
nbdev-2.4.10.dist-info/top_level.txt,sha256=3cWYLMuaXsZjz3TQRGEkWGs9Z8ieEDmYcq8TZS3y3vU,6
|
|
30
|
-
nbdev-2.4.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|