From e7dc0e051e61c5df8a1677f21690d326d96422c0 Mon Sep 17 00:00:00 2001 From: bohd4nx Date: Wed, 20 May 2026 22:55:18 +0300 Subject: [PATCH] feat: update README and pyproject.toml to clarify browser dependency installation --- README.md | 5 ++++- pyfragment/utils/cookies.py | 4 ++-- pyproject.toml | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7677515..1f91781 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,10 @@ Requires Python 3.10+. **Fragment cookies** — log in to [fragment.com](https://fragment.com) and connect your TON wallet. You can get cookies in two ways: -- **Automatically** (recommended) — use `get_cookies_from_browser()`, which reads them directly from your browser's on-disk store. No extension needed: +- **Automatically** (recommended) — install the optional browser extra and use `get_cookies_from_browser()`, which reads them directly from your browser's on-disk store. No extension needed: + ```bash + pip install "pyfragment[browser]" + ``` ```python from pyfragment.utils import get_cookies_from_browser result = get_cookies_from_browser("chrome") # or "firefox", "edge", "brave", ... diff --git a/pyfragment/utils/cookies.py b/pyfragment/utils/cookies.py index 7f9aaa4..49b76e6 100644 --- a/pyfragment/utils/cookies.py +++ b/pyfragment/utils/cookies.py @@ -3,8 +3,6 @@ from __future__ import annotations from datetime import datetime, timezone from typing import Any -import rookiepy - from pyfragment.types import CookieError from pyfragment.types import CookieResult as CookieResult from pyfragment.types.constants import FRAGMENT_BASE_URL, FRAGMENT_DOMAIN, REQUIRED_COOKIE_KEYS, SUPPORTED_BROWSERS @@ -36,6 +34,8 @@ def get_cookies_from_browser(browser: str = "chrome") -> CookieResult: raise CookieError(CookieError.UNSUPPORTED_BROWSER.format(browser=browser, supported=supported)) try: + import rookiepy + jar: list[dict[str, Any]] = getattr(rookiepy, key)([FRAGMENT_DOMAIN]) except Exception as exc: raise CookieError(CookieError.BROWSER_READ_FAILED.format(browser=browser, exc=exc, url=FRAGMENT_BASE_URL)) from exc diff --git a/pyproject.toml b/pyproject.toml index b69a7e6..42c56cd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,10 +54,11 @@ classifiers = [ "Topic :: Office/Business :: Financial :: Investment", "Typing :: Typed", ] -dependencies = ["httpx>=0.25", "rookiepy>=0.5.6", "tonutils>=2.0.1"] +dependencies = ["httpx>=0.25", "tonutils>=2.0.1"] [project.optional-dependencies] dev = ["pytest", "pytest-asyncio", "pytest-mock", "mypy", "ruff"] +browser = ["rookiepy>=0.5.6"] [project.urls] Homepage = "https://github.com/bohd4nx/pyfragment"