python-redlines 1.0.0__tar.gz → 3.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: python-redlines
3
- Version: 1.0.0
4
- Summary: Open-source DOCX comparison tool to generate native Word tracked changes (redlines) in Python without MS Word dependencies.
3
+ Version: 3.0.0
4
+ Summary: Open-source DOCX comparison tool, powered by the Docxodus engine, to generate native Word tracked changes (redlines) in Python without MS Word dependencies.
5
5
  Project-URL: Homepage, https://github.com/JSv4/Python-Redlines
6
6
  Project-URL: Documentation, https://jsv4.github.io/Python-Redlines/
7
7
  Project-URL: Demo, https://redlines.opensource.legal
@@ -13,20 +13,20 @@ Keywords: compare-word-documents,diff,docx,docx-comparison,docxodus,legal-tech,o
13
13
  Classifier: Development Status :: 5 - Production/Stable
14
14
  Classifier: License :: OSI Approved :: MIT License
15
15
  Classifier: Programming Language :: Python
16
- Classifier: Programming Language :: Python :: 3.9
17
- Classifier: Programming Language :: Python :: 3.10
18
16
  Classifier: Programming Language :: Python :: 3.11
19
17
  Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
20
  Classifier: Programming Language :: Python :: Implementation :: CPython
21
- Requires-Python: >=3.9
21
+ Requires-Python: >=3.11
22
22
  Requires-Dist: platformdirs>=3.0
23
23
  Provides-Extra: all
24
- Requires-Dist: python-redlines-docxodus; extra == 'all'
25
- Requires-Dist: python-redlines-ooxmlpowertools; extra == 'all'
24
+ Requires-Dist: python-redlines-docxodus==3.0.0; extra == 'all'
25
+ Requires-Dist: python-redlines-ooxmlpowertools==3.0.0; extra == 'all'
26
26
  Provides-Extra: docxodus
27
- Requires-Dist: python-redlines-docxodus; extra == 'docxodus'
27
+ Requires-Dist: python-redlines-docxodus==3.0.0; extra == 'docxodus'
28
28
  Provides-Extra: ooxmlpowertools
29
- Requires-Dist: python-redlines-ooxmlpowertools; extra == 'ooxmlpowertools'
29
+ Requires-Dist: python-redlines-ooxmlpowertools==3.0.0; extra == 'ooxmlpowertools'
30
30
  Description-Content-Type: text/markdown
31
31
 
32
32
  # python-redlines
@@ -59,8 +59,25 @@ redline_bytes, stdout, stderr = engine.run_redline(
59
59
  )
60
60
  ```
61
61
 
62
- `DocxodusEngine` accepts `engine="wmlcomparer"` (default) or `engine="docxdiff"` to select the
63
- comparison algorithm. See the [project README](https://github.com/JSv4/Python-Redlines#choosing-an-engine).
62
+ `DocxodusEngine` runs DocxDiff. The `engine` selector was removed in 1.0.0 along
63
+ with WmlComparer. See the [project README](https://github.com/JSv4/Python-Redlines#comparison-settings-docxodusengine-only)
64
+ for supported settings.
65
+
66
+ From 2.0.0 onward, each extra pins its companion package to the same release
67
+ version as the wrapper. For older releases, pin both packages explicitly (for
68
+ example, `python-redlines[docxodus]==0.3.0` and
69
+ `python-redlines-docxodus==0.3.0`). Existing published metadata is unchanged.
70
+
71
+ 3.0.0 bundles Docxodus v17.0.0 and adds one setting, `minimum_anchor_word_count`.
72
+ Existing call signatures and settings are unchanged from 2.0.0, but comparison markup
73
+ and revision counts can differ, and some very deeply nested documents are now refused.
74
+ It requires Python 3.11 or newer; 2.0.0 was the last release to support 3.9 and 3.10.
75
+ Review representative redlines when upgrading; see the
76
+ [3.0.0 migration guide](https://github.com/JSv4/Python-Redlines#upgrading-to-300).
77
+
78
+ An unsuccessful engine exit raises `EngineExecutionError`, a subclass of
79
+ `subprocess.CalledProcessError`. Its message includes the captured stderr and
80
+ stdout; `returncode`, `cmd`, `stdout`/`output`, and `stderr` remain available.
64
81
 
65
82
  If an engine's companion package is not installed, instantiating the engine
66
83
  raises `EngineNotInstalledError` with the `pip install` command to fix it.
@@ -0,0 +1,54 @@
1
+ # python-redlines
2
+
3
+ Generate tracked-change "redline" `.docx` documents by comparing two Word files.
4
+
5
+ `python-redlines` is the pure-Python core. The comparison engines themselves are
6
+ compiled .NET binaries shipped in separate, optional companion packages — install
7
+ the one(s) you need as extras:
8
+
9
+ ```bash
10
+ pip install python-redlines[docxodus] # Docxodus engine
11
+ pip install python-redlines[ooxmlpowertools] # Open-XML-PowerTools engine
12
+ pip install python-redlines[all] # both
13
+ ```
14
+
15
+ Binaries are prebuilt for each platform and embedded in the companion package's
16
+ wheel — no .NET SDK and no local compilation are needed to install or use it.
17
+
18
+ ## Usage
19
+
20
+ ```python
21
+ from python_redlines import DocxodusEngine
22
+
23
+ engine = DocxodusEngine()
24
+ redline_bytes, stdout, stderr = engine.run_redline(
25
+ "Author Name",
26
+ original=open("original.docx", "rb").read(),
27
+ modified=open("modified.docx", "rb").read(),
28
+ )
29
+ ```
30
+
31
+ `DocxodusEngine` runs DocxDiff. The `engine` selector was removed in 1.0.0 along
32
+ with WmlComparer. See the [project README](https://github.com/JSv4/Python-Redlines#comparison-settings-docxodusengine-only)
33
+ for supported settings.
34
+
35
+ From 2.0.0 onward, each extra pins its companion package to the same release
36
+ version as the wrapper. For older releases, pin both packages explicitly (for
37
+ example, `python-redlines[docxodus]==0.3.0` and
38
+ `python-redlines-docxodus==0.3.0`). Existing published metadata is unchanged.
39
+
40
+ 3.0.0 bundles Docxodus v17.0.0 and adds one setting, `minimum_anchor_word_count`.
41
+ Existing call signatures and settings are unchanged from 2.0.0, but comparison markup
42
+ and revision counts can differ, and some very deeply nested documents are now refused.
43
+ It requires Python 3.11 or newer; 2.0.0 was the last release to support 3.9 and 3.10.
44
+ Review representative redlines when upgrading; see the
45
+ [3.0.0 migration guide](https://github.com/JSv4/Python-Redlines#upgrading-to-300).
46
+
47
+ An unsuccessful engine exit raises `EngineExecutionError`, a subclass of
48
+ `subprocess.CalledProcessError`. Its message includes the captured stderr and
49
+ stdout; `returncode`, `cmd`, `stdout`/`output`, and `stderr` remain available.
50
+
51
+ If an engine's companion package is not installed, instantiating the engine
52
+ raises `EngineNotInstalledError` with the `pip install` command to fix it.
53
+
54
+ See the [project repository](https://github.com/JSv4/Python-Redlines) for details.
@@ -0,0 +1,15 @@
1
+ """Keep optional engine dependencies in lockstep with the core release."""
2
+ from hatchling.metadata.plugin.interface import MetadataHookInterface
3
+
4
+
5
+ class CompanionMetadataHook(MetadataHookInterface):
6
+ def update(self, metadata):
7
+ version = metadata["version"]
8
+ ooxmlpowertools = f"python-redlines-ooxmlpowertools=={version}"
9
+ docxodus = f"python-redlines-docxodus=={version}"
10
+ # Keep the deprecated engine in both its own extra and `all`.
11
+ metadata["optional-dependencies"] = {
12
+ "ooxmlpowertools": [ooxmlpowertools],
13
+ "docxodus": [docxodus],
14
+ "all": [ooxmlpowertools, docxodus],
15
+ }
@@ -4,10 +4,10 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "python-redlines"
7
- dynamic = ["version"]
8
- description = "Open-source DOCX comparison tool to generate native Word tracked changes (redlines) in Python without MS Word dependencies."
7
+ dynamic = ["version", "optional-dependencies"]
8
+ description = "Open-source DOCX comparison tool, powered by the Docxodus engine, to generate native Word tracked changes (redlines) in Python without MS Word dependencies."
9
9
  readme = "README.md"
10
- requires-python = ">=3.9"
10
+ requires-python = ">=3.11"
11
11
  license = "MIT"
12
12
  keywords = [
13
13
  "docx",
@@ -30,27 +30,16 @@ classifiers = [
30
30
  "Development Status :: 5 - Production/Stable",
31
31
  "License :: OSI Approved :: MIT License",
32
32
  "Programming Language :: Python",
33
- "Programming Language :: Python :: 3.9",
34
- "Programming Language :: Python :: 3.10",
35
33
  "Programming Language :: Python :: 3.11",
36
34
  "Programming Language :: Python :: 3.12",
35
+ "Programming Language :: Python :: 3.13",
36
+ "Programming Language :: Python :: 3.14",
37
37
  "Programming Language :: Python :: Implementation :: CPython",
38
38
  ]
39
39
  dependencies = [
40
40
  "platformdirs>=3.0",
41
41
  ]
42
42
 
43
- # Engine binaries ship in separate companion packages. Install an engine via
44
- # its extra, e.g. `pip install python-redlines[docxodus]`. All three packages
45
- # are released together from the same repository on each tagged release.
46
- [project.optional-dependencies]
47
- # Deprecated: wraps the archived Open-XML-PowerTools WmlComparer. Kept so that
48
- # anyone who needs that algorithm's output has somewhere to stand; `all` keeps
49
- # installing it so the extra does not change meaning under existing pins.
50
- ooxmlpowertools = ["python-redlines-ooxmlpowertools"]
51
- docxodus = ["python-redlines-docxodus"]
52
- all = ["python-redlines-ooxmlpowertools", "python-redlines-docxodus"]
53
-
54
43
  [project.urls]
55
44
  Homepage = "https://github.com/JSv4/Python-Redlines"
56
45
  Documentation = "https://jsv4.github.io/Python-Redlines/"
@@ -61,5 +50,10 @@ Source = "https://github.com/JSv4/Python-Redlines"
61
50
  [tool.hatch.version]
62
51
  path = "src/python_redlines/__about__.py"
63
52
 
53
+ # All three packages release together. Generate exact companion pins from the
54
+ # same version source, including in editable installs and source distributions.
55
+ [tool.hatch.metadata.hooks.custom]
56
+ path = "hatch_build.py"
57
+
64
58
  [tool.hatch.build.targets.wheel]
65
59
  packages = ["src/python_redlines"]
@@ -1,4 +1,4 @@
1
1
  # SPDX-FileCopyrightText: 2024-present U.N. Owen <void@some.where>
2
2
  #
3
3
  # SPDX-License-Identifier: MIT
4
- __version__ = "1.0.0"
4
+ __version__ = "3.0.0"
@@ -6,6 +6,7 @@ from .__about__ import __version__
6
6
  from .engines import (
7
7
  BaseEngine,
8
8
  DocxodusEngine,
9
+ EngineExecutionError,
9
10
  EngineNotInstalledError,
10
11
  XmlPowerToolsEngine,
11
12
  )
@@ -14,6 +15,7 @@ __all__ = [
14
15
  "BaseEngine",
15
16
  "XmlPowerToolsEngine",
16
17
  "DocxodusEngine",
18
+ "EngineExecutionError",
17
19
  "EngineNotInstalledError",
18
20
  "__version__",
19
21
  ]
@@ -22,6 +22,21 @@ class EngineNotInstalledError(ImportError):
22
22
  """Raised when an engine is used but its binary package is not installed."""
23
23
 
24
24
 
25
+ class EngineExecutionError(subprocess.CalledProcessError):
26
+ """An engine exited unsuccessfully; its diagnostics appear in the message.
27
+
28
+ Retains CalledProcessError's returncode, cmd, stdout/output and stderr so
29
+ existing subprocess.CalledProcessError handlers keep working.
30
+ """
31
+
32
+ def __str__(self):
33
+ message = super().__str__()
34
+ for label, output in (("stderr", self.stderr), ("stdout", self.stdout)):
35
+ if output and output.strip():
36
+ message += f"\n{label}:\n{output.rstrip()}"
37
+ return message
38
+
39
+
25
40
  def _detect_rid() -> str:
26
41
  """Return the .NET-style runtime identifier for the current platform."""
27
42
  os_name = platform.system().lower()
@@ -142,12 +157,16 @@ class BaseEngine(object):
142
157
  A path the caller supplies is never deleted; only scratch files this
143
158
  method creates are cleaned up.
144
159
 
160
+ A nonzero engine exit raises EngineExecutionError (a CalledProcessError
161
+ subclass) with captured stderr and stdout included in its message.
162
+
145
163
  Additional keyword arguments are passed to _build_command() for engine-specific
146
164
  options. DocxodusEngine supports: case_insensitive, detect_moves,
147
- move_similarity_threshold, move_minimum_word_count, detect_format_changes,
148
- conflate_spaces, date_time. It raises ValueError for unrecognised settings and
149
- for the WmlComparer-era settings removed in Docxodus v11.0.0 (engine,
150
- detail_threshold, simplify_move_markup). XmlPowerToolsEngine ignores kwargs.
165
+ move_similarity_threshold, move_minimum_word_count, minimum_anchor_word_count,
166
+ detect_format_changes, conflate_spaces, date_time. It raises ValueError for
167
+ unrecognised settings and for the WmlComparer-era settings removed in Docxodus
168
+ v11.0.0 (engine, detail_threshold, simplify_move_markup). XmlPowerToolsEngine
169
+ ignores kwargs.
151
170
  """
152
171
  scratch_files = []
153
172
  try:
@@ -163,7 +182,12 @@ class BaseEngine(object):
163
182
  command = self._build_command(author_tag, original_path, modified_path, target_path, **kwargs)
164
183
 
165
184
  # Capture stdout and stderr
166
- result = subprocess.run(command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
185
+ try:
186
+ result = subprocess.run(command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
187
+ except subprocess.CalledProcessError as exc:
188
+ raise EngineExecutionError(
189
+ exc.returncode, exc.cmd, output=exc.output, stderr=exc.stderr,
190
+ ) from exc
167
191
 
168
192
  stdout_output = result.stdout if isinstance(result.stdout, str) and len(result.stdout) > 0 else None
169
193
  stderr_output = result.stderr if isinstance(result.stderr, str) and len(result.stderr) > 0 else None
@@ -265,6 +289,7 @@ class DocxodusEngine(BaseEngine):
265
289
  _VALUE_FLAGS = [
266
290
  ('move_similarity_threshold', '--move-similarity-threshold'),
267
291
  ('move_minimum_word_count', '--move-minimum-word-count'),
292
+ ('minimum_anchor_word_count', '--minimum-anchor-word-count'),
268
293
  ('date_time', '--date-time'),
269
294
  ]
270
295
 
@@ -299,6 +324,12 @@ class DocxodusEngine(BaseEngine):
299
324
  if not isinstance(val, int) or val < 1:
300
325
  raise ValueError(f"move_minimum_word_count must be a positive integer, got {val!r}")
301
326
 
327
+ if 'minimum_anchor_word_count' in kwargs:
328
+ val = kwargs['minimum_anchor_word_count']
329
+ # bool is an int subclass, but would reach the CLI as "True".
330
+ if isinstance(val, bool) or not isinstance(val, int) or val < 0:
331
+ raise ValueError(f"minimum_anchor_word_count must be a non-negative integer, got {val!r}")
332
+
302
333
  def _build_command(self, author_tag, original_path, modified_path, target_path, **kwargs):
303
334
  self._validate_kwargs(kwargs)
304
335
 
@@ -1,37 +0,0 @@
1
- # python-redlines
2
-
3
- Generate tracked-change "redline" `.docx` documents by comparing two Word files.
4
-
5
- `python-redlines` is the pure-Python core. The comparison engines themselves are
6
- compiled .NET binaries shipped in separate, optional companion packages — install
7
- the one(s) you need as extras:
8
-
9
- ```bash
10
- pip install python-redlines[docxodus] # Docxodus engine
11
- pip install python-redlines[ooxmlpowertools] # Open-XML-PowerTools engine
12
- pip install python-redlines[all] # both
13
- ```
14
-
15
- Binaries are prebuilt for each platform and embedded in the companion package's
16
- wheel — no .NET SDK and no local compilation are needed to install or use it.
17
-
18
- ## Usage
19
-
20
- ```python
21
- from python_redlines import DocxodusEngine
22
-
23
- engine = DocxodusEngine()
24
- redline_bytes, stdout, stderr = engine.run_redline(
25
- "Author Name",
26
- original=open("original.docx", "rb").read(),
27
- modified=open("modified.docx", "rb").read(),
28
- )
29
- ```
30
-
31
- `DocxodusEngine` accepts `engine="wmlcomparer"` (default) or `engine="docxdiff"` to select the
32
- comparison algorithm. See the [project README](https://github.com/JSv4/Python-Redlines#choosing-an-engine).
33
-
34
- If an engine's companion package is not installed, instantiating the engine
35
- raises `EngineNotInstalledError` with the `pip install` command to fix it.
36
-
37
- See the [project repository](https://github.com/JSv4/Python-Redlines) for details.