marimo-dev 0.1.0__tar.gz → 0.1.2__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.
@@ -0,0 +1,94 @@
1
+ Metadata-Version: 2.3
2
+ Name: marimo-dev
3
+ Version: 0.1.2
4
+ Summary: Build and publish python packages from marimo notebooks
5
+ Author: Deufel
6
+ Author-email: Deufel <MDeufel13@gmail.com>
7
+ License: MIT
8
+ Requires-Python: >=3.12
9
+ Description-Content-Type: text/markdown
10
+
11
+ # marimo_dev
12
+
13
+ A literate programming build system that converts Marimo notebooks into distributable Python packages. Inspired by nbdev.
14
+
15
+
16
+ ## What it does
17
+
18
+ Looks in `/notebooks` dir for [self contained functions and classes](https://docs.marimo.io/guides/reusing_functions/) and extracts them into a PyPI ready directory. Each notebook will be striped of the leading `##_`, and `XX_` and `test` notebooks will be ignored. Run `md build` to generate a proper Python package with `__init__.py`, module files, and `llms.txt` API documentation.
19
+
20
+ ## What it does not
21
+
22
+ An intentional effort to minimise magic project set up. You are responsible for setting up your pyproject.toml, and even `mkdir notebooks`.
23
+ **Note:** *I highly reccommend that you use uv my main motivation for making this was the dependency harmony betwwen marimo and uv*
24
+
25
+
26
+
27
+ ## Project structure
28
+
29
+ ```
30
+ my-project/
31
+ ├── README.md
32
+ ├── pyproject.toml
33
+ ├── notebooks/
34
+ │ ├── 01_core.py
35
+ │ ├── 02_read.py
36
+ │ ├── ...
37
+ ├── src/ # auto created
38
+ │ └── my_package/
39
+ │ ├── __init__.py
40
+ │ ├── core.py
41
+ │ ├── read.py
42
+ │ └── ...
43
+ ├── docs/ # auto created
44
+ │ ├── index.html # Fut ver. 0.2
45
+ │ └── llms.txt
46
+ └── dist/ # auto created
47
+ └──...
48
+ ```
49
+
50
+ ## How it works
51
+
52
+ The build system parses notebooks via AST, extracts decorated exports (`@app.function`, `@app.class_definition`), and writes clean module files. It reads metadata from `pyproject.toml` and generates `__init__.py` with proper imports and `__all__` exports.
53
+
54
+ The `llms.txt` file contains function signatures with inline documentation extracted from comments, formatted for LLM consumption. This provides a compact API reference.
55
+ **Note:** *this will work much better with [fastcore.docments](https://fastcore.fast.ai/docments.html) style function definitions*
56
+
57
+ ## CLI usage
58
+
59
+ ```bash
60
+ md build # build package from notebooks/
61
+ md publish # publish to PyPI
62
+ md publish --test # publish to Test PyPI
63
+ ```
64
+
65
+ ## Requirements
66
+
67
+ - Python 3.12+, Marimo, uv, pyproject.toml
68
+ - for relative imports to work in multi module libraries add the following to your pyproject.tml
69
+ - ``` [tool.marimo.runtime]
70
+ pythonpath = ["src"] ```
71
+
72
+ **Tip** *let marimo manages your `pyproject.toml` through its package tab, making dependencies visible and easy to update. When you add packages and remove them from the marimo package tab marimo will automaticly update your pyproject.toml*
73
+
74
+ ## Install
75
+
76
+ ```bash
77
+ uv add marimo-dev
78
+ ```
79
+
80
+ ## Helpful
81
+ ```bash
82
+ uv sync --upgrade` # to update uv.lock and pyroject.toml in one go...
83
+ uv cache clean # General Trouble Shooting Tip
84
+ ```
85
+ - you need to manually update the version in pyproject.toml
86
+
87
+ ## Module structure
88
+
89
+ - `core.py` - Data model: `Kind`, `Param`, `Node`
90
+ - `read.py` - Parse notebooks, extract exports, scan project
91
+ - `pkg.py` - Write module files and `__init__.py`
92
+ - `docs.py` - Generate signatures and `llms.txt`
93
+ - `build.py` - Orchestrate the build
94
+ - `cli.py` - Command-line interface
@@ -0,0 +1,84 @@
1
+ # marimo_dev
2
+
3
+ A literate programming build system that converts Marimo notebooks into distributable Python packages. Inspired by nbdev.
4
+
5
+
6
+ ## What it does
7
+
8
+ Looks in `/notebooks` dir for [self contained functions and classes](https://docs.marimo.io/guides/reusing_functions/) and extracts them into a PyPI ready directory. Each notebook will be striped of the leading `##_`, and `XX_` and `test` notebooks will be ignored. Run `md build` to generate a proper Python package with `__init__.py`, module files, and `llms.txt` API documentation.
9
+
10
+ ## What it does not
11
+
12
+ An intentional effort to minimise magic project set up. You are responsible for setting up your pyproject.toml, and even `mkdir notebooks`.
13
+ **Note:** *I highly reccommend that you use uv my main motivation for making this was the dependency harmony betwwen marimo and uv*
14
+
15
+
16
+
17
+ ## Project structure
18
+
19
+ ```
20
+ my-project/
21
+ ├── README.md
22
+ ├── pyproject.toml
23
+ ├── notebooks/
24
+ │ ├── 01_core.py
25
+ │ ├── 02_read.py
26
+ │ ├── ...
27
+ ├── src/ # auto created
28
+ │ └── my_package/
29
+ │ ├── __init__.py
30
+ │ ├── core.py
31
+ │ ├── read.py
32
+ │ └── ...
33
+ ├── docs/ # auto created
34
+ │ ├── index.html # Fut ver. 0.2
35
+ │ └── llms.txt
36
+ └── dist/ # auto created
37
+ └──...
38
+ ```
39
+
40
+ ## How it works
41
+
42
+ The build system parses notebooks via AST, extracts decorated exports (`@app.function`, `@app.class_definition`), and writes clean module files. It reads metadata from `pyproject.toml` and generates `__init__.py` with proper imports and `__all__` exports.
43
+
44
+ The `llms.txt` file contains function signatures with inline documentation extracted from comments, formatted for LLM consumption. This provides a compact API reference.
45
+ **Note:** *this will work much better with [fastcore.docments](https://fastcore.fast.ai/docments.html) style function definitions*
46
+
47
+ ## CLI usage
48
+
49
+ ```bash
50
+ md build # build package from notebooks/
51
+ md publish # publish to PyPI
52
+ md publish --test # publish to Test PyPI
53
+ ```
54
+
55
+ ## Requirements
56
+
57
+ - Python 3.12+, Marimo, uv, pyproject.toml
58
+ - for relative imports to work in multi module libraries add the following to your pyproject.tml
59
+ - ``` [tool.marimo.runtime]
60
+ pythonpath = ["src"] ```
61
+
62
+ **Tip** *let marimo manages your `pyproject.toml` through its package tab, making dependencies visible and easy to update. When you add packages and remove them from the marimo package tab marimo will automaticly update your pyproject.toml*
63
+
64
+ ## Install
65
+
66
+ ```bash
67
+ uv add marimo-dev
68
+ ```
69
+
70
+ ## Helpful
71
+ ```bash
72
+ uv sync --upgrade` # to update uv.lock and pyroject.toml in one go...
73
+ uv cache clean # General Trouble Shooting Tip
74
+ ```
75
+ - you need to manually update the version in pyproject.toml
76
+
77
+ ## Module structure
78
+
79
+ - `core.py` - Data model: `Kind`, `Param`, `Node`
80
+ - `read.py` - Parse notebooks, extract exports, scan project
81
+ - `pkg.py` - Write module files and `__init__.py`
82
+ - `docs.py` - Generate signatures and `llms.txt`
83
+ - `build.py` - Orchestrate the build
84
+ - `cli.py` - Command-line interface
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "marimo-dev"
7
- version = "0.1.0"
7
+ version = "0.1.2"
8
8
  description = "Build and publish python packages from marimo notebooks"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.12"
@@ -1,24 +1,26 @@
1
1
  """Build and publish python packages from marimo notebooks"""
2
- __version__ = '0.1.0'
2
+ __version__ = '0.1.2'
3
3
  __author__ = 'Deufel'
4
4
  from .core import Kind, Param, Node
5
5
  from .read import inline_doc, parse_params, parse_class_params, parse_ret, src_with_decs, is_export, parse_import, parse_const, parse_export, parse_node, parse_file, read_meta, nb_name, scan
6
6
  from .pkg import clean, write, write_mod, write_init
7
7
  from .docs import cls_sig, fn_sig, sig, write_llms
8
- from .build import publish
9
- from .cli import init, main
8
+ from .build import build, tidy, nuke
9
+ from .cli import main
10
+ from .publish import publish
10
11
  __all__ = [
11
12
  "Kind",
12
13
  "Node",
13
14
  "Param",
15
+ "build",
14
16
  "clean",
15
17
  "cls_sig",
16
18
  "fn_sig",
17
- "init",
18
19
  "inline_doc",
19
20
  "is_export",
20
21
  "main",
21
22
  "nb_name",
23
+ "nuke",
22
24
  "parse_class_params",
23
25
  "parse_const",
24
26
  "parse_export",
@@ -32,6 +34,7 @@ __all__ = [
32
34
  "scan",
33
35
  "sig",
34
36
  "src_with_decs",
37
+ "tidy",
35
38
  "write",
36
39
  "write_init",
37
40
  "write_llms",
@@ -0,0 +1,40 @@
1
+ from marimo_dev.core import Kind, Param, Node
2
+ from marimo_dev.read import scan
3
+ from marimo_dev.pkg import write_mod, write_init
4
+ from marimo_dev.docs import write_llms
5
+ from pathlib import Path
6
+ import ast, shutil
7
+
8
+ def build(
9
+ nbs='notebooks', # directory containing notebook files
10
+ out='src', # output directory for built package
11
+ root='.', # root directory containing pyproject.toml
12
+ rebuild=True, # remove existing package directory before building
13
+ )->str: # path to built package
14
+ "Build a Python package from notebooks."
15
+ meta, mods = scan(nbs, root)
16
+ pkg = Path(out) / meta['name'].replace('-', '_')
17
+ if rebuild and pkg.exists(): shutil.rmtree(pkg)
18
+ pkg.mkdir(parents=True, exist_ok=True)
19
+ for name, nodes in mods:
20
+ if name != 'index' and any(n.kind == Kind.EXP for n in nodes): write_mod(pkg/f'{name}.py', nodes)
21
+ write_init(pkg/'__init__.py', meta, mods)
22
+ all_exp = [n for _, nodes in mods for n in nodes if n.kind == Kind.EXP]
23
+ if all_exp: write_llms(meta, all_exp)
24
+ return str(pkg)
25
+
26
+ def tidy():
27
+ "Remove cache and temporary files (__pycache__, __marimo__, .pytest_cache, etc)."
28
+ import shutil
29
+ for p in Path('.').rglob('__pycache__'): shutil.rmtree(p, ignore_errors=True)
30
+ for p in Path('.').rglob('__marimo__'): shutil.rmtree(p, ignore_errors=True)
31
+ for p in Path('.').rglob('.pytest_cache'): shutil.rmtree(p, ignore_errors=True)
32
+ for p in Path('.').rglob('*.pyc'): p.unlink(missing_ok=True)
33
+ print("Cleaned cache files")
34
+
35
+ def nuke():
36
+ "Remove all build artifacts (dist, docs, src) and cache files."
37
+ import shutil
38
+ tidy()
39
+ for d in ['dist', 'docs', 'src']: shutil.rmtree(d, ignore_errors=True)
40
+ print("Nuked build artifacts")
@@ -0,0 +1,18 @@
1
+ from marimo_dev.build import build, clean, nuke
2
+ from marimo_dev.publish import publish
3
+ import sys, subprocess
4
+ from pathlib import Path
5
+
6
+ def main():
7
+ if len(sys.argv) < 2: print("Usage: md [build|publish|clean|nuke]"); sys.exit(1)
8
+ cmd = sys.argv[1]
9
+ if cmd == 'build':
10
+ from m_dev.build import build
11
+ print(f"Built package at: {build()}")
12
+ elif cmd == 'publish':
13
+ test = '--test' in sys.argv or '-t' in sys.argv
14
+ from m_dev.publish import publish
15
+ publish(test=test)
16
+ elif cmd == 'clean': clean()
17
+ elif cmd == 'nuke': nuke()
18
+ else: print(f"Unknown command: {cmd}"); sys.exit(1)
@@ -1,4 +1,4 @@
1
- from m_dev.core import Kind, Param, Node
1
+ from marimo_dev.core import Kind, Param, Node
2
2
  from pathlib import Path
3
3
  import ast
4
4
 
@@ -1,4 +1,4 @@
1
- from m_dev.core import Kind, Param, Node
1
+ from marimo_dev.core import Kind, Param, Node
2
2
  from pathlib import Path
3
3
  import ast
4
4
 
@@ -1,19 +1,17 @@
1
- from m_dev.core import Kind, Param, Node
2
- from m_dev.read import scan
3
- from m_dev.pkg import write_mod, write_init
4
- from m_dev.docs import write_llms
1
+ import subprocess, configparser, shutil
5
2
  from pathlib import Path
6
- import ast
3
+ from marimo_dev.build import build
7
4
 
8
5
  def publish(
9
6
  test:bool=True, # Use Test PyPI if True, real PyPI if False
10
7
  ):
11
8
  "Build and publish package to PyPI. Looks for ~/.pypirc for credentials, otherwise prompts."
12
- import subprocess, configparser, shutil
13
- from pathlib import Path
9
+
10
+ print("Rebuilding package from notebooks...")
11
+ build(rebuild=True)
14
12
 
15
13
  shutil.rmtree('dist', ignore_errors=True)
16
- print("Building package...")
14
+ print("Building distribution...")
17
15
  subprocess.run(['uv', 'build'], check=True)
18
16
 
19
17
  pypirc, cmd = Path.home() / '.pypirc', ['uv', 'publish']
@@ -1,4 +1,4 @@
1
- from m_dev.core import Kind, Param, Node
1
+ from marimo_dev.core import Kind, Param, Node
2
2
  from pathlib import Path
3
3
  import ast, re, tomllib
4
4
 
marimo_dev-0.1.0/PKG-INFO DELETED
@@ -1,74 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: marimo-dev
3
- Version: 0.1.0
4
- Summary: Build and publish python packages from marimo notebooks
5
- Author: Deufel
6
- Author-email: Deufel <MDeufel13@gmail.com>
7
- License: MIT
8
- Requires-Python: >=3.12
9
- Description-Content-Type: text/markdown
10
-
11
- # m_dev
12
-
13
- A literate programming build system that converts Marimo notebooks into distributable Python packages.
14
-
15
- ## What it does
16
-
17
- Write code in numbered notebook files in a `notebooks/` directory. Mark functions and classes for export by making them purely functional with references from the setup cell—Marimo detects these automatically. Run `md build` to generate a proper Python package with `__init__.py`, module files, and `llms.txt` API documentation.
18
-
19
- ## Project structure
20
-
21
- ```
22
- my-project/
23
- ├── pyproject.toml
24
- ├── notebooks/
25
- │ ├── 00_core.py
26
- │ ├── 01_read.py
27
- │ ├── 02_pkg.py
28
- │ ├── 03_docs.py
29
- │ └── 04_build.py
30
- └── src/
31
- └── my_package/
32
- ├── __init__.py
33
- ├── core.py
34
- ├── read.py
35
- └── ...
36
- ```
37
-
38
- ## How it works
39
-
40
- The build system parses notebooks via AST, extracts decorated exports (`@app.function`, `@app.class_definition`), and writes clean module files. It reads metadata from `pyproject.toml` and generates `__init__.py` with proper imports and `__all__` exports.
41
-
42
- The `llms.txt` file contains function signatures with inline documentation extracted from comments, formatted for LLM consumption. This provides a compact API reference.
43
-
44
- ## CLI usage
45
-
46
- ```bash
47
- md build # build package from notebooks/
48
- md publish # publish to PyPI
49
- md publish --test # publish to Test PyPI
50
- ```
51
-
52
- ## Requirements
53
-
54
- - Python 3.10+
55
- - Marimo for notebook management
56
- - uv for dependency management
57
- - pyproject.toml with project metadata
58
-
59
- Marimo manages your `pyproject.toml` through its package tab, making dependencies visible and easy to update.
60
-
61
- ## Install
62
-
63
- ```bash
64
- uv add m-dev --index testpypi=https://test.pypi.org/simple --index pypi=https://pypi.org/simple --index-strategy unsafe-best-match
65
- ```
66
-
67
- ## Module structure
68
-
69
- - `core.py` - Data model: `Kind`, `Param`, `Node`
70
- - `read.py` - Parse notebooks, extract exports, scan project
71
- - `pkg.py` - Write module files and `__init__.py`
72
- - `docs.py` - Generate signatures and `llms.txt`
73
- - `build.py` - Orchestrate the build
74
- - `cli.py` - Command-line interface
@@ -1,64 +0,0 @@
1
- # m_dev
2
-
3
- A literate programming build system that converts Marimo notebooks into distributable Python packages.
4
-
5
- ## What it does
6
-
7
- Write code in numbered notebook files in a `notebooks/` directory. Mark functions and classes for export by making them purely functional with references from the setup cell—Marimo detects these automatically. Run `md build` to generate a proper Python package with `__init__.py`, module files, and `llms.txt` API documentation.
8
-
9
- ## Project structure
10
-
11
- ```
12
- my-project/
13
- ├── pyproject.toml
14
- ├── notebooks/
15
- │ ├── 00_core.py
16
- │ ├── 01_read.py
17
- │ ├── 02_pkg.py
18
- │ ├── 03_docs.py
19
- │ └── 04_build.py
20
- └── src/
21
- └── my_package/
22
- ├── __init__.py
23
- ├── core.py
24
- ├── read.py
25
- └── ...
26
- ```
27
-
28
- ## How it works
29
-
30
- The build system parses notebooks via AST, extracts decorated exports (`@app.function`, `@app.class_definition`), and writes clean module files. It reads metadata from `pyproject.toml` and generates `__init__.py` with proper imports and `__all__` exports.
31
-
32
- The `llms.txt` file contains function signatures with inline documentation extracted from comments, formatted for LLM consumption. This provides a compact API reference.
33
-
34
- ## CLI usage
35
-
36
- ```bash
37
- md build # build package from notebooks/
38
- md publish # publish to PyPI
39
- md publish --test # publish to Test PyPI
40
- ```
41
-
42
- ## Requirements
43
-
44
- - Python 3.10+
45
- - Marimo for notebook management
46
- - uv for dependency management
47
- - pyproject.toml with project metadata
48
-
49
- Marimo manages your `pyproject.toml` through its package tab, making dependencies visible and easy to update.
50
-
51
- ## Install
52
-
53
- ```bash
54
- uv add m-dev --index testpypi=https://test.pypi.org/simple --index pypi=https://pypi.org/simple --index-strategy unsafe-best-match
55
- ```
56
-
57
- ## Module structure
58
-
59
- - `core.py` - Data model: `Kind`, `Param`, `Node`
60
- - `read.py` - Parse notebooks, extract exports, scan project
61
- - `pkg.py` - Write module files and `__init__.py`
62
- - `docs.py` - Generate signatures and `llms.txt`
63
- - `build.py` - Orchestrate the build
64
- - `cli.py` - Command-line interface
@@ -1,36 +0,0 @@
1
- from m_dev.build import build
2
- import sys, subprocess
3
- from pathlib import Path
4
-
5
- def init(
6
- name:str=None, # project name (defaults to current directory name)
7
- ):
8
- "Initialize a new m-dev project with notebooks dir and pyproject.toml."
9
- cmd = ['uv', 'init', '--bare', '--no-readme', '--no-pin-python', '--vcs', 'none']
10
- if name: cmd.append(name)
11
- subprocess.run(cmd, check=True)
12
- Path('notebooks').mkdir(exist_ok=True)
13
- p = Path('pyproject.toml')
14
- content = p.read_text()
15
- additions = '''
16
- [tool.marimo.runtime]
17
- pythonpath = ["src"]
18
-
19
- [build-system]
20
- requires = ["uv_build>=0.9.15,<0.10.0"]
21
- build-backend = "uv_build"
22
- '''
23
- if '[build-system]' not in content: p.write_text(content.rstrip() + '\n' + additions)
24
-
25
- def main():
26
- if len(sys.argv) < 2: print("Usage: md [init|build|publish]"); sys.exit(1)
27
- cmd = sys.argv[1]
28
- if cmd == 'init': init(sys.argv[2] if len(sys.argv) > 2 else None)
29
- elif cmd == 'build':
30
- from m_dev.build import build
31
- print(f"Built package at: {build()}")
32
- elif cmd == 'publish':
33
- test = '--test' in sys.argv or '-t' in sys.argv
34
- from m_dev.publish import publish
35
- publish(test=test)
36
- else: print(f"Unknown command: {cmd}"); sys.exit(1)