Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 81 additions & 6 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,82 @@ on:
workflow_dispatch:
inputs:
version:
description: Python package version to publish (for example, 0.1.0)
description: Python package version to publish (for example, 0.7.0)
required: true
type: string

permissions:
contents: read

jobs:
build:
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref_name, 'python-v')
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
- os: windows-latest
- os: macos-13
- os: macos-14
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: minipdf-python
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable

- name: Install build tools
run: python -m pip install maturin

- name: Build wheels
run: python -m maturin build --release --out dist

- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: minipdf-python/dist/

sdist:
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref_name, 'python-v')
runs-on: ubuntu-latest
defaults:
run:
working-directory: minipdf-python
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install build tools
run: python -m pip install maturin

- name: Build sdist
run: python -m maturin sdist --out dist

- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: sdist
path: minipdf-python/dist/

publish:
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref_name, 'python-v')
needs: [build, sdist]
runs-on: ubuntu-latest
environment:
name: pypi
Expand All @@ -26,18 +92,30 @@ jobs:
defaults:
run:
working-directory: minipdf-python

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download wheels
uses: actions/download-artifact@v4
with:
pattern: wheels-*
path: minipdf-python/dist
merge-multiple: true

- name: Download sdist
uses: actions/download-artifact@v4
with:
name: sdist
path: minipdf-python/dist

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install build tools
run: python -m pip install build twine
run: python -m pip install twine

- name: Validate release version
shell: bash
Expand All @@ -53,9 +131,6 @@ jobs:
exit 1
fi

- name: Build distributions
run: python -m build

- name: Check distributions
run: python -m twine check dist/*

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ jobs:
cache: pip
cache-dependency-path: minipdf-python/pyproject.toml

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable

- name: Install
run: python -m pip install -e "./minipdf-python[dev]"

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
**/*.node
**/*.tgz
minipdf-node/npm/
minipdf-python/src/minipdf/_native.pyd
minipdf-python/src/minipdf/_native.abi3.so

## IDE
.vs/
Expand Down
5 changes: 5 additions & 0 deletions FEATURE_PARITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ Notes:
- Node.js is a native binding over the Rust engine. Rendering fixes normally
belong in `minipdf-rs`; Node-specific work should focus on API exposure,
asynchronous execution, packaging, and binding tests.
- Python renders through the Rust engine via the
[`minipdf._native`](minipdf-python/native/src/lib.rs) PyO3 extension built by
the package backend, falling back to the pure Python renderers only when the
extension is not importable. The capability matrix below describes the pure
Python fallback.
- `P` does not mean the same depth in every language. The detailed matrices
below identify the important differences.
- The public .NET page-size and margin overrides currently apply to DOCX. The
Expand Down
32 changes: 28 additions & 4 deletions minipdf-python/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
# MiniPdf for Python

Experimental pure Python implementation of MiniPdf. It converts basic DOCX,
XLSX, and PPTX content to PDF 1.4 without requiring Microsoft Office,
LibreOffice, .NET, or Rust at runtime.
MiniPdf converts basic DOCX, XLSX, and PPTX content to PDF 1.4 without
requiring Microsoft Office or LibreOffice. Conversion runs through the Rust
MiniPdf engine in `minipdf-rs` via the PyO3 extension `minipdf._native`, which
the package build backend compiles from [`native/`](native/). A pure Python
renderer with reduced feature coverage remains as a fallback for source-tree
runs where the extension has not been built.

The package requires Python 3.10 or later.
The package requires Python 3.10 or later, and building it requires a Rust
toolchain.

## Native Rust Engine

`minipdf._native` is a PyO3 extension that delegates conversion to the Rust
engine in `minipdf-rs`. When the module is importable, the Python API uses it
automatically and the pure Python renderers are only used as a fallback.

Installing the package builds the extension:

```bash
pip install .
```

To rebuild only the extension into the package source tree, use PowerShell:

```powershell
scripts/Build-Python-Native.ps1
```

The visual benchmark runner builds the extension automatically.

## Install

Expand Down
Loading
Loading