Deprecation warning: pkg_resources will be removed from setuptools in 2025
I am using the docxcompose library, and I have encountered the following deprecation warning related to pkg_resources:
UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81. import pkg_resources
This warning informs us that pkg_resources will be removed from setuptools after November 2025. As this library depends on pkg_resources, this could cause compatibility issues with future versions of Python and setuptools.
Related https://github.com/4teamwork/docxcompose/issues/105
Last commit of docxcompose is 3 years ago, I think it is time to remove this line
from .subdoc import Subdoc
from docxtpl/__init__.py, and move docxcompose to optional dependencies.
I would also really like to see docxcompose moved to optional dependencies.
Perhaps we can extract this to a separate PR so it's easier to merge?
Another argument for this is that docxcompose hasn't published any wheels (causing issues when installing manylinux reqs).
@svleeuwen done. https://github.com/elapouya/python-docx-template/pull/615
Hi team, another option here someone has made a fork and fixed this bug, @waketzheng this might be an option to close it out long term > https://github.com/darkvisiontech/docxcompose
I rechecked this against the current upstream releases. The original pkg_resources problem is resolved now.
- docxcompose 2.0.0 removed the deprecated API, and current 2.2.0 has no
pkg_resourcesimport: https://github.com/4teamwork/docxcompose/blob/2.2.0/CHANGELOG.md - For older Python versions that cannot install 2.x, upstream published 1.4.1 specifically as a compatibility backport removing
pkg_resources: https://github.com/4teamwork/docxcompose/blob/1.4.1/HISTORY.txt - The exact backport is visible here: https://github.com/4teamwork/docxcompose/commit/a06fe7d1193d90b90fbde1aa0720e0c1c36f4ace
I also tested the current python-docx-template master subdocument path under -W error:
- CPython 3.8.20 with docxcompose 1.4.1 and no setuptools package installed
- CPython 3.12.13 with docxcompose 2.2.0
In both environments, importing CustomProperties, loading its XML template, and creating a subdocument with new_subdoc() passed. This issue can be closed as resolved upstream.
@lhe127 fyi, docxcompose 2.x no longer uses pkg_resources, and Docform (the maintained fork at https://github.com/cvas22/docform, docform on PyPI) pulls the latest through its docform[subdoc] extra, so the warning is gone there.