Sun Oct 2 22:58:52 2022 UTC ()
pyversion.mk: Define PYPKGPREFIX in error case

The specification for pyversion.mk says that it defines PYPKGPREFIX
and PYVERSSUFFIX.  Various buildlink files rely on these being
defined, as they are tested without guarding them for being empty.

When there is no valid python version, _PYTHON_VERSION was set to
"none", and PKG_FAIL_REASON defined, so the user gets a reasonable
error.  However, if a buildlink3 uses an unguarded PYPKGPREFIX, a
syntax error results, and the PKG_FAIL_REASON is not display.

This commit defines the two variables to "none" in the case of no
valid version, mirroring the treatment of _PYTHON_VERSION and
correcting a failure to follow the specification.  In this case the
build is going to fail one way or another, but it's vastly better to
have a useful error message.

(Tested earlier, but deferred during freeze.)


(gdt)
diff -r1.141 -r1.142 pkgsrc/lang/python/pyversion.mk

cvs diff -r1.141 -r1.142 pkgsrc/lang/python/pyversion.mk (expand / switch to unified diff)

--- pkgsrc/lang/python/pyversion.mk 2022/06/30 10:45:36 1.141
+++ pkgsrc/lang/python/pyversion.mk 2022/10/02 22:58:52 1.142
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: pyversion.mk,v 1.141 2022/06/30 10:45:36 nia Exp $ 1# $NetBSD: pyversion.mk,v 1.142 2022/10/02 22:58:52 gdt Exp $
2 2
3# This file determines which Python version is used as a dependency for 3# This file determines which Python version is used as a dependency for
4# a package. 4# a package.
5# 5#
6# === User-settable variables === 6# === User-settable variables ===
7# 7#
8# PYTHON_VERSION_DEFAULT 8# PYTHON_VERSION_DEFAULT
9# The preferred Python version to use. 9# The preferred Python version to use.
10# 10#
11# Possible values: 27 37 38 39 310 11# Possible values: 27 37 38 39 310
12# Default: 310 12# Default: 310
13# 13#
14# === Infrastructure variables === 14# === Infrastructure variables ===
@@ -121,26 +121,28 @@ _PYTHON_VERSION?= ${pv} @@ -121,26 +121,28 @@ _PYTHON_VERSION?= ${pv}
121. endif 121. endif
122. endfor 122. endfor
123. endif 123. endif
124.endif 124.endif
125 125
126# 126#
127# Variable assignment for multi-python packages 127# Variable assignment for multi-python packages
128MULTI+= PYTHON_VERSION_REQD=${_PYTHON_VERSION} 128MULTI+= PYTHON_VERSION_REQD=${_PYTHON_VERSION}
129 129
130# No supported version found, annotate to simplify statements below. 130# No supported version found, annotate to simplify statements below.
131.if !defined(_PYTHON_VERSION) 131.if !defined(_PYTHON_VERSION)
132_PYTHON_VERSION= none 132_PYTHON_VERSION= none
133PKG_FAIL_REASON+= "No valid Python version" 133PKG_FAIL_REASON+= "No valid Python version"
 134PYPKGPREFIX= none
 135PYVERSSUFFIX= none
134.endif 136.endif
135 137
136# Additional CONFLICTS 138# Additional CONFLICTS
137.if ${PYTHON_SELF_CONFLICT:U:tl} == "yes" 139.if ${PYTHON_SELF_CONFLICT:U:tl} == "yes"
138. for i in ${PYTHON_VERSIONS_ACCEPTED:N${_PYTHON_VERSION}} 140. for i in ${PYTHON_VERSIONS_ACCEPTED:N${_PYTHON_VERSION}}
139. if empty(PYTHON_VERSIONS_INCOMPATIBLE:M${i}) 141. if empty(PYTHON_VERSIONS_INCOMPATIBLE:M${i})
140CONFLICTS+= ${PKGNAME:S/py${_PYTHON_VERSION}/py${i}/:C/-[0-9].*$/-[0-9]*/} 142CONFLICTS+= ${PKGNAME:S/py${_PYTHON_VERSION}/py${i}/:C/-[0-9].*$/-[0-9]*/}
141. endif 143. endif
142. endfor 144. endfor
143.endif # PYCONFLICTS 145.endif # PYCONFLICTS
144 146
145# 147#
146PLIST_VARS+= py2x py3x 148PLIST_VARS+= py2x py3x