tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

USE_PKG_RESOURCES and wheel.mk



In a package that used wheel.mk and where upstream noted that it used
pkg_resources, I set USE_PKG_RESOURCES.  But wheel.mk doesn't support
that.

It seems pkg_resources is deprecated:

  https://setuptools.pypa.io/en/latest/pkg_resources.html

but we package things that still use it, and sometimes we do that with
wheel.mk.

The overall situation is buggy :-)

I can see three reasonable approaches:

  Noting in wheel.mk in comments that USE_PKG_RESOURCES is not
  implemented, and that instead one should DEPEND on setuptools.

  Bringing the USE_PKG_RESOURCES condition DEPEND to wheel.mk.

  Get every python package that uses pkg_resources to release a new,
  stable version that switches to importlib, and get them all in pkgsrc.

of which only two are feasible.

But seriously, what do people think about a comment vs.

--- wheel.mk.~1.20.~	2025-02-02 10:26:12.000000000 -0500
+++ wheel.mk	2025-04-07 19:24:31.308304635 -0400
@@ -23,6 +23,9 @@
 # WHEELFILE:		Path to the wheelfile to be installed.
 #			Only needs to be set if do-build is redefined.
 #
+# USE_PKG_RESOURCES:	If set to yes, depend on setuptools (because the
+#			package uses pkg_resources from setuptools at runtime.)
+#
 # USE_PYTEST:		If set to yes, depend on py-test and use it for testing.
 #			Default: yes
 #
@@ -71,6 +74,17 @@ do-install:
 		${WHEELFILE}
 .endif
 
+USE_PKG_RESOURCES?=	no
+.if "${PYVERSSUFFIX}" == "2.7"
+SETUPTOOLS_PATH=../../devel/py-setuptools44
+.else
+SETUPTOOLS_PATH=../../devel/py-setuptools
+.endif
+.if "${USE_PKG_RESOURCES}" == "yes"
+# when packages use pkg_resources, setuptools is needed at runtime
+DEPENDS+=	${PYPKGPREFIX}-setuptools-[0-9]*:${SETUPTOOLS_PATH}
+.endif
+
 USE_PYTEST?=	yes
 .if !target(do-test) && ${USE_PYTEST:Myes}
 TEST_DEPENDS+= ${PYPKGPREFIX}-test-[0-9]*:../../devel/py-test


Home | Main Index | Thread Index | Old Index