From b64444d3a93136c6a813e9537d9bf1ec095a4224 Mon Sep 17 00:00:00 2001 From: Kristof Date: Mon, 27 Oct 2025 17:45:57 +0100 Subject: [PATCH 1/2] add source publishing --- .github/workflows/publishwheels.yml | 51 ++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publishwheels.yml b/.github/workflows/publishwheels.yml index 9fe67866..226841b0 100644 --- a/.github/workflows/publishwheels.yml +++ b/.github/workflows/publishwheels.yml @@ -9,8 +9,57 @@ on: - "v*.*.*" # Triggers only for version tag pushes jobs: + sdist: + name: Build source distribution and upload + runs-on: ubuntu-latest + + steps: + - name: Set up Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + + - name: Create virtual environment + shell: bash + run: | + python -m venv .venv + if [ -f ".venv/bin/activate" ]; then + source .venv/bin/activate + else + source .venv/Scripts/activate + fi + python -m pip install --upgrade pip maturin + + - name: Build wheel + shell: bash + run: | + if [ -f ".venv/bin/activate" ]; then + source .venv/bin/activate + else + source .venv/Scripts/activate + fi + + cd python + maturin build --sdist + + - name: Upload to TestPyPI + shell: bash + run: | + if [ -f ".venv/bin/activate" ]; then + source .venv/bin/activate + else + source .venv/Scripts/activate + fi + + cd python + maturin upload --skip-existing $GITHUB_WORKSPACE/target/wheels/* + env: + MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} + build: - name: Build and upload wheels + name: Build plaform binaries and upload wheels runs-on: ${{ matrix.os }} strategy: matrix: From a93ee3479ae9ef2343ef65535bc5612898abaf87 Mon Sep 17 00:00:00 2001 From: Kristof Date: Mon, 27 Oct 2025 18:55:07 +0100 Subject: [PATCH 2/2] update readme --- README.md | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 481c9b9b..0bb96b78 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,35 @@ This is a port of the C++ Lepton JPEG compression tool that was released by Drop With precise bit-by-bit recovery of the original JPEG, the Lepton compression library is designed for lossless compression of baseline and progressive JPEGs up to 22%. JPEG storage in a cloud storage system is the main application case. Even metadata headers and invalid content are kept in good condition. - ## How to Use This Library -Some operations of this library are vectorized such as the IDCT using the [Wide](https://crates.io/crates/wide) crate, so you can get a significant boost if you enable +AVX2. -#### Building From Source +### Rust + +The libary is published on crates.io as [lepton_jpeg](https://crates.io/crates/lepton_jpeg). + +### Python + +The library is published on PyPI as *lepton_jpeg_python*. + +``` +pip install lepton_jpeg_python +``` + +``` Python +import lepton_jpeg_python + +with open("../images/slrcity.jpg", "rb") as f: + jpg_data = f.read() + +compressed = lepton_jpeg_python.compress_bytes(jpg_data, config) +decompressed = lepton_jpeg_python.decompress_bytes(compressed, config) + +assert jpg_data == decompressed +``` + +### Building From Source -- [Rust 1.65 or Above](https://www.rust-lang.org/tools/install) +- [Rust 1.88 or Above](https://www.rust-lang.org/tools/install) ``` bash git clone https://github.com/microsoft/lepton_jpeg_rust @@ -21,9 +43,11 @@ cargo test cargo build --release ``` -#### Running +Some operations of this library are vectorized such as the IDCT using the [Wide](https://crates.io/crates/wide) crate, so you can get a significant boost if you enable +AVX2. + +### Executable -There is an `lepton_jpeg_util.exe` wrapper that is built as part of the project. It can be used to compress/decompress and also to verify the test end-to-end on a given JPEG. If the input file has a `.jpg` extension, it will encode. If the input file has a `.lep` extension, it will decode back to the original`.jpg`. +Building the Rust project generates an `lepton_jpeg_util.exe` wrapper that is built as part of the project. It can be used to compress/decompress and also to verify the test end-to-end on a given JPEG. If the input file has a `.jpg` extension, it will encode. If the input file has a `.lep` extension, it will decode back to the original`.jpg`. It supports the following options: