Skip to main content

libpresign

CI PyPI Python Versions License Downloads

High-performance library for generating AWS S3 presigned URLs. Generate presigned URLs up to 160x faster than boto3.

Features

  • 🚀 Lightning Fast: 5-160x faster than boto3 for presigned URL generation
  • 🔐 Secure: Full AWS Signature Version 4 compliance
  • 🌍 Compatible: Works with S3 and S3-compatible services (MinIO, Wasabi, etc.)
  • 📦 Lightweight: Minimal dependencies, pure C++ implementation
  • 🐍 Python Ready: Simple Python bindings with type hints
  • 🧵 Thread Safe: Generate URLs concurrently without locks
  • 💰 Cost Effective: Reduce compute costs with faster operations

Installation

pip install libpresign

Pre-built wheels are available for:

  • Linux: x86_64, aarch64 (Python 3.8-3.13)
  • macOS: x86_64, arm64 (Python 3.8-3.13)
  • Windows: AMD64 (Python 3.8-3.13)

Quick Start

import libpresign

# Generate a presigned URL
url = libpresign.get(
    access_key_id="AKIAIOSFODNN7EXAMPLE",
    secret_access_key="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
    region="us-east-1",
    bucket="my-bucket",
    key="path/to/file.jpg",
    expires=3600  # URL valid for 1 hour
)

print(url)
# https://my-bucket.s3.us-east-1.amazonaws.com/path/to/file.jpg?X-Amz-Algorithm=...

Performance

Benchmark Results

Generate 10,000 presigned URLs:

Library Time (ms) URLs/sec Speedup
libpresign 60 166,667 160x
boto3 9,600 1,042 1x

Single URL generation:

Library Time (μs) Memory
libpresign 6 262 bytes
boto3 102 1.6 KB

Usage Examples

Basic Usage

import libpresign

# Simple URL generation
url = libpresign.get(
    access_key_id="your-access-key",
    secret_access_key="your-secret-key",
    region="us-east-1",
    bucket="my-bucket",
    key="document.pdf"
)

Custom Endpoint (MinIO/S3-Compatible)

# Use with MinIO or other S3-compatible storage
url = libpresign.get(
    access_key_id="minioadmin",
    secret_access_key="minioadmin",
    region="us-east-1",
    bucket="my-bucket",
    key="file.txt",
    expires=3600,
    endpoint="https://minio.example.com"
)

Batch Generation

# Generate multiple URLs efficiently
config = {
    "access_key_id": "your-access-key",
    "secret_access_key": "your-secret-key",
    "region": "us-west-2",
    "bucket": "my-bucket",
    "expires": 3600
}

urls = []
for i in range(1000):
    url = libpresign.get(**config, key=f"file_{i}.jpg")
    urls.append(url)

Integration with Web Frameworks

FastAPI

from fastapi import FastAPI
import libpresign

app = FastAPI()

@app.get("/presigned-url")
async def get_presigned_url(file_key: str):
    url = libpresign.get(
        access_key_id="...",
        secret_access_key="...",
        region="us-east-1",
        bucket="uploads",
        key=file_key,
        expires=3600
    )
    return {"url": url}

Django

from django.http import JsonResponse
import libpresign

def download_file(request, file_id):
    url = libpresign.get(
        access_key_id=settings.AWS_ACCESS_KEY_ID,
        secret_access_key=settings.AWS_SECRET_ACCESS_KEY,
        region=settings.AWS_REGION,
        bucket=settings.S3_BUCKET,
        key=f"files/{file_id}",
        expires=300  # 5 minutes
    )
    return JsonResponse({"download_url": url})

API Reference

libpresign.get()

Generate a presigned URL for S3 object access.

Parameters:

  • access_key_id (str): AWS access key ID
  • secret_access_key (str): AWS secret access key
  • region (str | None): AWS region (defaults to "us-east-1")
  • bucket (str): S3 bucket name
  • key (str): S3 object key
  • expires (int): URL expiration time in seconds (defaults to 3600)
  • endpoint (str | None): Custom S3 endpoint URL

Returns:

  • str: Presigned URL

Raises:

  • SystemError: If required parameters are invalid

Development

Setup Development Environment

# Clone the repository
git clone https://github.com/myk0la-b/libpresign.git
cd libpresign

# Install uv package manager
curl -LsSf https://astral.sh/uv/install.sh | sh

# Create virtual environment
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install in editable mode with dev dependencies
uv pip install -e ".[dev]"

Running Tests

# Run all tests with coverage
uv run pytest

# Run specific test file
uv run pytest tests/test_basic.py

# Run benchmarks
uv run pytest tests/test_benchmark_boto3.py -v

Code Quality

# Format code
uv run ruff format .

# Lint code
uv run ruff check .

# Type checking
uv run mypy libpresign

Building from Source

Prerequisites

  • C++ compiler with C++11 support
  • CMake 3.15+
  • OpenSSL 3.x
  • Python 3.8+

Build Instructions

# Quick build
pip install .

# Development build
pip install -e .

# Build wheel
pip wheel . --no-deps

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Reporting Issues

If you find a bug or have a feature request, please open an issue.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Built with OpenSSL for cryptographic operations
  • Inspired by the need for faster S3 presigned URL generation
  • Thanks to all contributors

Links

Release files for libpresign 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for libpresign 1.2.0
File Size Uploaded
libpresign-1.2.0.tar.gz 61.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for libpresign 1.2.0
File
libpresign-1.2.0-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details
libpresign-1.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-64 Details
libpresign-1.2.0-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-32 Details
libpresign-1.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.8 abi3 Linux glibc 2.17+ ARM64 Details
libpresign-1.2.0-cp38-abi3-macosx_14_0_x86_64.whl CPython 3.8 abi3 macOS 14.0+ x86-64 Details
libpresign-1.2.0-cp38-abi3-macosx_14_0_arm64.whl CPython 3.8 abi3 macOS 14.0+ ARM64 Details

Total release size: 8.8 MB

Release files / libpresign-1.2.0.tar.gz

Download URL libpresign-1.2.0.tar.gz
Size 61.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1448eb8c9aea00b5b439b2b9c1ce48b88bded5abc216498cab0fb9a8edb2ca84
BLAKE2b-256 checksum
How to use checksums
8fcc45cf9ad3a64f5c080de2d5768594662cf685876dcb8f6913293ecd8a84e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 27, 2025.

Transparency log

Release files / libpresign-1.2.0-cp38-abi3-win_amd64.whl

Download URL libpresign-1.2.0-cp38-abi3-win_amd64.whl
Size 1.6 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
e75daa999490aff6301ad12bd09eba9755398175fee8cb6f016ae1b0d0337d4f
BLAKE2b-256 checksum
How to use checksums
17939410f77dad164ccd0b1c3a6631321e0348a457a79dfaac48dd32c4b94f08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 27, 2025.

Transparency log

Release files / libpresign-1.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL libpresign-1.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.1 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
a42bf6485b8719b7213ed1ba1b59489b512aca5cd4b378eb595816d620cd643f
BLAKE2b-256 checksum
How to use checksums
759de4d2e2c9d627f680d214b465f2500bd4104f0c1dec048703054079dc0184
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 27, 2025.

Transparency log

Release files / libpresign-1.2.0-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl

Download URL libpresign-1.2.0-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Size 890.4 kB
Tags CPython 3.8 Linux glibc 2.17+ x86-32 abi3
SHA-256 checksum
How to use checksums
bf11e7014e13f88a23307474ec178f305f93d0bc117b203de19acb9bb143e206
BLAKE2b-256 checksum
How to use checksums
3dae670e1b1983a635e3f6271ad29e04826469c1291472e0915534f0f44f43a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 27, 2025.

Transparency log

Release files / libpresign-1.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL libpresign-1.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 901.6 kB
Tags CPython 3.8 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
cb6e40a472663ed354cd9037207bbad919b948b90fe878f049ef9fa23059d684
BLAKE2b-256 checksum
How to use checksums
7caf1f84a73a69ecec6382bd0f4fc79848a18cdb2c4c3eb382260d53c5de6936
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 27, 2025.

Transparency log

Release files / libpresign-1.2.0-cp38-abi3-macosx_14_0_x86_64.whl

Download URL libpresign-1.2.0-cp38-abi3-macosx_14_0_x86_64.whl
Size 2.0 MB
Tags CPython 3.8 abi3 macOS 14.0+ x86-64
SHA-256 checksum
How to use checksums
b98a4e756700f6525a58d760981ae8dc700d7ce7b1226b05de1efac14aa676f9
BLAKE2b-256 checksum
How to use checksums
66e1f1e340ea2574d1b5d16d4609627fc57e0936a11b7983ca654bc23022854f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 27, 2025.

Transparency log

Release files / libpresign-1.2.0-cp38-abi3-macosx_14_0_arm64.whl

Download URL libpresign-1.2.0-cp38-abi3-macosx_14_0_arm64.whl
Size 2.3 MB
Tags CPython 3.8 abi3 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
c7edacd9dfd6fbd52bc9f94a29a3f39b4d44a8d2c350ae7e021a763194f1f10a
BLAKE2b-256 checksum
How to use checksums
e2c371c26abf204a14aa539c2361f469c100540690e42e3fe0bf11457442394f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 27, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.2.0 This release

7 release files

1.1.1

1 release file

1.1.0

26 release files

1.0.1

21 release files

1.0.0

21 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page