Skip to content

Commit 3bbedea

Browse files
committed
refactor: move docxcompose to optional dependencies
1 parent f6bab5a commit 3bbedea

3 files changed

Lines changed: 51 additions & 19 deletions

File tree

docxtpl/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@
1111
from .inline_image import InlineImage
1212
from .listing import Listing
1313
from .richtext import RichText, R, RichTextParagraph, RP
14-
from .subdoc import Subdoc
1514
from .template import DocxTemplate
15+
try:
16+
from .subdoc import Subdoc
17+
except ImportError:
18+
pass

docxtpl/template.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
from jinja2.exceptions import TemplateError
2626
from lxml import etree
2727

28-
from .subdoc import Subdoc
29-
3028
if TYPE_CHECKING:
3129
from docx.document import Document as _Document
3230
from docx.oxml.document import CT_Document
3331
from docx.parts.story import StoryPart
3432

33+
from .subdoc import Subdoc
34+
3535
class DocumentObject(_Document):
3636
_element: CT_Document
3737

@@ -622,6 +622,8 @@ def fix_docpr_ids(self, tree) -> None:
622622
elt.attrib["id"] = str(self.docx_ids_index)
623623

624624
def new_subdoc(self, docpath=None) -> Subdoc:
625+
from .subdoc import Subdoc
626+
625627
self.init_docx()
626628
return Subdoc(self, docpath)
627629

pyproject.toml

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,50 @@
1-
[tool.poetry]
1+
[project]
22
name = "docxtpl"
3-
version = "0.20.1"
3+
dynamic = ["version"]
44
description = "Python docx template engine"
5-
authors = ["Eric Lapouyade"]
5+
authors = [{name="Eric Lapouyade", email="elapouya@proton.me"}]
66
readme = "README.rst"
7+
license = "LGPL 2.1"
8+
requires-python = ">=3.7"
9+
classifiers=[
10+
"Intended Audience :: Developers",
11+
"Development Status :: 4 - Beta",
12+
"Programming Language :: Python :: 3",
13+
"Programming Language :: Python :: 3.7",
14+
"Programming Language :: Python :: 3.8",
15+
"Programming Language :: Python :: 3.9",
16+
"Programming Language :: Python :: 3.10",
17+
"Programming Language :: Python :: 3.11",
18+
"Programming Language :: Python :: 3.12",
19+
"Programming Language :: Python :: 3.13",
20+
]
21+
keywords = ["jinja2"]
22+
dependencies = [
23+
"python-docx (>=1.1.2,<2)",
24+
"jinja2",
25+
"lxml",
26+
]
27+
28+
[project.optional-dependencies]
29+
subdoc = ["docxcompose"]
30+
docs = ["Sphinx", "sphinxcontrib-napoleon"]
31+
32+
[dependency-groups]
33+
dev = ["mypy", "lxml-stubs", "flake8"]
734

8-
[tool.poetry.dependencies]
9-
python = "^3.11"
10-
python-docx = "^1.1.2"
11-
docxcompose = "^1.4.0"
12-
jinja2 = "^3.1.4"
35+
[project.urls]
36+
homepage = "https://github.com/elapouya/python-docx-template"
37+
repository = "https://github.com/elapouya/python-docx-template.git"
38+
document = "https://docxtpl.readthedocs.org"
1339

40+
[tool.pdm]
41+
version = {source="file", path="docxtpl/__init__.py"}
42+
43+
[tool.poetry]
44+
version = '0.0.0'
1445

15-
[tool.poetry.group.dev.dependencies]
16-
flake8 = "^7.1.0"
17-
black = "^24.4.2"
18-
twine = "^6.1.0"
19-
mypy = "^1.17.0"
20-
lxml-stubs = "^0.5.1"
46+
[tool.poetry-plugin-version]
47+
source = "docxtpl/__init__.py"
2148

2249
[tool.mypy]
2350
pretty = true
@@ -31,5 +58,5 @@ module = ["docxcompose.*"]
3158
ignore_missing_imports = true
3259

3360
[build-system]
34-
requires = ["poetry-core"]
35-
build-backend = "poetry.core.masonry.api"
61+
requires = ["pdm-backend"]
62+
build-backend = "pdm.backend"

0 commit comments

Comments
 (0)