Metadata-Version: 2.4
Name: upathtools
Version: 1.24.0
Summary: Async helpers, typed base classes and many filesystem implementations for fsspec and universal-pathlib
Keywords: async,filesystem,fsspec,mcp,pathlib,sandbox,sqlite,universal-pathlib,upath,vfs
Author: Philipp Temminghoff
Author-email: Philipp Temminghoff <philipptemminghoff@googlemail.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: AsyncIO
Classifier: Framework :: Pydantic :: 2
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Filesystems
Classifier: Topic :: Utilities
Classifier: Typing :: Typed
Requires-Dist: aiofile>=3.9.0
Requires-Dist: fsspec>=2025.2.0
Requires-Dist: pydantic>=2.10
Requires-Dist: ripgrep-rs>=0.3.14
Requires-Dist: universal-pathlib>=0.3.0
Requires-Dist: adlfs ; extra == 'adlfs'
Requires-Dist: appwrite>=16 ; extra == 'appwrite'
Requires-Dist: beam-client>=0.2.187 ; (python_full_version < '3.14' or sys_platform != 'win32') and extra == 'beam'
Requires-Dist: httpx ; extra == 'cloudflare'
Requires-Dist: codexed ; extra == 'codex'
Requires-Dist: daytona<2 ; python_full_version < '3.14' and extra == 'daytona'
Requires-Dist: e2b-code-interpreter ; extra == 'e2b'
Requires-Dist: gcsfs ; extra == 'gcsfs'
Requires-Dist: python-gitlab>=7.0.0 ; extra == 'gitlab'
Requires-Dist: hopx-ai ; extra == 'hopx'
Requires-Dist: httpx ; extra == 'httpx'
Requires-Dist: yarl ; extra == 'httpx'
Requires-Dist: brotli ; extra == 'httpx'
Requires-Dist: huggingface-hub ; extra == 'huggingface-hub'
Requires-Dist: jq>=1.8.0 ; extra == 'jq'
Requires-Dist: pyyaml ; extra == 'jsonschema'
Requires-Dist: requests ; extra == 'jsonschema'
Requires-Dist: fastmcp ; extra == 'mcp'
Requires-Dist: mcp ; extra == 'mcp'
Requires-Dist: microsandbox ; sys_platform != 'win32' and extra == 'microsandbox'
Requires-Dist: modal ; extra == 'modal'
Requires-Dist: pydantic-monty>=0.0.5 ; extra == 'monty'
Requires-Dist: notion-client ; extra == 'notion-client'
Requires-Dist: openapi3 ; extra == 'openapi3'
Requires-Dist: s3fs ; extra == 's3fs'
Requires-Dist: httpx ; extra == 'sprites'
Requires-Dist: sqlalchemy[aiosqlite] ; extra == 'sqlite'
Requires-Dist: anyenv>=2.0.0 ; extra == 'srt'
Requires-Dist: sshfs[bcrypt]>=2025.11.0 ; extra == 'ssh'
Requires-Dist: tree-sitter>=0.25.2 ; extra == 'tree-sitter'
Requires-Dist: tree-sitter-python>=0.25.0 ; extra == 'tree-sitter'
Requires-Dist: tree-sitter-c>=0.24.1 ; extra == 'tree-sitter'
Requires-Dist: tree-sitter-javascript>=0.25.0 ; extra == 'tree-sitter'
Requires-Dist: tree-sitter>=0.25.2 ; extra == 'tree-sitter'
Requires-Dist: tree-sitter-typescript>=0.23.0 ; extra == 'tree-sitter'
Requires-Dist: tree-sitter-cpp>=0.23.0 ; extra == 'tree-sitter'
Requires-Dist: tree-sitter-rust>=0.23.0 ; extra == 'tree-sitter'
Requires-Dist: tree-sitter-go>=0.23.0 ; extra == 'tree-sitter'
Requires-Dist: tree-sitter-json>=0.24.0 ; extra == 'tree-sitter'
Requires-Dist: tree-sitter-yaml>=0.6.0 ; extra == 'tree-sitter'
Requires-Dist: vercel ; extra == 'vercel'
Requires-Dist: webdav4 ; extra == 'webdav4'
Requires-Python: >=3.13
Project-URL: Code coverage, https://app.codecov.io/gh/phil65/upathtools
Project-URL: Discussions, https://github.com/phil65/upathtools/discussions
Project-URL: Documentation, https://phil65.github.io/upathtools/
Project-URL: Homepage, https://phil65.github.io/upathtools/
Project-URL: Issues, https://github.com/phil65/upathtools/issues
Project-URL: Source, https://github.com/phil65/upathtools
Provides-Extra: adlfs
Provides-Extra: appwrite
Provides-Extra: beam
Provides-Extra: cloudflare
Provides-Extra: codex
Provides-Extra: daytona
Provides-Extra: e2b
Provides-Extra: gcsfs
Provides-Extra: gitlab
Provides-Extra: hopx
Provides-Extra: httpx
Provides-Extra: huggingface-hub
Provides-Extra: jq
Provides-Extra: jsonschema
Provides-Extra: mcp
Provides-Extra: microsandbox
Provides-Extra: modal
Provides-Extra: monty
Provides-Extra: notion-client
Provides-Extra: openapi3
Provides-Extra: s3fs
Provides-Extra: sprites
Provides-Extra: sqlite
Provides-Extra: srt
Provides-Extra: ssh
Provides-Extra: tree-sitter
Provides-Extra: vercel
Provides-Extra: webdav4
Description-Content-Type: text/markdown

# UPathTools

[![PyPI License](https://img.shields.io/pypi/l/upathtools.svg)](https://pypi.org/project/upathtools/)
[![Package status](https://img.shields.io/pypi/status/upathtools.svg)](https://pypi.org/project/upathtools/)
[![Monthly downloads](https://img.shields.io/pypi/dm/upathtools.svg)](https://pypi.org/project/upathtools/)
[![Distribution format](https://img.shields.io/pypi/format/upathtools.svg)](https://pypi.org/project/upathtools/)
[![Wheel availability](https://img.shields.io/pypi/wheel/upathtools.svg)](https://pypi.org/project/upathtools/)
[![Python version](https://img.shields.io/pypi/pyversions/upathtools.svg)](https://pypi.org/project/upathtools/)
[![Implementation](https://img.shields.io/pypi/implementation/upathtools.svg)](https://pypi.org/project/upathtools/)
[![Releases](https://img.shields.io/github/downloads/phil65/upathtools/total.svg)](https://github.com/phil65/upathtools/releases)
[![Github Contributors](https://img.shields.io/github/contributors/phil65/upathtools)](https://github.com/phil65/upathtools/graphs/contributors)
[![Github Discussions](https://img.shields.io/github/discussions/phil65/upathtools)](https://github.com/phil65/upathtools/discussions)
[![Github Forks](https://img.shields.io/github/forks/phil65/upathtools)](https://github.com/phil65/upathtools/forks)
[![Github Issues](https://img.shields.io/github/issues/phil65/upathtools)](https://github.com/phil65/upathtools/issues)
[![Github Issues](https://img.shields.io/github/issues-pr/phil65/upathtools)](https://github.com/phil65/upathtools/pulls)
[![Github Watchers](https://img.shields.io/github/watchers/phil65/upathtools)](https://github.com/phil65/upathtools/watchers)
[![Github Stars](https://img.shields.io/github/stars/phil65/upathtools)](https://github.com/phil65/upathtools/stars)
[![Github Repository size](https://img.shields.io/github/repo-size/phil65/upathtools)](https://github.com/phil65/upathtools)
[![Github last commit](https://img.shields.io/github/last-commit/phil65/upathtools)](https://github.com/phil65/upathtools/commits)
[![Github release date](https://img.shields.io/github/release-date/phil65/upathtools)](https://github.com/phil65/upathtools/releases)
[![Github language count](https://img.shields.io/github/languages/count/phil65/upathtools)](https://github.com/phil65/upathtools)
[![Github commits this month](https://img.shields.io/github/commit-activity/m/phil65/upathtools)](https://github.com/phil65/upathtools)
[![Package status](https://codecov.io/gh/phil65/upathtools/branch/main/graph/badge.svg)](https://codecov.io/gh/phil65/upathtools/)
[![PyUp](https://pyup.io/repos/github/phil65/upathtools/shield.svg)](https://pyup.io/repos/github/phil65/upathtools/)

**Async-first helpers, typed base classes and a large collection of filesystems for
[fsspec](https://filesystem-spec.readthedocs.io/) and
[universal-pathlib](https://github.com/fsspec/universal_pathlib).**

📖 Documentation: <https://phil65.github.io/upathtools/>

## Installation

```bash
uv add upathtools
# optional backends are extras, e.g.
uv add "upathtools[httpx,sqlite,mcp]"
```

Requires Python 3.13+.

## Quickstart

```python
import asyncio

from upathtools import AsyncUPath, list_files, read_folder


async def main() -> None:
    path = AsyncUPath("notes/hello.txt")
    await path.parent.amkdir(parents=True, exist_ok=True)
    await path.awrite_text("Hello from upathtools!")
    print(await path.aread_text())

    # Read many files concurrently (works for any fsspec protocol: s3://, gcs://, ...)
    files = await read_folder("notes", pattern="**/*.txt")
    for name, content in files.items():
        print(name, len(content))

    print(await list_files("notes", pattern="**/*.txt"))


asyncio.run(main())
```

Filesystems can be used directly or combined:

```python
from upathtools.filesystems import IsolatedMemoryFileSystem, PackageFileSystem, UnionFileSystem

pkg = PackageFileSystem("upathtools")  # browse an installed package's modules
print(pkg.get_upath("helpers").read_text()[:34])

docs = IsolatedMemoryFileSystem()
docs.pipe_file("/readme.md", b"# Hi")

union = UnionFileSystem({"pkg": pkg, "docs": docs})  # mount filesystems side by side
print(union.ls("/", detail=False))  # ['pkg', 'docs']
print(union.cat_file("docs/readme.md"))
```

## Features

- **`AsyncUPath`**: async versions of the `UPath` API (`aread_text`, `awrite_bytes`,
  `aiterdir`, `aglob`, `acopy`, ...), falling back to threads for sync filesystems.
- **Batch operations**: `read_folder`, `list_files`, `read_folder_as_text`, `read_path`,
  `fsspec_grep` with parallel loading.
- **Typed base classes**: `BaseAsyncFileSystem[TPath, TInfoDict]`, `BaseUPath[TInfoDict]`,
  `WrapperFileSystem`, `BaseAsyncFileFileSystem` for building your own filesystems with typed
  info dicts, `get_upath()`, `get_tree()` and a shell-like `cli("grep TODO . -r")`.
- **Filesystems** (registered as fsspec / UPath protocols via entry points):
  - file contents: Markdown sections, SQLite tables, tree-sitter code, OpenAPI and JSON Schema specs
  - Python: installed packages (`pkg://`), distributions, Pydantic models and instances
  - remote: HTTP (httpx), GitHub Gists / Issues / Wiki, GitLab, Linear, Notion, Appwrite, MCP
    resources and tools
  - sandboxes: E2B, Modal, Daytona, Beam, Vercel, Cloudflare, Microsandbox, HopX, Sprites, Codex, SRT
  - combining: union (mount points), flat union (merged view), overlay (layered writes),
    delegating (`file.md::Section` access into files)
- **`upathtools_config`**: lightweight pydantic models describing filesystems
  (`FilesystemConfigType` discriminated union) with `create_fs()`.
- Helpers: `to_upath`, `upath_to_fs`, `copy`, `write_file`, `multi_glob`, directory trees,
  pydantic `UPath` field types.

## License

MIT
