A Python package for integrating rclone with fsspec
Project description
RCloneFileSystem: fsspec-Compatible Filesystem via rclone
This package provides a fully fsspec-compliant filesystem interface backed by rclone.
Installation
pip install rclone-filesystem
Quick Start
Given an rclone remote rclone config create myremote s3 ... you can use the RCloneFileSystem as follows:
from rclone_filesystem import RCloneFileSystem
fs = RCloneFileSystem(remote="myremote")
# List files
fs.ls("data") # path, e.g. bucket name for S3
# Read and write files
with fs.open("data/test-file.txt", "wb") as f:
f.write(b"Hello, World!")
with fs.open("data/test-file.txt", "rb") as f:
content = f.read()
# Text mode
with fs.open("data/test-file.txt", "w") as f:
f.write("Hello, World!")
with fs.open("data/test-file.txt", "r") as f:
text = f.read()
Features
Protocol Registration
The filesystem registers itself as rclone://, enabling URL-based access:
import fsspec
fs = fsspec.filesystem("rclone", remote="myremote")
# or
with fsspec.open("rclone://myremote:bucket/file.txt", "rb") as f:
data = f.read()
File Operations
# Upload / download
fs.put_file("local.txt", "bucket/remote.txt")
fs.get_file("bucket/remote.txt", "local.txt")
# Copy within remote
fs.cp_file("bucket/src.txt", "bucket/dst.txt")
# Delete
fs.rm_file("bucket/file.txt")
# Read file content directly
data = fs.cat_file("bucket/file.txt")
Directory Operations
fs.mkdir("bucket/new-dir")
fs.rmdir("bucket/old-dir") # removes directory and all contents recursively
Listing and Metadata
# List directory contents
fs.ls("bucket") # returns list of names
fs.ls("bucket", detail=True) # returns list of dicts with metadata
# Get file/directory info
fs.info("bucket/file.txt") # returns metadata dict
Caching
Directory listings are cached automatically. Cache behavior can be controlled:
fs = RCloneFileSystem(
remote="myremote",
listings_expiry_time_secs=60, # cache TTL in seconds
use_listings_cache=False, # disable caching entirely
)
# Force refresh a listing
fs.ls("bucket", refresh=True)
# Manually invalidate cache
fs.invalidate_cache("bucket")
Configuration
Settings can be provided via constructor arguments, environment variables (prefixed with RCLONE_FS_), or pyproject.toml:
fs = RCloneFileSystem(
remote="myremote",
temp_dir="/tmp/rclone", # directory for temp files during transfers
show_progress=True, # show rclone transfer progress
)
| Constructor Argument | Environment Variable | Default |
|---|---|---|
temp_dir |
RCLONE_FS_TEMP_DIR |
None (system default) |
listings_expiry_time_secs |
RCLONE_FS_LISTINGS_EXPIRY_TIME_SECS |
None |
show_progress |
RCLONE_FS_SHOW_PROGRESS |
False |
pyproject.toml example:
[tool.rclone-filesystem]
temp_dir = "/tmp/rclone"
show_progress = true
listings_expiry_time_secs = 60.0
Priority: constructor args > environment variables > pyproject.toml > defaults.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rclone_filesystem-0.2.0.tar.gz.
File metadata
- Download URL: rclone_filesystem-0.2.0.tar.gz
- Upload date:
- Size: 235.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81e757c81c6fc1d990893b2d537e8d8870a739b08879ce7a925bd62027260ac4
|
|
| MD5 |
f45896e0afddbba9b12e3c830db327aa
|
|
| BLAKE2b-256 |
a4ea42dfc8e7fc8e0202eb74830a046176a8f8ceef2151292676eea3a3414b86
|
File details
Details for the file rclone_filesystem-0.2.0-py3-none-any.whl.
File metadata
- Download URL: rclone_filesystem-0.2.0-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92743689d61b1f53fa775973acefaf39a3a60ba44b3582c60b21e3a66879b457
|
|
| MD5 |
8854ea4f114a116ca5ca672ef2e67df6
|
|
| BLAKE2b-256 |
0da5113ebc856b636e3e5c0103636109c9f7fdffc6b51e0209b18541a4e1b07c
|