marimo-dev 0.4.0__tar.gz → 0.4.1__tar.gz
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.
- {marimo_dev-0.4.0 → marimo_dev-0.4.1}/PKG-INFO +1 -1
- {marimo_dev-0.4.0 → marimo_dev-0.4.1}/pyproject.toml +1 -1
- {marimo_dev-0.4.0 → marimo_dev-0.4.1}/src/marimo_dev/__init__.py +1 -1
- {marimo_dev-0.4.0 → marimo_dev-0.4.1}/src/marimo_dev/build_pkg.py +22 -10
- {marimo_dev-0.4.0 → marimo_dev-0.4.1}/README.md +0 -0
- {marimo_dev-0.4.0 → marimo_dev-0.4.1}/src/marimo_dev/build_docs.py +0 -0
- {marimo_dev-0.4.0 → marimo_dev-0.4.1}/src/marimo_dev/cli.py +0 -0
- {marimo_dev-0.4.0 → marimo_dev-0.4.1}/src/marimo_dev/parse.py +0 -0
- {marimo_dev-0.4.0 → marimo_dev-0.4.1}/src/marimo_dev/publish.py +0 -0
- {marimo_dev-0.4.0 → marimo_dev-0.4.1}/src/marimo_dev/types.py +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"""Build and publish python packages from marimo notebooks"""
|
|
2
|
-
__version__ = '0.4.
|
|
2
|
+
__version__ = '0.4.1'
|
|
3
3
|
__author__ = 'Deufel'
|
|
4
4
|
from .types import rename, Config, Param, Return, Method, Import, Const, Setup, ExportKind, Export, Module, Meta, Project
|
|
5
5
|
from .parse import read_config, read_project
|
|
@@ -45,11 +45,11 @@ def _write_module(
|
|
|
45
45
|
imports = '\n'.join(_rewrite_import(i.src, mod_names) for i in mod.imports)
|
|
46
46
|
consts = '\n'.join(c.src for c in mod.consts)
|
|
47
47
|
setup = '\n'.join(s.src for s in mod.setup)
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
exp_src = '\n\n'.join(
|
|
50
50
|
_apply_renames(e.clean_src, e.name, e.final_name) for e in mod.exports
|
|
51
51
|
)
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
# Fix cross-references to renamed symbols
|
|
54
54
|
rename_map = {
|
|
55
55
|
e.name: e.final_name
|
|
@@ -58,7 +58,7 @@ def _write_module(
|
|
|
58
58
|
}
|
|
59
59
|
for old, new in rename_map.items():
|
|
60
60
|
exp_src = re.sub(rf'\b{re.escape(old)}\b', new, exp_src)
|
|
61
|
-
|
|
61
|
+
|
|
62
62
|
_write(path, imports, consts, setup, exp_src)
|
|
63
63
|
|
|
64
64
|
def _write_init(
|
|
@@ -70,18 +70,18 @@ def _write_init(
|
|
|
70
70
|
lines = [f'"""{meta.desc}"""', f"__version__ = '{meta.version}'"]
|
|
71
71
|
if meta.author:
|
|
72
72
|
lines.append(f"__author__ = '{meta.author.split('<')[0].strip()}'")
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
all_exports = []
|
|
75
75
|
for mod in proj.modules:
|
|
76
76
|
pub = [e.final_name for e in mod.public_exports]
|
|
77
77
|
if pub:
|
|
78
78
|
lines.append(f"from .{mod.name} import {', '.join(pub)}")
|
|
79
79
|
all_exports.extend(pub)
|
|
80
|
-
|
|
80
|
+
|
|
81
81
|
if all_exports:
|
|
82
82
|
entries = '\n'.join(f' "{n}",' for n in sorted(all_exports))
|
|
83
83
|
lines.append(f'__all__ = [\n{entries}\n]')
|
|
84
|
-
|
|
84
|
+
|
|
85
85
|
_write(path, '\n'.join(lines))
|
|
86
86
|
|
|
87
87
|
def _write_main(
|
|
@@ -116,16 +116,16 @@ def build(
|
|
|
116
116
|
pkg = Path(cfg.root) / cfg.out / meta.pkg_name
|
|
117
117
|
if pkg.exists(): shutil.rmtree(pkg)
|
|
118
118
|
pkg.mkdir(parents=True, exist_ok=True)
|
|
119
|
-
|
|
119
|
+
|
|
120
120
|
mod_names = proj.mod_names
|
|
121
121
|
for mod in proj.modules:
|
|
122
122
|
if mod.name != 'index' and mod.has_exports:
|
|
123
123
|
_write_module(pkg / f'{mod.name}.py', mod, mod_names)
|
|
124
|
-
|
|
124
|
+
|
|
125
125
|
_write_init(pkg / '__init__.py', proj)
|
|
126
126
|
if cfg.app_parts:
|
|
127
127
|
_write_main(pkg / '__main__.py', cfg.app_parts)
|
|
128
|
-
|
|
128
|
+
|
|
129
129
|
return str(pkg)
|
|
130
130
|
|
|
131
131
|
def bundle(
|
|
@@ -169,7 +169,19 @@ def bundle(
|
|
|
169
169
|
imports = '\n'.join(external_imports)
|
|
170
170
|
consts = '\n'.join(c.src for m in proj.modules for c in m.consts)
|
|
171
171
|
setup = '\n'.join(s.src for m in proj.modules for s in m.setup)
|
|
172
|
-
|
|
172
|
+
|
|
173
|
+
# Apply renames to exports and fix cross-references
|
|
174
|
+
exports = '\n\n'.join(
|
|
175
|
+
_apply_renames(e.clean_src, e.name, e.final_name)
|
|
176
|
+
for m in proj.modules for e in m.exports
|
|
177
|
+
)
|
|
178
|
+
rename_map = {
|
|
179
|
+
e.name: e.final_name
|
|
180
|
+
for m in proj.modules for e in m.exports
|
|
181
|
+
if e.final_name != e.name
|
|
182
|
+
}
|
|
183
|
+
for old, new in rename_map.items():
|
|
184
|
+
exports = re.sub(rf'\b{re.escape(old)}\b', new, exports)
|
|
173
185
|
|
|
174
186
|
sections = [header, imports, consts, setup, exports]
|
|
175
187
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|