python-redlines 1.0.0__tar.gz → 2.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,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: python-redlines
3
- Version: 1.0.0
3
+ Version: 2.0.0
4
4
  Summary: Open-source DOCX comparison tool 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/
@@ -21,12 +21,12 @@ Classifier: Programming Language :: Python :: Implementation :: CPython
21
21
  Requires-Python: >=3.9
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==2.0.0; extra == 'all'
25
+ Requires-Dist: python-redlines-ooxmlpowertools==2.0.0; extra == 'all'
26
26
  Provides-Extra: docxodus
27
- Requires-Dist: python-redlines-docxodus; extra == 'docxodus'
27
+ Requires-Dist: python-redlines-docxodus==2.0.0; extra == 'docxodus'
28
28
  Provides-Extra: ooxmlpowertools
29
- Requires-Dist: python-redlines-ooxmlpowertools; extra == 'ooxmlpowertools'
29
+ Requires-Dist: python-redlines-ooxmlpowertools==2.0.0; extra == 'ooxmlpowertools'
30
30
  Description-Content-Type: text/markdown
31
31
 
32
32
  # python-redlines
@@ -59,8 +59,23 @@ 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
+ 2.0.0 bundles Docxodus v14.1.0. Python call signatures and supported settings
72
+ are unchanged from 1.0.0, but comparison markup and revision granularity can differ.
73
+ Review representative redlines when upgrading; see the
74
+ [2.0.0 migration guide](https://github.com/JSv4/Python-Redlines#upgrading-to-200).
75
+
76
+ An unsuccessful engine exit raises `EngineExecutionError`, a subclass of
77
+ `subprocess.CalledProcessError`. Its message includes the captured stderr and
78
+ stdout; `returncode`, `cmd`, `stdout`/`output`, and `stderr` remain available.
64
79
 
65
80
  If an engine's companion package is not installed, instantiating the engine
66
81
  raises `EngineNotInstalledError` with the `pip install` command to fix it.
@@ -28,8 +28,23 @@ redline_bytes, stdout, stderr = engine.run_redline(
28
28
  )
29
29
  ```
30
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).
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
+ 2.0.0 bundles Docxodus v14.1.0. Python call signatures and supported settings
41
+ are unchanged from 1.0.0, but comparison markup and revision granularity can differ.
42
+ Review representative redlines when upgrading; see the
43
+ [2.0.0 migration guide](https://github.com/JSv4/Python-Redlines#upgrading-to-200).
44
+
45
+ An unsuccessful engine exit raises `EngineExecutionError`, a subclass of
46
+ `subprocess.CalledProcessError`. Its message includes the captured stderr and
47
+ stdout; `returncode`, `cmd`, `stdout`/`output`, and `stderr` remain available.
33
48
 
34
49
  If an engine's companion package is not installed, instantiating the engine
35
50
  raises `EngineNotInstalledError` with the `pip install` command to fix it.
@@ -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,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "python-redlines"
7
- dynamic = ["version"]
7
+ dynamic = ["version", "optional-dependencies"]
8
8
  description = "Open-source DOCX comparison tool to generate native Word tracked changes (redlines) in Python without MS Word dependencies."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -40,17 +40,6 @@ 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__ = "2.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,6 +157,9 @@ 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
165
  move_similarity_threshold, move_minimum_word_count, detect_format_changes,
@@ -163,7 +181,12 @@ class BaseEngine(object):
163
181
  command = self._build_command(author_tag, original_path, modified_path, target_path, **kwargs)
164
182
 
165
183
  # Capture stdout and stderr
166
- result = subprocess.run(command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
184
+ try:
185
+ result = subprocess.run(command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
186
+ except subprocess.CalledProcessError as exc:
187
+ raise EngineExecutionError(
188
+ exc.returncode, exc.cmd, output=exc.output, stderr=exc.stderr,
189
+ ) from exc
167
190
 
168
191
  stdout_output = result.stdout if isinstance(result.stdout, str) and len(result.stdout) > 0 else None
169
192
  stderr_output = result.stderr if isinstance(result.stderr, str) and len(result.stderr) > 0 else None