1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
From: Tero Vuotila <tero.vuotila@falcony.io>
Date: Fri, 29 Sep 2023 17:06:05 +0300
Subject: Replace pkg_resources with importlib_resources
Fixes #90
Require Python 3.9+, because importlib.resources.files is used.
Origin: other, https://github.com/4teamwork/docxcompose/pull/91
Bug: https://github.com/4teamwork/docxcompose/issues/90
Bug-Debian: https://bugs.debian.org/1083632
Last-Update: 2026-01-08
---
docxcompose/properties.py | 9 ++++++---
setup.py | 3 +--
tox.ini | 2 +-
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/docxcompose/properties.py b/docxcompose/properties.py
index f89fb54..a7887a8 100644
--- a/docxcompose/properties.py
+++ b/docxcompose/properties.py
@@ -11,11 +11,11 @@ from docx.oxml.coreprops import CT_CoreProperties
from docxcompose.utils import NS
from docxcompose.utils import word_to_python_date_format
from docxcompose.utils import xpath
+from importlib import resources
from lxml.etree import FunctionNamespace
from lxml.etree import QName
binary_type = bytes
text_type = str
-import pkg_resources
import re
@@ -108,8 +108,11 @@ class CustomProperties(object):
self._element = parse_xml(part.blob)
def _part_template(self):
- return pkg_resources.resource_string(
- 'docxcompose', 'templates/custom.xml')
+ return (
+ resources.files('docxcompose')
+ .joinpath('templates/custom.xml')
+ .read_bytes()
+ )
def _update_part(self):
if self.part is None:
diff --git a/setup.py b/setup.py
index 751b689..334997a 100644
--- a/setup.py
+++ b/setup.py
@@ -18,7 +18,6 @@ setup(
# 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",
@@ -31,10 +30,10 @@ setup(
packages=find_packages(exclude=['ez_setup']),
include_package_data=True,
zip_safe=True,
+ python_requires=">=3.9",
install_requires=[
'lxml',
'python-docx >= 0.8.8',
- 'setuptools',
'babel',
],
extras_require={
diff --git a/tox.ini b/tox.ini
index bc93ad0..6add372 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist = py27, py36
+envlist = py39
[testenv]
deps = .[tests]
|