python-docx-template icon indicating copy to clipboard operation
python-docx-template copied to clipboard

Deprecation warning: pkg_resources will be removed from setuptools in 2025

Open lhe127 opened this issue 1 year ago • 7 comments

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.

lhe127 avatar Jul 16 '25 03:07 lhe127

Related https://github.com/4teamwork/docxcompose/issues/105

waketzheng avatar Jul 22 '25 15:07 waketzheng

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.

waketzheng avatar Jul 22 '25 15:07 waketzheng

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 avatar Sep 22 '25 12:09 svleeuwen

@svleeuwen done. https://github.com/elapouya/python-docx-template/pull/615

waketzheng avatar Sep 23 '25 12:09 waketzheng

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

ghost avatar Nov 02 '25 21:11 ghost

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_resources import: 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.

jackspiece avatar Jul 30 '26 14:07 jackspiece

@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.

cvas22 avatar Nov 22 '26 09:11 cvas22