You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Restructure into 3 packages for optional, prebuilt engine distribution
Split the project into a monorepo of three separately-published packages so
engines can be installed optionally with binaries embedded in PyPI wheels:
- python-redlines (packages/core): pure-Python wrapper, py3-none-any wheel
- python-redlines-ooxmlpowertools: Open-XML-PowerTools binary, per-platform wheels
- python-redlines-docxodus: Docxodus binary, per-platform wheels
Engines install via extras: pip install python-redlines[docxodus|ooxmlpowertools|all].
Binaries are prebuilt per platform and embedded in each binary package's wheel, so
no .NET SDK or local compilation is needed to install or use the library.
- engines.py locates its binary package via importlib.resources, extracts the
platform archive into the user cache dir (not site-packages), and raises
EngineNotInstalledError with install guidance when a companion package is missing
- hatch_build.py stamps each binary wheel with the correct platform tag
- build_differ.py builds a given RID into each package's _binaries/ dir
- CI builds per-platform wheels across 3 OS runners; release publishes all three
- Drop hatch/hatchling runtime deps and the build-on-install hook
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CLAUDE.md
+71-37Lines changed: 71 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,68 +4,102 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
4
4
5
5
## Project Overview
6
6
7
-
Python-Redlines is a Python wrapper around compiled C# binaries that generate `.docx` redline/tracked-changes documents by comparing two Word files. The Python layer handles platform detection, binary extraction, temp file management, and subprocess execution.
7
+
Python-Redlines generates `.docx` redline/tracked-changes documents by comparing two Word files. A pure-Python wrapper drives compiled C# (.NET 8) engine binaries; the Python layer handles platform detection, binary extraction, temp file management, and subprocess execution.
-`BaseEngine` — shared logic for binary extraction, subprocess invocation, and temp file management
44
-
-`XmlPowerToolsEngine(BaseEngine)` — sets constants for the Open-XML-PowerTools binary (`dist/`, `bin/`, `redlines`)
45
-
-`DocxodusEngine(BaseEngine)` — sets constants for the Docxodus binary (`dist_docxodus/`, `bin_docxodus/`, `redline`)
49
+
# Build a package wheel
50
+
python -m build packages/core
51
+
python -m build --wheel packages/docxodus # needs an archive in _binaries/ first
52
+
```
46
53
47
-
Both engines expose `run_redline(author_tag, original, modified, **kwargs)`. `DocxodusEngine` overrides `_build_command()` to translate kwargs (e.g. `detect_moves`, `detail_threshold`) into CLI flags for the Docxodus binary. `XmlPowerToolsEngine` uses the legacy 4-positional-arg format and ignores kwargs.
Pre-compiled binaries for 6 platform targets (linux/win/osx x x64/arm64) are stored as archives in `src/python_redlines/dist/` and `src/python_redlines/dist_docxodus/`, included in the wheel. The build script `build_differ.py` compiles both engines using `dotnet publish`.
79
+
`build_differ.py` compiles an engine for a given RID with `dotnet publish` and
80
+
writes a single flat archive into the corresponding binary package's `_binaries/`.
81
+
82
+
## Build & release flow
83
+
84
+
- A binary-package wheel must contain **exactly one** platform archive. Each
85
+
`build_differ.py <rid>` invocation clears old archives, so build one RID, build
86
+
the wheel, repeat.
87
+
-`.github/workflows/ci.yml` — tests on each OS (native RID) + builds all wheels.
88
+
-`.github/workflows/python-publish.yml` — on release, builds per-platform engine
89
+
wheels across 3 OS runners, the core sdist+wheel, and publishes all three packages.
54
90
55
-
## Key Files
91
+
## Version management
56
92
57
-
-`src/python_redlines/engines.py` — BaseEngine, XmlPowerToolsEngine, and DocxodusEngine classes
58
-
-`src/python_redlines/__init__.py` — Exports all engine classes
59
-
-`src/python_redlines/__about__.py` — Single source of truth for package version
-`docxodus/` — Docxodus git submodule (tools/redline/ contains the CLI)
62
-
-`build_differ.py` — Cross-platform C# build orchestration for both engines
63
-
-`hatch_run_build_hook.py` — Hatch build hook that triggers C# compilation
64
-
-`tests/fixtures/` — Test `.docx` files (original, modified, expected_redline)
93
+
`packages/core/src/python_redlines/__about__.py` is the single source of truth.
94
+
The two binary packages read it via `[tool.hatch.version] path = "../core/..."`,
95
+
so all three always share one version. Bump only that file.
65
96
66
97
## Testing Notes
67
98
68
-
Tests must be run from the project root (fixtures use relative paths like `tests/fixtures/original.docx`). The XmlPowerToolsEngine integration test validates that comparing the fixture documents produces exactly 9 revisions. Docxodus uses a different stdout format (`"revision(s) found"` vs `"Revisions found: 9"`).
99
+
Tests live in repo-root `tests/` and must be run from the repo root (fixtures use
100
+
relative paths like `tests/fixtures/original.docx`). They require all three packages
101
+
installed and the binaries built for the current platform. The XmlPowerToolsEngine
102
+
integration test validates exactly 9 revisions on the fixture documents.
0 commit comments