Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ pip-selfcheck.json

/.cache/
dist/
.idea/
7 changes: 7 additions & 0 deletions HISTORY.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

1.4.1.post0+tes
------------------

- 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)
------------------
Expand Down
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*docxcompose* is a Python library for concatenating/appending Microsoft
Word (.docx) files.

This fork fixes the DeprecationWarning on pkg_import, and modernizes the build system.

Example usage
-------------
Expand Down
6 changes: 3 additions & 3 deletions docxcompose/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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:
Expand Down
13 changes: 11 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ build-backend = "setuptools.build_meta"

[project]
name = "docxcompose_tes"
authors = [{ name="Telengsol", email="devops+test-pypi@telengsol.com" }]
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 >= 1.2.0',
'six',
'babel',
]


# Only version is dynamic
dynamic = ["version"]
Expand All @@ -33,3 +39,6 @@ tests = ["pytest"]
version_scheme = "guess-next-dev"
local_scheme = "node-and-date"

# declare readme dynamically via setuptools
[tool.setuptools.dynamic]
readme = { file = ["README.rst", "HISTORY.txt"], content-type = "text/x-rst" }
50 changes: 0 additions & 50 deletions setup.py

This file was deleted.

19 changes: 10 additions & 9 deletions tests/test_properties.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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():
Expand All @@ -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():
Expand All @@ -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():
Expand Down Expand Up @@ -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():
Expand All @@ -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),
]

Expand All @@ -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''
Expand Down