Metadata-Version: 2.4
Name: jupyterlab-save-py
Version: 0.1.0
Summary: JupyterLab extension to save the active notebook as a sibling Python script.
Project-URL: Changelog, https://github.com/mihnea/jupyterlab-save-py/blob/main/CHANGELOG.md
Project-URL: Homepage, https://github.com/mihnea/jupyterlab-save-py
Project-URL: Issues, https://github.com/mihnea/jupyterlab-save-py/issues
Project-URL: Source, https://github.com/mihnea/jupyterlab-save-py
Author: jupyterlab-save-py contributors
License: MIT License
        
        Copyright (c) 2026 jupyterlab-save-py contributors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: jupyter,jupyterlab,jupyterlab-extension,notebook
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Framework :: Jupyter
Classifier: Framework :: Jupyter :: JupyterLab
Classifier: Framework :: Jupyter :: JupyterLab :: 4
Classifier: Framework :: Jupyter :: JupyterLab :: Extensions
Classifier: Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Requires-Dist: jupyterlab<5,>=4
Description-Content-Type: text/markdown

# jupyterlab-save-py

[![CI](https://github.com/mihnea/jupyterlab-save-py/actions/workflows/ci.yml/badge.svg)](https://github.com/mihnea/jupyterlab-save-py/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/jupyterlab-save-py.svg)](https://pypi.org/project/jupyterlab-save-py/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)

`jupyterlab-save-py` is a JupyterLab 4 prebuilt frontend extension that adds a
notebook toolbar button and command palette item named **Save .py**.

The command converts the active `.ipynb` notebook to a sibling `.py` file on the
same Jupyter server using JupyterLab's built-in contents API. It does not run a
separate service and does not install a Jupyter Server extension.

## Features

- JupyterLab 4.x prebuilt frontend extension
- Toolbar button labeled **Save .py** for notebooks
- Command palette command labeled **Save .py**
- Saves next to the active notebook with the same basename and `.py` extension
- Uses the JupyterLab contents manager, not browser downloads
- Configurable output format:
  - `percent`: `# %%` cell markers
  - `script`: plain Python with cell comments
- Configurable overwrite behavior

## Install

From PyPI:

```bash
pip install jupyterlab-save-py
```

From this repository:

```bash
uv sync
uv pip install -e .
```

Then start JupyterLab:

```bash
jupyter lab
```

## Settings

Open JupyterLab's settings editor and search for `Save .py`.

Default settings:

```json
{
  "format": "percent",
  "overwrite": true
}
```

When `overwrite` is `false`, existing files are not replaced. The extension will
save to `name-1.py`, `name-2.py`, and so on.

## Development

Install dependencies into `.venv` with `uv`:

```bash
uv sync
uv run jlpm install
uv run jlpm build
uv pip install -e .
```

Run JupyterLab:

```bash
uv run jupyter lab
```

Watch TypeScript and labextension builds during development:

```bash
uv run jlpm watch
```

## Build

Build frontend assets and Python distributions:

```bash
uv run jlpm install
uv run jlpm build:prod
uv run python -m build
```

The distributions are written to `dist/`.

## Publish

This repository is configured for PyPI Trusted Publishing from GitHub Releases.
Configure the PyPI project with:

- Owner: `mihnea`
- Repository: `jupyterlab-save-py`
- Workflow: `publish.yml`
- Environment: `pypi`

Manual upload is also possible:

```bash
uv run python -m twine upload dist/*
```

See [CONTRIBUTING.md](CONTRIBUTING.md) for the release checklist.

## License

MIT
