Skip to main content

No project description provided

Reason this release was yanked:

No distributions for all systems

Project description

XYCut++ Python Wrapper (xycutppy)

PyPI version Publish xycutppy to PyPI Publish xycutppy-paper to PyPI License

This project provides a Python wrapper with two reading backends: paper (original GPL core) and datalab (native Rust port of Datalab's Apache-2.0 module). The wrapper lets you choose the backend at runtime.

✨ Features

  • High performance: The algorithm core is implemented in Rust for maximum efficiency.
  • Pythonic API: A clean, well-documented Python layer wrapping the Rust logic.
  • Configurable: Tune XYCut parameters through a dedicated configuration class.
  • Type-safe labels: Uses enums for semantic labels to avoid string-based errors.
  • Easy build and distribution: Uses maturin for seamless Rust/Python integration.
  • Backend selection: Choose paper or datalab per call or as a global default.
  • Multi-license structure: Code is split by module to simplify license compliance.

⚖️ Module licensing (Dual License)

This repository uses:

Apache-2.0 OR GPL-3.0-or-later

How this applies in practice:

  • Root pip package (xycutppy): distributed under Apache-2.0.
  • xycutppy-paper backend/package (code in src/paper/xycut_plus_plus): distributed under GPL-3.0-or-later.

Reference files:

  • LICENSE (root): formal dual-license declaration (Apache-2.0 OR GPL-3.0-or-later).
  • src/datalab/xycut_plus_plus_sorter/LICENSE: Apache-2.0 text.
  • src/paper/xycut_plus_plus/LICENSE: GPL-3.0 text.

📦 Installation

Once published to PyPI, the package can be installed with pip:

pip install xycutppy

🚀 Quickstart

Below is a basic example showing how to use the package to determine the reading order of a set of elements.

from xycutppy import compute_order, SemanticLabel, XYCutConfig, set_backend

# 1. Define the elements to sort.
# Each element is a dictionary with id, coordinates (x1, y1, x2, y2), and a label.
elements = [
    {'id': 0, 'x1': 10.0, 'y1': 10.0, 'x2': 200.0, 'y2': 30.0, 'label': SemanticLabel.HorizontalTitle},
    {'id': 1, 'x1': 10.0, 'y1': 50.0, 'x2': 400.0, 'y2': 100.0, 'label': SemanticLabel.Regular},
    {'id': 2, 'x1': 450.0, 'y1': 50.0, 'x2': 600.0, 'y2': 100.0, 'label': SemanticLabel.Regular},
    {'id': 3, 'x1': 10.0, 'y1': 120.0, 'x2': 600.0, 'y2': 200.0, 'label': SemanticLabel.Regular},
]

# 2. Define page bounds (x_min, y_min, x_max, y_max)
page_bounds = (0.0, 0.0, 800.0, 1200.0)

# 3. (Optional) Customize algorithm configuration.
custom_config = XYCutConfig(
    min_cut_threshold=10.0,
    same_row_tolerance=5.0
)

# 4. Global backend selection (optional).
set_backend("paper")  # or "datalab"

# 5. Compute reading order.
# If `config` is not passed, defaults are used.
ordered_ids = compute_order(elements, page_bounds, config=custom_config)

# 6. Or explicit per-call backend selection.
ordered_ids_datalab = compute_order(elements, page_bounds, backend="datalab")

print(f"Reading order IDs: {ordered_ids}")
# Expected output: Reading order IDs:

🧪 Visual scenarios tests (tests/scenarios.py)

Run the visual scenario suite to generate annotated PNG outputs for every available backend:

cd tests
python scenarios.py

Generated images are saved in:

tests/output_examples/

For a gallery with all example outputs rendered inline, see:


🛠️ Developer Guide: Build the Wheel from Source

This section describes how to compile the Python package (.whl) from source code.

Prerequisites

Make sure you have the following installed:

  1. Python (version 3.8+).
  2. Rust: Rust toolchain (including rustc and cargo). Install from rustup.rs.
  3. Maturin: Tool to build and publish Rust-based Python packages.
    pip install maturin
    

Project structure

The project follows a backend/license-separated structure:

xycut_project/
├── pyproject.toml      # Project and maturin configuration
├── README.md
├── Cargo.toml
├── LICENSE             # Dual-license declaration: Apache-2.0 OR GPL-3.0-or-later
├── src/
│   ├── lib.rs          # Native Python module (PyO3)
│   ├── paper/xycut_plus_plus/  # GPL Rust core
│   └── datalab/
│       ├── LICENSE     # Apache-2.0
│       └── java/       # Original Java source kept as reference/license
└── xycutppy/           # Python package source code
    └── __init__.py

Steps to generate the wheel

  1. Clone the repository (if applicable) and move to the project root (xycut_project/).

  2. Create and activate a virtual environment (recommended):

    python -m venv venv
    source venv/bin/activate  # Linux/macOS
    # venv\Scripts\activate   # Windows
    
  3. Build the project and generate the wheel: Run the following maturin command from the project root. It compiles the Rust crate in release mode and packages it with the Python wrapper into a .whl file.

    maturin build --release
    

    The generated wheel is stored in target/wheels/.

    Tip: During development, you can run maturin develop to build and install into the active virtual environment. It is faster because it skips packaging and lets you test changes immediately.

  4. Install the wheel locally for testing: Install the .whl you just created with pip:

    # Exact filename may vary by OS and Python version
    pip install target/wheels/xycutppy-0.0.2-*.whl
    

That's it. You now have a locally installed Python package ready for testing or distribution.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

xycutppy-0.1.1-cp314-cp314-win32.whl (158.0 kB view details)

Uploaded CPython 3.14Windows x86

xycutppy-0.1.1-cp313-cp313-win32.whl (158.1 kB view details)

Uploaded CPython 3.13Windows x86

xycutppy-0.1.1-cp312-cp312-win32.whl (158.0 kB view details)

Uploaded CPython 3.12Windows x86

xycutppy-0.1.1-cp311-cp311-win32.whl (158.0 kB view details)

Uploaded CPython 3.11Windows x86

xycutppy-0.1.1-cp310-cp310-win32.whl (158.3 kB view details)

Uploaded CPython 3.10Windows x86

File details

Details for the file xycutppy-0.1.1-cp314-cp314-win32.whl.

File metadata

  • Download URL: xycutppy-0.1.1-cp314-cp314-win32.whl
  • Upload date:
  • Size: 158.0 kB
  • Tags: CPython 3.14, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xycutppy-0.1.1-cp314-cp314-win32.whl
Algorithm Hash digest
SHA256 19e48cfb0c06ac6f345a5b4e48b28c1f9be68e7b02291ba144bd21235eb57241
MD5 edff830d11aa37cb603ffa33d0b7521b
BLAKE2b-256 74af922d486cd81b91469bcaa23ce2985ce7fe81d6c1cdb334456c2945923924

See more details on using hashes here.

Provenance

The following attestation bundles were made for xycutppy-0.1.1-cp314-cp314-win32.whl:

Publisher: ci-cd.yml on vquilon/xycut_ppy

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

File details

Details for the file xycutppy-0.1.1-cp313-cp313-win32.whl.

File metadata

  • Download URL: xycutppy-0.1.1-cp313-cp313-win32.whl
  • Upload date:
  • Size: 158.1 kB
  • Tags: CPython 3.13, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xycutppy-0.1.1-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 e828dba9cada564a1a4fc21bfb9dd6defcd3aab82398ff922d4a774d6e98274b
MD5 7924133186f3203eb2f723115ece55b5
BLAKE2b-256 a5716f0779d785630e0325e02a7e92db84cb52e767d0d3382944b970d4faf3bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for xycutppy-0.1.1-cp313-cp313-win32.whl:

Publisher: ci-cd.yml on vquilon/xycut_ppy

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

File details

Details for the file xycutppy-0.1.1-cp312-cp312-win32.whl.

File metadata

  • Download URL: xycutppy-0.1.1-cp312-cp312-win32.whl
  • Upload date:
  • Size: 158.0 kB
  • Tags: CPython 3.12, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xycutppy-0.1.1-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 aec7760003661c2e6c072b18b16ebe77b9e717f2b79baf04c7e5a0283add7a1d
MD5 d567c3b6f0bafe00da79cd6369c87621
BLAKE2b-256 93f351c396fd7cb25521afa6823e6e6a5cf27511a255eb44e38421dda9862f73

See more details on using hashes here.

Provenance

The following attestation bundles were made for xycutppy-0.1.1-cp312-cp312-win32.whl:

Publisher: ci-cd.yml on vquilon/xycut_ppy

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

File details

Details for the file xycutppy-0.1.1-cp311-cp311-win32.whl.

File metadata

  • Download URL: xycutppy-0.1.1-cp311-cp311-win32.whl
  • Upload date:
  • Size: 158.0 kB
  • Tags: CPython 3.11, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xycutppy-0.1.1-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 09516e6db0702ca60b66cfc9b68c6efdc81d4acf1f3938a192d672a46c7c0434
MD5 2c1cc02823dc44114df5908e287d0ed9
BLAKE2b-256 c52f34d820ea88c6353fa228b23b18385f9a9225037d14ac733563bdb62f902e

See more details on using hashes here.

Provenance

The following attestation bundles were made for xycutppy-0.1.1-cp311-cp311-win32.whl:

Publisher: ci-cd.yml on vquilon/xycut_ppy

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

File details

Details for the file xycutppy-0.1.1-cp310-cp310-win32.whl.

File metadata

  • Download URL: xycutppy-0.1.1-cp310-cp310-win32.whl
  • Upload date:
  • Size: 158.3 kB
  • Tags: CPython 3.10, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xycutppy-0.1.1-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 b1f33ff3e2c8caa1028bcd2bbe21b5c002496c9db07f1ff2728644d95106e0d5
MD5 d1f6365bd64165c070faa83fbe5bef64
BLAKE2b-256 fac1a280c1e9562bb5f3d4853720423d0c99df10e9a229e3c72fe384a2758b49

See more details on using hashes here.

Provenance

The following attestation bundles were made for xycutppy-0.1.1-cp310-cp310-win32.whl:

Publisher: ci-cd.yml on vquilon/xycut_ppy

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