Advanced Jupyter Notebook to Python script converter with round-trip support
Project description
notebook-to-code
Jupyter Notebook ➜ Python converter with round‑trip metadata, semantic Markdown processing, a pluginable theme system, batch mode, and a friendly CLI.
Key features
- Convert
.ipynb➜.pywith clear, annotated cells - Optional reverse conversion (annotated
.py➜.ipynb) - Semantic Markdown processing and wrapping
- Round‑trip metadata to validate integrity
- Batch processing for folders/patterns
- Theme plugins (e.g., default, minimal)
- Rich CLI output (optional)
Install
- Stable release:
pip install notebook-to-code
- Extras:
- GUI:
pip install notebook-to-code[gui] - Analysis:
pip install notebook-to-code[analysis] - Dev:
pip install notebook-to-code[dev]
- GUI:
Quickstart
- Convert a single notebook:
- CLI:
notebook-to-code convert path/to/notebook.ipynb -o out.py --stats - Python one‑liner:
from notebook_converter import convert_notebook; convert_notebook("path/to/notebook.ipynb", "out.py")
- CLI:
- Batch convert a folder:
notebook-to-code batch notebooks/ -o converted/ --pattern *.ipynb
- Reverse (annotated .py ➜ .ipynb):
notebook-to-code reverse script.py -o out.ipynb
- List themes:
notebook-to-code themes
CLI Options (highlights)
--theme default|minimalchoose a theme--no-metadatadisable metadata preservation--no-round-tripdisable round‑trip metadata--no-semantic-markdowndisable semantic Markdown--quality-analysisenable code quality checks--max-line-length 88wrap text/comments at length--statsshow conversion statistics
Python API (minimal)
from notebook_converter import AdvancedNotebookConverter, ConversionOptions
options = ConversionOptions(semantic_markdown=True, round_trip_metadata=True)
converter = AdvancedNotebookConverter(options=options)
out_file, stats = converter.convert_notebook("path/to/notebook.ipynb", "out.py")
print("Converted:", out_file)
Project structure
- Package:
notebook_converter(import path) - CLI:
notebook-to-code(entry point) - Source:
notebook_converter/src/notebook_converter/
Contributing
- Create a virtual env and install in editable mode:
pip install -e .[dev]
- Run tests (if configured):
pytest -q
License
- MIT
How PyPI description works
- The "Project description" on PyPI is rendered from this
README.md. - Configuration is set in
pyproject.tomlviareadme = "README.md"anddescription. - To update what appears on PyPI:
- Edit this README.
- Bump the version in
pyproject.tomland innotebook_converter/src/notebook_converter/__init__.py. - Rebuild and upload a new release:
py -m build && py -m twine upload dist/*
- PyPI does not allow editing a release’s metadata in place; publish a new version to change the description.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file notebook_to_code-3.0.3.tar.gz.
File metadata
- Download URL: notebook_to_code-3.0.3.tar.gz
- Upload date:
- Size: 29.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99c572d80c5deb945e82216ea1d0ab398a6da10184b95f1ae328e7cb7c205165
|
|
| MD5 |
96af7f7effe924baa72e87f6220e4a27
|
|
| BLAKE2b-256 |
3c1026739804ceba24df0119eeb55467f6982193930eb25484c93f6f801b334b
|
File details
Details for the file notebook_to_code-3.0.3-py3-none-any.whl.
File metadata
- Download URL: notebook_to_code-3.0.3-py3-none-any.whl
- Upload date:
- Size: 33.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e44a84a5228aa08966409967a15eef8267b5f149ac47aa22d464276fbffd47c
|
|
| MD5 |
0ce5515ac2819aa3e4deb1300cd630af
|
|
| BLAKE2b-256 |
1cfa254fe6c3aecf0c82de6bd48a809c5642127f65c129e2f66beae187934a43
|