Skip to main content

We are the Superlative Components! — a streaming HTML/web-component bundler.

Project description

wesc (Python)

Python bindings for wesc's streaming HTML/web-component bundler. The Rust core runs in-process — no subprocess, no WASM — so you can build and server-render web components straight from a Python backend (Flask, FastAPI, Django, plain http.server, …).

pip install wesc

Prebuilt abi3 wheels ship for macOS, Linux, and Windows and work on CPython 3.8+. No Rust toolchain needed to install.

Usage

import wesc

# One-shot: returns the full HTML output as `bytes`. Releases the GIL while it
# runs, so other threads keep working.
html = wesc.build(["./index.html"], minify=True)

# Streaming: low memory, chunk by chunk. The callback receives each `bytes`
# chunk, then `None` once to signal end-of-stream.
def on_chunk(chunk):
    if chunk is None:
        finish()
    else:
        write(chunk)

wesc.build_stream(["./index.html"], on_chunk)

Async servers

build releases the GIL, so the idiomatic way to await it from asyncio (FastAPI, etc.) is a worker thread:

import asyncio, wesc

html = await asyncio.to_thread(wesc.build, ["./index.html"], minify=True)

API

  • build(entry_points, *, outcss=None, outjs=None, minify=False) -> bytes
  • build_stream(entry_points, callback, *, outcss=None, outjs=None, minify=False) -> None
Argument Type Notes
entry_points list[str] First entry is the host document.
callback Callable[[bytes | None], object] build_stream only. None ends the stream.
outcss str | None Path to write the bundled CSS file.
outjs str | None Path to write the bundled JS file.
minify bool Minify generated assets. Defaults to False.

The bundler keeps a process-global file/template cache, so builds should not run concurrently within a single process — serialize them (the examples/python-server demo does exactly this).

Building from source

This is a maturin project. From this directory:

pip install maturin
maturin develop            # build + install into the active virtualenv
maturin build --release    # produce a wheel in target/wheels/

See the repo README's Python section for the broader project and crates/wesc-py/src/lib.rs for the binding source.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wesc-0.6.2.tar.gz (59.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

wesc-0.6.2-cp38-abi3-win_amd64.whl (6.8 MB view details)

Uploaded CPython 3.8+Windows x86-64

wesc-0.6.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.9 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

wesc-0.6.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (6.6 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

wesc-0.6.2-cp38-abi3-macosx_11_0_arm64.whl (6.4 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

wesc-0.6.2-cp38-abi3-macosx_10_12_x86_64.whl (6.6 MB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file wesc-0.6.2.tar.gz.

File metadata

  • Download URL: wesc-0.6.2.tar.gz
  • Upload date:
  • Size: 59.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for wesc-0.6.2.tar.gz
Algorithm Hash digest
SHA256 6fdda44c9aa94312ae07792198d1ef90d75cf1b43c0e1b844b761e4ee37d4e84
MD5 41c8b0be1deb43a3468ba35706f9990e
BLAKE2b-256 bdf6a4e2943b1be3add076e874fa0dc6f56518e2dadb032d5fe802a4ab15db1e

See more details on using hashes here.

Provenance

The following attestation bundles were made for wesc-0.6.2.tar.gz:

Publisher: cd.yml on luwes/wesc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wesc-0.6.2-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: wesc-0.6.2-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 6.8 MB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for wesc-0.6.2-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b75b8a8ac3b2245a1fde840cd7c52dd4291d3fdc7f947a9d564f1b8eb21929f7
MD5 452479e719305aeb7f72c50890c70c82
BLAKE2b-256 e03f7aa4078b775fc722dcaec245db5756767e77dea5973ca2762721e4dc3505

See more details on using hashes here.

Provenance

The following attestation bundles were made for wesc-0.6.2-cp38-abi3-win_amd64.whl:

Publisher: cd.yml on luwes/wesc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wesc-0.6.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for wesc-0.6.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 102ccfac9f1f66f1f506fc87a7bc9539ec20c4ae0c988f7a730ef393270082a9
MD5 3b2bfb0d626eb9b902378069d9dcfda5
BLAKE2b-256 69d54f86269f0a6e50831b566ea0b193a50ec124971b52b33cd2cb1ad4d6926c

See more details on using hashes here.

Provenance

The following attestation bundles were made for wesc-0.6.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: cd.yml on luwes/wesc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wesc-0.6.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for wesc-0.6.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d6bfda7a282c199b07b8df64e47bd3ab55ac486891f3cd906e00965d01552dd2
MD5 febe1fe286b583c2dbd058fb736797c0
BLAKE2b-256 ab65edb2c555eaf1a03ea01a5e2178ebffcced5d663ceb9351ff8128de193f39

See more details on using hashes here.

Provenance

The following attestation bundles were made for wesc-0.6.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: cd.yml on luwes/wesc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wesc-0.6.2-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: wesc-0.6.2-cp38-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 6.4 MB
  • Tags: CPython 3.8+, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for wesc-0.6.2-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 33266898dc7fcb45aa6c51f218d81337a7f2f443f2283e0b11a56b6b8ed4137f
MD5 fc4de4acd24958088da3ddc990b3e601
BLAKE2b-256 1f8b8d8f58b205313094906f75a0142d38236e8a2e8e89178b09ace237afefa8

See more details on using hashes here.

Provenance

The following attestation bundles were made for wesc-0.6.2-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: cd.yml on luwes/wesc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wesc-0.6.2-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: wesc-0.6.2-cp38-abi3-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 6.6 MB
  • Tags: CPython 3.8+, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for wesc-0.6.2-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8efaca4eb782789b57228a1527dc6fe00674ead547a68a54ce3bfd6af94e49b3
MD5 d91cb561323a434e873583f771e5c57a
BLAKE2b-256 468d6ee7ba7ea3b6db0834b9839c860ce5330fc1cd510127e7e815e6b43385b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for wesc-0.6.2-cp38-abi3-macosx_10_12_x86_64.whl:

Publisher: cd.yml on luwes/wesc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page