Metadata-Version: 2.5
Name: geminpy
Version: 1.5.2
Summary: Automated OAuth wrapper for Google Gemini CLI on macOS
Project-URL: Documentation, https://github.com/twardoch/geminpy#readme
Project-URL: Issues, https://github.com/twardoch/geminpy/issues
Project-URL: Source, https://github.com/twardoch/geminpy
Author-email: Adam Twardoch <adam+github@twardoch.com>
License: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=3.10
Requires-Dist: aiohttp>=3.8.0
Requires-Dist: fire>=0.5.0
Requires-Dist: loguru>=0.7.0
Requires-Dist: macdefaultbrowsy>=2.1.1; sys_platform == 'darwin'
Requires-Dist: platformdirs>=4.0.0
Requires-Dist: playwright>=1.43.0
Requires-Dist: requests>=2.31.0
Requires-Dist: rich>=13.0.0
Provides-Extra: all
Requires-Dist: absolufy-imports>=0.3.1; extra == 'all'
Requires-Dist: aiohttp>=3.8.0; extra == 'all'
Requires-Dist: coverage[toml]>=7.6.12; extra == 'all'
Requires-Dist: fire>=0.5.0; extra == 'all'
Requires-Dist: isort>=6.0.1; extra == 'all'
Requires-Dist: loguru>=0.7.0; extra == 'all'
Requires-Dist: macdefaultbrowsy>=2.1.1; extra == 'all'
Requires-Dist: mypy>=1.15.0; extra == 'all'
Requires-Dist: myst-parser>=3.0.0; extra == 'all'
Requires-Dist: platformdirs>=4.0.0; extra == 'all'
Requires-Dist: playwright>=1.43.0; extra == 'all'
Requires-Dist: pre-commit>=4.1.0; extra == 'all'
Requires-Dist: pytest-asyncio>=0.25.3; extra == 'all'
Requires-Dist: pytest-benchmark[histogram]>=5.1.0; extra == 'all'
Requires-Dist: pytest-cov>=6.0.0; extra == 'all'
Requires-Dist: pytest-xdist>=3.6.1; extra == 'all'
Requires-Dist: pytest>=8.3.4; extra == 'all'
Requires-Dist: pyupgrade>=3.19.1; extra == 'all'
Requires-Dist: requests>=2.31.0; extra == 'all'
Requires-Dist: rich>=13.0.0; extra == 'all'
Requires-Dist: ruff>=0.9.7; extra == 'all'
Requires-Dist: sphinx-autodoc-typehints>=2.0.0; extra == 'all'
Requires-Dist: sphinx-rtd-theme>=2.0.0; extra == 'all'
Requires-Dist: sphinx>=7.2.6; extra == 'all'
Provides-Extra: build
Requires-Dist: cx-freeze>=7.0.0; extra == 'build'
Requires-Dist: pyinstaller>=6.0.0; extra == 'build'
Provides-Extra: dev
Requires-Dist: absolufy-imports>=0.3.1; extra == 'dev'
Requires-Dist: isort>=6.0.1; extra == 'dev'
Requires-Dist: mypy>=1.15.0; extra == 'dev'
Requires-Dist: pre-commit>=4.1.0; extra == 'dev'
Requires-Dist: pyupgrade>=3.19.1; extra == 'dev'
Requires-Dist: ruff>=0.9.7; extra == 'dev'
Provides-Extra: docs
Requires-Dist: myst-parser>=3.0.0; extra == 'docs'
Requires-Dist: sphinx-autodoc-typehints>=2.0.0; extra == 'docs'
Requires-Dist: sphinx-rtd-theme>=2.0.0; extra == 'docs'
Requires-Dist: sphinx>=7.2.6; extra == 'docs'
Provides-Extra: test
Requires-Dist: coverage[toml]>=7.6.12; extra == 'test'
Requires-Dist: pytest-asyncio>=0.25.3; extra == 'test'
Requires-Dist: pytest-benchmark[histogram]>=5.1.0; extra == 'test'
Requires-Dist: pytest-cov>=6.0.0; extra == 'test'
Requires-Dist: pytest-xdist>=3.6.1; extra == 'test'
Requires-Dist: pytest>=8.3.4; extra == 'test'
Description-Content-Type: text/markdown

<!-- this_file: README.md -->

# geminpy

<img src="docs/assets/icon.png" align="right" width="180" alt="geminpy icon: a browser tipping its hat and handing over a key">

**Automated OAuth wrapper for Google's Gemini CLI on macOS.**

Google's `gemini` CLI wants you to open a browser, pick your account, and click
"Sign in" — every time. `geminpy` does that clicking for you. It launches Chrome
for Testing, runs `gemini` with your arguments, drives the OAuth screens over the
Chrome DevTools Protocol, and hands you back a clean response. Your everyday
browser is never touched, and your default browser is restored exactly as it was.

> **macOS only.** `geminpy` switches the default browser during sign-in using a
> macOS-only utility. It will not run on Linux or Windows.

Full documentation: **<https://twardoch.github.io/geminpy/>**

## Three commands to get going

```bash
pip install geminpy                       # 1. install
playwright install chromium               # 2. one-time browser setup
geminpy -p "Explain Python decorators"    # 3. ask
```

The first authenticated call installs Chrome for Testing if it is missing (via
`@puppeteer/browsers`, so Node.js must be available). Every call after that signs
in on its own.

## Why geminpy

- **Hands-off auth** — the OAuth dance runs without you.
- **Your browser, untouched** — Chrome for Testing stays isolated; your default
  browser is put back afterwards.
- **Rate-limit fallback** — a `429` triggers an automatic retry on
  `gemini-2.5-flash` (with `--retry`).
- **Clean output** — authentication noise is stripped, so scripts get the answer,
  not the login chatter.
- **Current model aliases** — `pro` and `flash` resolve to whatever your installed
  `gemini` CLI currently ships, not hard-coded IDs.

## Command line

`geminpy` is a drop-in front for `gemini` — pass the same arguments.

```bash
geminpy -p "Explain Python decorators"          # ask a question
geminpy -m pro -p "Write a reverse() function"  # model shortcut: pro / flash
geminpy --user you@gmail.com -p "Hello"         # name the Google account
geminpy --retry -p "Summarise this"             # retry on rate limits
geminpy --quit-browser -p "What day is it?"     # quit Chrome when finished
geminpy --verbose -p "Hello world"              # watch the OAuth flow
```

Omit `-p` for interactive mode — `gemini` runs as usual, sign-in handled for you.

## Python

```python
from geminpy import ask

answer = ask("Explain quantum computing in simple terms")
print(answer)

# Named account, model shortcut, retry
answer = ask("Generate a Python function", user="you@gmail.com", model="pro", retry=True)
```

Inside an event loop, use `ask_async`. For raw `gemini` arguments, use
`call_gemini_cli`. See the [API reference](https://twardoch.github.io/geminpy/api-reference.html).

## Choosing an account

`geminpy` resolves the Google account in this order:

1. The `--user` argument (or `user=` in Python).
2. The `GEMINI_CLI_USER` environment variable.
3. The account stored from your last successful sign-in.
4. The first Google account it finds.

```bash
export GEMINI_CLI_USER="you@gmail.com"
geminpy -p "Now I don't need --user"
```

## Requirements

- **Platform**: macOS (Darwin).
- **Python**: 3.10 or newer.
- **Tools**: `brew install macdefaultbrowsy`, then `playwright install chromium`.
- **Node.js**: needed for the one-time Chrome for Testing install.

## How it works

Every call runs four phases — setup, authentication, execution, cleanup — and the
cleanup phase always runs, so your default browser ends up where it started. The
full walkthrough, including troubleshooting, lives in
[How it works](https://twardoch.github.io/geminpy/how-it-works.html).

## Development

Built with [Hatch](https://hatch.pypa.io/).

```bash
hatch run test:test        # run tests (all browser/network calls are mocked)
hatch run lint:style       # ruff check + format
hatch run lint:typing      # mypy
hatch build                # build wheel + sdist
```

CI runs the mocked test suite on macOS and Linux across Python 3.10–3.12. Tagging
`vX.Y.Z` builds and publishes to PyPI and GitHub Releases.

## License

MIT — see [LICENSE](LICENSE).
