Metadata-Version: 2.4
Name: ipyketcher
Version: 0.1.0
Summary: Ketcher editor as anywidget
Project-URL: Home, https://github.com/Jhsmit/ipyketcher/
License: MIT License
        
        Copyright (c) 2025 Jochem Smit
        
        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
Requires-Dist: anywidget
Provides-Extra: dev
Requires-Dist: jupyterlab; extra == 'dev'
Requires-Dist: watchfiles; extra == 'dev'
Description-Content-Type: text/markdown

# ipyketcher

## How to use

```python
from ipyketcher import KetcherEditor

editor = KetcherEditor(
    initial_molecule="OCC",
    return_formats=["smiles", "molfile"],
)

editor
```

You can now draw a structure, and access the currently drawn molecule in smiles or molfile format via
`editor.smiles` or `editor.molfile`.

Other supported formats are: 'rxn', 'ket', 'smarts', 'cml', 'sdf', 'cdxml', 'cdx', 'inchi', 'inchi_key'. Set the format you want synchronized back to Python using the `return_formats` parameter, and observe the output via the corresponding attribute on the `KetcherEditor` instance.


## Installation

```sh
pip install ipyketcher
```

or with [uv](https://github.com/astral-sh/uv):

```sh
uv add ipyketcher
```

## Development

We recommend using [uv](https://github.com/astral-sh/uv) for development.
It will automatically manage virtual environments and dependencies for you.

```sh
uv run jupyter lab example.ipynb
```

Alternatively, create and manage your own virtual environment:

```sh
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
jupyter lab example.ipynb
```

The widget front-end code bundles it's JavaScript dependencies. After setting up Python,
make sure to install these dependencies locally:

```sh
npm install
```

While developing, you can run the following in a separate terminal to automatically
rebuild JavaScript as you make changes:

```sh
npm run dev
```

Open `example.ipynb` in JupyterLab, VS Code, or your favorite editor
to start developing. Changes made in `js/` will be reflected
in the notebook.


Creating a new release:
1. Bump the version in `pyproject.toml`.
2. Create a new git tag with the version.
3. Build and upload the package to PyPI:

```sh
npm build
hatch build
hatch publish -u __token__ -a pypi-<your-token>
```


### Hot reloading

Set anywidget hot reloading on windows:

```
set ANYWIDGET_HMR=1
```

## Resources

- [Ketcher Home page](https://lifescience.opensource.epam.com/ketcher/index.html)
- [Ketcher Help](https://github.com/epam/ketcher/blob/master/documentation/help.md)
- [Ketcher API docs](https://github.com/epam/ketcher/blob/master/README.md#ketcher-api)
- [Streamlit Ketcher](https://github.com/mik-laj/streamlit-ketcher)