| 1 |
From: Benjamin Drung <[email protected]> |
| 2 |
Date: Wed, 15 Jul 2026 16:42:47 +0200 |
| 3 |
Subject: Try importing vendored libraries independently |
| 4 |
|
| 5 |
Debian/Ubuntu removes the vendored `yaml` library, but keeps `lexicon` |
| 6 |
and `fluidity`. Trying to import `lexicon` and `yaml` together will fail |
| 7 |
in this case: `yaml` is not available from the vendored directory and |
| 8 |
`lexicon` from the system. |
| 9 |
|
| 10 |
So try importing vendored libraries independently to allow replacing |
| 11 |
them individually. |
| 12 |
|
| 13 |
Forwarded: https://github.com/pyinvoke/invoke/pull/1076 |
| 14 |
--- |
| 15 |
invoke/parser/parser.py | 4 +++- |
| 16 |
invoke/util.py | 4 +++- |
| 17 |
2 files changed, 6 insertions(+), 2 deletions(-) |
| 18 |
|
| 19 |
diff --git a/invoke/parser/parser.py b/invoke/parser/parser.py |
| 20 |
index 43e95df..4d254a3 100644 |
| 21 |
--- a/invoke/parser/parser.py |
| 22 |
+++ b/invoke/parser/parser.py |
| 23 |
@@ -3,9 +3,11 @@ from typing import TYPE_CHECKING, Any, Iterable, List, Optional |
| 24 |
|
| 25 |
try: |
| 26 |
from ..vendor.lexicon import Lexicon |
| 27 |
- from ..vendor.fluidity import StateMachine, state, transition |
| 28 |
except ImportError: |
| 29 |
from lexicon import Lexicon # type: ignore[no-redef] |
| 30 |
+try: |
| 31 |
+ from ..vendor.fluidity import StateMachine, state, transition |
| 32 |
+except ImportError: |
| 33 |
from fluidity import ( # type: ignore[no-redef] |
| 34 |
StateMachine, |
| 35 |
state, |
| 36 |
diff --git a/invoke/util.py b/invoke/util.py |
| 37 |
index df29c84..d3cca4e 100644 |
| 38 |
--- a/invoke/util.py |
| 39 |
+++ b/invoke/util.py |
| 40 |
@@ -19,9 +19,11 @@ import sys |
| 41 |
# more obvious. Requires packagers to leave invoke/vendor/__init__.py alone tho |
| 42 |
try: |
| 43 |
from .vendor.lexicon import Lexicon # noqa |
| 44 |
- from .vendor import yaml # noqa |
| 45 |
except ImportError: |
| 46 |
from lexicon import Lexicon # type: ignore[no-redef] # noqa |
| 47 |
+try: |
| 48 |
+ from .vendor import yaml # noqa |
| 49 |
+except ImportError: |
| 50 |
import yaml # type: ignore[no-redef] # noqa |
| 51 |
|
| 52 |
|