From ca616bd7da5abe81c89686a90881d453d1bc609e Mon Sep 17 00:00:00 2001 From: Garret Pick Date: Tue, 4 Nov 2025 07:46:49 -1000 Subject: [PATCH 1/4] Modern build system: https://github.com/4teamwork/docxcompose/pull/113 --- HISTORY.txt | 7 ++++++ README.rst | 2 ++ docxcompose/properties.py | 6 ++--- setup.py | 50 --------------------------------------- 4 files changed, 12 insertions(+), 53 deletions(-) delete mode 100644 setup.py diff --git a/HISTORY.txt b/HISTORY.txt index 87aea06..5b11f65 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -1,6 +1,13 @@ Changelog ========= +1.4.1.post0+emmv +------------------ + +- Migrated build system to PEP 517/621. +- Added pyproject.toml with modern metadata. +- Declared dynamic readme using setuptools to combine README.rst and HISTORY.txt. +- Removed legacy setup.py-based build path to avoid deprecation warnings. 1.4.1 (unreleased) ------------------ diff --git a/README.rst b/README.rst index 6ba0d20..6d76eb5 100644 --- a/README.rst +++ b/README.rst @@ -2,6 +2,8 @@ *docxcompose* is a Python library for concatenating/appending Microsoft Word (.docx) files. +This fork adds the PR 112, Fixed DeprecationWarning on pkg_import, by +@numshub and modernizes the build system for Python >= 3.8. Example usage ------------- diff --git a/docxcompose/properties.py b/docxcompose/properties.py index aa8cd2d..51f2ac0 100644 --- a/docxcompose/properties.py +++ b/docxcompose/properties.py @@ -15,7 +15,7 @@ from lxml.etree import QName from six import binary_type from six import text_type -import pkg_resources +import importlib.resources as importlib_resources import re @@ -108,8 +108,8 @@ def __init__(self, doc): self._element = parse_xml(part.blob) def _part_template(self): - return pkg_resources.resource_string( - 'docxcompose', 'templates/custom.xml') + ref = importlib_resources.files('docxcompose').joinpath('templates/custom.xml') + return ref.read_bytes() def _update_part(self): if self.part is None: diff --git a/setup.py b/setup.py deleted file mode 100644 index 1d7d53c..0000000 --- a/setup.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -"""Installer for the docxcompose package.""" - -from setuptools import find_packages -from setuptools import setup - - -tests_require = [ - 'pytest', -] - -setup( - name='docxcompose', - version='1.4.1.dev0', - description="Compose .docx documents", - long_description=(open("README.rst").read() + "\n" + - open("HISTORY.txt").read()), - # Get more from https://pypi.python.org/pypi?%3Aaction=list_classifiers - classifiers=[ - "Programming Language :: Python", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3", - "Operating System :: OS Independent", - "License :: OSI Approved :: MIT License", - ], - keywords='Python DOCX Word OOXML', - author='Thomas Buchberger', - author_email='t.buchberger@4teamwork.ch', - url='https://github.com/4teamwork/docxcompose', - license='MIT license', - packages=find_packages(exclude=['ez_setup']), - include_package_data=True, - zip_safe=True, - install_requires=[ - 'lxml', - 'python-docx >= 0.8.8', - 'setuptools', - 'six', - 'babel', - ], - extras_require={ - 'test': tests_require, - 'tests': tests_require, - }, - entry_points={ - 'console_scripts': [ - 'docxcompose = docxcompose.command:main' - ] - }, -) From 9347e339499e8badcdb191112d2ad71e1c950dd2 Mon Sep 17 00:00:00 2001 From: Garret Pick Date: Tue, 4 Nov 2025 07:47:04 -1000 Subject: [PATCH 2/4] Modern build system: https://github.com/4teamwork/docxcompose/pull/113 --- pyproject.toml | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..99487ee --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,55 @@ +[build-system] +requires = ["setuptools>=68", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "docxcompose" +version = "1.4.1.post0+emmv" # PEP 440-valid +description = "Compose .docx documents" +requires-python = ">=3.8" +license = { text = "MIT License" } + +authors = [ + { name = "Thomas Buchberger", email = "t.buchberger@4teamwork.ch" }, +] +maintainers = [ + { name = "Emmanuel Viennet" } +] + +keywords = ["Python", "DOCX", "Word", "OOXML"] + +classifiers = [ + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] + +dependencies = [ + "lxml", + "python-docx>=0.8.8", + "six", + "Babel", # (same as 'babel'; keep if upstream uses it) +] + +[project.optional-dependencies] +test = ["pytest"] + +[project.scripts] +docxcompose = "docxcompose.command:main" + +[project.urls] +Homepage = "https://github.com/emmanuelito/docxcompose" +Repository = "https://github.com/emmanuelito/docxcompose" + + +# declare readme dynamically via setuptools +[tool.setuptools.dynamic] +readme = { file = ["README.rst", "HISTORY.txt"], content-type = "text/x-rst" } From 6e73db2f86627b365b69b2ea390dcd82f67603b0 Mon Sep 17 00:00:00 2001 From: suwilsoncongruex Date: Tue, 18 Nov 2025 16:45:20 -0800 Subject: [PATCH 3/4] cleanup, fix unit tests --- .github/workflows/build-publish.yml | 2 +- HISTORY.txt | 2 +- README.rst | 3 +-- pyproject.toml | 10 +++++++--- tests/test_properties.py | 19 ++++++++++--------- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.yml index 989d6cf..8893b64 100644 --- a/.github/workflows/build-publish.yml +++ b/.github/workflows/build-publish.yml @@ -20,7 +20,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: "3.13" - name: Install build tools run: | diff --git a/HISTORY.txt b/HISTORY.txt index 5b11f65..58337fb 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -1,7 +1,7 @@ Changelog ========= -1.4.1.post0+emmv +1.4.1.post0+tes ------------------ - Migrated build system to PEP 517/621. diff --git a/README.rst b/README.rst index 6d76eb5..5f82ea0 100644 --- a/README.rst +++ b/README.rst @@ -2,8 +2,7 @@ *docxcompose* is a Python library for concatenating/appending Microsoft Word (.docx) files. -This fork adds the PR 112, Fixed DeprecationWarning on pkg_import, by -@numshub and modernizes the build system for Python >= 3.8. +This fork fixes the DeprecationWarning on pkg_import, and modernizes the build system. Example usage ------------- diff --git a/pyproject.toml b/pyproject.toml index 5f54125..68516d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,13 +3,17 @@ requires = ["setuptools>=61.0", "wheel", "setuptools_scm"] build-backend = "setuptools.build_meta" [project] -name = "docxcompose" -version = "1.4.1.post0+tes" # PEP 440-valid +name = "docxcompose_tes" description = "Python library for concatenating/appending Microsoft Word (.docx) files." readme = "README.rst" license = {text = "MIT"} -dependencies = [] requires-python = ">=3.13" +dependencies = [ + 'lxml', + 'python-docx >= 0.8.8', + 'six', + 'babel', +] # Only version is dynamic diff --git a/tests/test_properties.py b/tests/test_properties.py index 99250a9..c8ca766 100644 --- a/tests/test_properties.py +++ b/tests/test_properties.py @@ -1,4 +1,5 @@ from datetime import datetime +from datetime import timezone from docx import Document from docx.opc.constants import RELATIONSHIP_TYPE as RT from docx.oxml import parse_xml @@ -763,12 +764,12 @@ def test_get_doc_properties(): assert props['Text Property'] == 'Foo Bar' assert props['Number Property'] == 123 assert props['Boolean Property'] is True - assert props['Date Property'] == datetime(2019, 6, 11, 10, 0) + assert props['Date Property'] == datetime(2019, 6, 11, 10, 0, tzinfo=timezone.utc) assert props.get('Text Property') == 'Foo Bar' assert props.get('Number Property') == 123 assert props.get('Boolean Property') is True - assert props.get('Date Property') == datetime(2019, 6, 11, 10, 0) + assert props.get('Date Property') == datetime(2019, 6, 11, 10, 0, tzinfo=timezone.utc) def test_get_doc_property_is_case_insensitive(): @@ -792,8 +793,8 @@ def test_add_doc_properties(): props.add('My Number Property', 123) assert props.get('My Number Property') == 123 - props.add('My Date Property', datetime(2019, 10, 23, 15, 44, 50)) - assert props.get('My Date Property') == datetime(2019, 10, 23, 15, 44, 50) + props.add('My Date Property', datetime(2019, 10, 23, 15, 44, 50, tzinfo=timezone.utc)) + assert props.get('My Date Property') == datetime(2019, 10, 23, 15, 44, 50, tzinfo=timezone.utc) def test_add_utf8_property(): @@ -817,8 +818,8 @@ def test_set_doc_properties(): props['Number Property'] = 456 assert props['Number Property'] == 456 - props['Date Property'] = datetime(2019, 10, 20, 12, 0) - assert props['Date Property'] == datetime(2019, 10, 20, 12, 0) + props['Date Property'] = datetime(2019, 10, 20, 12, 0, tzinfo=timezone.utc) + assert props['Date Property'] == datetime(2019, 10, 20, 12, 0, tzinfo=timezone.utc) def test_set_doc_property_is_case_insensitive(): @@ -913,7 +914,7 @@ def test_doc_properties_values(): props = CustomProperties(document) assert props.values() == [ - 'Foo Bar', 123, True, datetime(2019, 6, 11, 10, 0), 1.1] + 'Foo Bar', 123, True, datetime(2019, 6, 11, 10, 0, tzinfo=timezone.utc), 1.1] def test_doc_properties_items(): @@ -924,7 +925,7 @@ def test_doc_properties_items(): ('Text Property', 'Foo Bar'), ('Number Property', 123), ('Boolean Property', True), - ('Date Property', datetime(2019, 6, 11, 10, 0)), + ('Date Property', datetime(2019, 6, 11, 10, 0, tzinfo=timezone.utc)), ('Float Property', 1.1), ] @@ -933,7 +934,7 @@ def test_vt2value_value2vt_roundtrip(): assert vt2value(value2vt(42)) == 42 assert vt2value(value2vt(True)) is True assert vt2value(value2vt(1.1)) == pytest.approx(1.1) - dt = datetime(2019, 6, 11, 10, 0) + dt = datetime(2019, 6, 11, 10, 0, tzinfo=timezone.utc) assert vt2value(value2vt(dt)) == dt assert vt2value(value2vt(u'foo')) == u'foo' assert vt2value(value2vt(u'')) == u'' From 6af417f2007c94e19d58bcb7bbc6b23e8322fa67 Mon Sep 17 00:00:00 2001 From: suwilsoncongruex Date: Tue, 18 Nov 2025 16:52:10 -0800 Subject: [PATCH 4/4] Bump python-docx version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 68516d7..ae24e9f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ license = {text = "MIT"} requires-python = ">=3.13" dependencies = [ 'lxml', - 'python-docx >= 0.8.8', + 'python-docx >= 1.2.0', 'six', 'babel', ]