marimo-dev 0.5.0__tar.gz → 0.5.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: marimo-dev
3
- Version: 0.5.0
3
+ Version: 0.5.1
4
4
  Summary: Build and publish (functional/immutable) python packages from marimo notebooks
5
5
  Author: Mike Deufel
6
6
  Author-email: Mike Deufel <MDeufel13@gmail.com>
@@ -71,12 +71,15 @@ $ md bundle app.py
71
71
 
72
72
  $ md docs
73
73
  docs/
74
+ ├─ index.html # single page API docs, inline CSS, no JS, no external requests
74
75
  ├─ llms.txt # module index with export names
75
76
  └─ llms-full.txt # complete cleaned source
76
77
 
77
78
  $ md publish [--test]
78
79
  builds package, then uploads to PyPI (or TestPyPI with --test)
79
- requires ~/.pypirc with token
80
+ credentials are left to uv: UV_PUBLISH_TOKEN, or it prompts;
81
+ ~/.pypirc is used if present. Or push a v* tag and let
82
+ .github/workflows/publish.yml do it (trusted publishing, no token)
80
83
 
81
84
  $ md tidy
82
85
  removes __pycache__/, __marimo__/, .pytest_cache/, *.pyc
@@ -58,12 +58,15 @@ $ md bundle app.py
58
58
 
59
59
  $ md docs
60
60
  docs/
61
+ ├─ index.html # single page API docs, inline CSS, no JS, no external requests
61
62
  ├─ llms.txt # module index with export names
62
63
  └─ llms-full.txt # complete cleaned source
63
64
 
64
65
  $ md publish [--test]
65
66
  builds package, then uploads to PyPI (or TestPyPI with --test)
66
- requires ~/.pypirc with token
67
+ credentials are left to uv: UV_PUBLISH_TOKEN, or it prompts;
68
+ ~/.pypirc is used if present. Or push a v* tag and let
69
+ .github/workflows/publish.yml do it (trusted publishing, no token)
67
70
 
68
71
  $ md tidy
69
72
  removes __pycache__/, __marimo__/, .pytest_cache/, *.pyc
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "marimo-dev"
7
- version = "0.5.0"
7
+ version = "0.5.1"
8
8
  description = "Build and publish (functional/immutable) python packages from marimo notebooks"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.12"
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "marimo-dev"
7
- version = "0.5.0"
7
+ version = "0.5.1"
8
8
  description = "Build and publish (functional/immutable) python packages from marimo notebooks"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.12"
@@ -1,5 +1,5 @@
1
1
  """Build and publish (functional/immutable) python packages from marimo notebooks"""
2
- __version__ = '0.5.0'
2
+ __version__ = '0.5.1'
3
3
  __author__ = 'Mike Deufel'
4
4
  from .types import rename, Config, Param, Return, Method, Import, Const, Setup, ExportKind, Export, ParsedFile, Module, Meta, Project
5
5
  from .parse import read_config, read_project
@@ -0,0 +1,55 @@
1
+ from pathlib import Path
2
+ import configparser, os, shutil, subprocess
3
+ from .types import Project
4
+ from .build_pkg import build
5
+
6
+ PYPI_URLS = {'testpypi': 'https://test.pypi.org/legacy/', 'pypi': 'https://upload.pypi.org/legacy/'}
7
+ ENV_KEYS = ('UV_PUBLISH_TOKEN', 'UV_PUBLISH_PASSWORD')
8
+ TOKEN_URLS = {'testpypi': 'https://test.pypi.org/manage/account/', 'pypi': 'https://pypi.org/manage/account/'}
9
+
10
+ """
11
+ marimo-dev publish.
12
+
13
+ Build distribution and upload to PyPI.
14
+ Calls uv build + uv publish. Credentials are uv's business: UV_PUBLISH_TOKEN,
15
+ a prompt, or trusted publishing in CI. ~/.pypirc is used only if it exists.
16
+
17
+ Public API:
18
+ publish(project, test) -> None
19
+ """
20
+
21
+ def _pypirc_env(
22
+ section: str, # 'testpypi' or 'pypi'
23
+ ) -> dict[str, str]: # UV_PUBLISH_* variables, or {} when ~/.pypirc has nothing for this section
24
+ "Optional fallback: turn a `~/.pypirc` section into environment variables for `uv publish`."
25
+ pypirc = Path.home() / '.pypirc'
26
+ if not pypirc.exists(): return {}
27
+ cfg = configparser.ConfigParser()
28
+ cfg.read(pypirc)
29
+ password = cfg[section].get('password', '') if section in cfg else ''
30
+ if not password: return {}
31
+ return {'UV_PUBLISH_USERNAME': cfg[section].get('username', '__token__'), 'UV_PUBLISH_PASSWORD': password}
32
+
33
+ def publish(
34
+ proj: Project, # complete parsed project
35
+ test: bool = True, # True for TestPyPI, False for PyPI
36
+ ):
37
+ "Build package and publish to PyPI. Credentials are left to `uv publish`."
38
+ section = 'testpypi' if test else 'pypi'
39
+ target = 'TestPyPI' if test else 'PyPI'
40
+
41
+ print("Building package from notebooks...")
42
+ build(proj)
43
+
44
+ shutil.rmtree('dist', ignore_errors=True)
45
+ print("Building distribution...")
46
+ subprocess.run(['uv', 'build'], check=True)
47
+
48
+ env = dict(os.environ)
49
+ if any(k in env for k in ENV_KEYS): print("Using credentials from the environment.")
50
+ elif (rc := _pypirc_env(section)): env.update(rc); print("Using credentials from ~/.pypirc.")
51
+ else: print(f"No stored credentials: uv will ask. Username is __token__, password is an API token from {TOKEN_URLS[section]}")
52
+
53
+ print(f"Publishing to {target}...")
54
+ done = subprocess.run(['uv', 'publish', '--publish-url', PYPI_URLS[section]], env=env)
55
+ print(f"Published to {target}!" if done.returncode == 0 else f"Publish failed. If it was a 403, make a new token at {TOKEN_URLS[section]}")
@@ -1,77 +0,0 @@
1
- from pathlib import Path
2
- import configparser, shutil, subprocess
3
- from .types import Project
4
- from .build_pkg import build
5
-
6
- PYPI_URLS = {'testpypi': 'https://test.pypi.org/legacy/', 'pypi': 'https://upload.pypi.org/legacy/'}
7
- TOKEN_URLS = {'testpypi': 'https://test.pypi.org/manage/account/', 'pypi': 'https://pypi.org/manage/account/'}
8
-
9
- """
10
- marimo-dev publish.
11
-
12
- Build distribution and upload to PyPI.
13
- Reads credentials from ~/.pypirc, calls uv build + uv publish.
14
-
15
- Public API:
16
- publish(project, test) -> None
17
- """
18
-
19
- def _read_pypirc(
20
- section: str, # 'testpypi' or 'pypi'
21
- ) -> tuple[str, str]|None: # (username, password) or None on failure
22
- "Read credentials from ~/.pypirc. Prints error and returns None on failure."
23
- pypirc = Path.home() / '.pypirc'
24
- url = TOKEN_URLS[section]
25
-
26
- if not pypirc.exists():
27
- print(f"No ~/.pypirc found. Create a token at {url}"); return None
28
-
29
- cfg = configparser.ConfigParser()
30
- cfg.read(pypirc)
31
-
32
- if section not in cfg:
33
- print(f"No [{section}] in ~/.pypirc. Create a token at {url}"); return None
34
-
35
- password = cfg[section].get('password', '')
36
- if not password:
37
- print(f"No password in [{section}]. Create a token at {url}"); return None
38
-
39
- username = cfg[section].get('username', '__token__')
40
- return (username, password)
41
-
42
- def publish(
43
- proj: Project, # complete parsed project
44
- test: bool = True, # True for TestPyPI, False for PyPI
45
- ):
46
- "Build package and publish to PyPI."
47
- section = 'testpypi' if test else 'pypi'
48
- target = 'TestPyPI' if test else 'PyPI'
49
-
50
- creds = _read_pypirc(section)
51
- if not creds: return
52
- username, password = creds
53
-
54
- preview = password[:9] + '...' if password.startswith('pypi-') else '****'
55
- print(f"Authenticated as {username} ({preview})")
56
-
57
- print("Building package from notebooks...")
58
- build(proj)
59
-
60
- shutil.rmtree('dist', ignore_errors=True)
61
- print("Building distribution...")
62
- subprocess.run(['uv', 'build'], check=True)
63
-
64
- print(f"Publishing to {target}...")
65
- try:
66
- subprocess.run([
67
- 'uv', 'publish',
68
- '--publish-url', PYPI_URLS[section],
69
- '--username', username,
70
- '--password', password,
71
- ], capture_output=True, text=True, check=True)
72
- print(f"Published to {target}!")
73
- except subprocess.CalledProcessError as e:
74
- if '403' in (e.stderr or ''):
75
- print(f"Auth failed. Token may be expired. Regenerate at {TOKEN_URLS[section]}")
76
- else:
77
- print(f"Publish failed: {e.stderr}")