git: ad7f115cddd9 - main - devel/py-setuptools_scm: Turn py-packaging into a soft dependency

From: Kai Knoblich <kai_at_FreeBSD.org>
Date: Thu, 09 Dec 2021 18:58:19 UTC
The branch main has been updated by kai:

URL: https://cgit.FreeBSD.org/ports/commit/?id=ad7f115cddd949d6ffd41bd9889328c06f8906e4

commit ad7f115cddd949d6ffd41bd9889328c06f8906e4
Author:     Kai Knoblich <kai@FreeBSD.org>
AuthorDate: 2021-12-09 18:49:49 +0000
Commit:     Kai Knoblich <kai@FreeBSD.org>
CommitDate: 2021-12-09 18:49:49 +0000

    devel/py-setuptools_scm: Turn py-packaging into a soft dependency
    
    * Since the 6.3.0 release, devel/py-packaging has been defined in the
      "setup.cfg" as an unconditional dependency.  However this leads to
      problems if py-packaging is uninstalled but py-setuptools_scm
      persists, then the missing port can no longer be built. [1]
    
      Although py-setuptools_scm has a fallback to devel/py-setuptools when
      py-packaging is absent this fallback code is not executed.  This is
      because py-setuptools, which checks the dependencies of
      py-setuptools_scm upon invocation and terminates as soon as these are
      not met.
    
      Fix this issue by converting py-packaging into an optional dependency
      for py-setuptools_scm so that the fallback code is really used if
      py-packaging is absent.  But keep the latter one in the RUN_DEPENDS in
      order to continue to reflect the actual dependencies.
    
    * Also add py-packaging to BUILD_DEPENDS as defined in "pyproject.toml"
      although it's not strictly required to build the port. [2]
    
    * Bump PORTREVISION due package change.
    
    PR:             259981
    Reported by:    many [1], koobs [2]
    Tested by:      se, myself
---
 devel/py-setuptools_scm/Makefile              |  4 +++-
 devel/py-setuptools_scm/files/patch-setup.cfg | 19 +++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/devel/py-setuptools_scm/Makefile b/devel/py-setuptools_scm/Makefile
index 58a5c111ad98..ed38105484b9 100644
--- a/devel/py-setuptools_scm/Makefile
+++ b/devel/py-setuptools_scm/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	setuptools_scm
 PORTVERSION=	6.3.2
+PORTREVISION=	1
 CATEGORIES=	devel python
 MASTER_SITES=	CHEESESHOP
 PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
@@ -10,7 +11,8 @@ COMMENT=	Setuptools plugin to manage your versions by scm tags
 LICENSE=	MIT
 LICENSE_FILE=	${WRKSRC}/LICENSE
 
-BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}tomli>=1.0.0:textproc/py-tomli@${PY_FLAVOR}
+BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}packaging>=20.0:devel/py-packaging@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}tomli>=1.0.0:textproc/py-tomli@${PY_FLAVOR}
 RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}packaging>=20.0:devel/py-packaging@${PY_FLAVOR}
 TEST_DEPENDS=	git:devel/git \
 		${PY_MERCURIAL} \
diff --git a/devel/py-setuptools_scm/files/patch-setup.cfg b/devel/py-setuptools_scm/files/patch-setup.cfg
new file mode 100644
index 000000000000..023b8f628e4d
--- /dev/null
+++ b/devel/py-setuptools_scm/files/patch-setup.cfg
@@ -0,0 +1,19 @@
+Avoid errors during runtime if devel/py-packaging is not present.
+
+The package is only required in "_version_cls.py" and falls back to
+devel/py-setuptools (via "try ... except") if it's not available.
+
+This is a workaround to remedy issues with upgrade runs that also update
+devel/py-{packaging,pyparsing} in environments where devel/py-setuptools_scm is
+already present.
+
+--- setup.cfg.orig	2021-12-05 20:43:43 UTC
++++ setup.cfg
+@@ -27,7 +27,6 @@ classifiers = 
+ [options]
+ packages = find:
+ install_requires = 
+-	packaging>=20.0
+ 	setuptools
+ 	tomli>=1.0.0 # keep in sync
+ python_requires = >=3.6