Subject: pkg/28415: Invalid Python version set by lang/python/extension.mk
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <sutre@labri.fr>
List: pkgsrc-bugs
Date: 11/24/2004 19:21:00
>Number:         28415
>Category:       pkg
>Synopsis:       Invalid Python version set by lang/python/extension.mk
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 24 19:21:00 +0000 2004
>Originator:     sutre@labri.fr
>Release:        NetBSD 2.0_RC4
>Organization:
>Environment:
	
	
System: NetBSD gavarnie 2.0_RC4 NetBSD 2.0_RC4 (STD-PC) #0: Tue Nov 2 07:32:08 CET 2004 instsoft@gavarnie:/usr/src/sys/arch/i386/compile/STD-PC i386
Architecture: i386
Machine: i386
>Description:

The python version detected by lang/python/extension.mk seems to be
incorrect in the following case. I did not understand why this occurs
but the fix below (a sanity check) seems to correct the problem. I'm
using the pkgsrc-2004Q3 branch, but lang/python has not changed since
then, so the problem is likely still in -current.


I came accross the problem when trying to install a custom meta-package
(in /usr/pkgsrc/local/default-install) pulling gnumeric.

After some investigation, it turned out that ${PKGNAME_REQD} was not
correctly set when "entering" lang/python/extension.mk (if I remember
well, this variable was set to "gnumeric" instead of "py23pth-gtk2"),
and hence the substitution done in lang/python/extension.mk to detect
the appropriate python version was not working. Strangely enough, there
is no problem when installing gnumeric directly (with a `make' or
`make update' in math/gnumeric).


The last lines of running `make' in my local package's directory are:

===> Required package gnumeric-[0-9]*: NOT found
===> Verifying reinstall for ../../math/gnumeric
===> Checking for vulnerabilities in gnumeric-1.2.13
=> Checksum OK for gnumeric-1.2.13.tar.bz2.
===> Extracting for gnumeric-1.2.13
===> Required installed package python23-pth>=2.3: python23-pth-2.3.4nb2 found
===> Required package py23pth-gtk2>=2.0.0nb2: NOT found
===> Verifying reinstall for ../../x11/py-gtk2
make: "../../lang/python/../../lang/python/../../lang/python/../../lang/python/pyversion.mk" line 180: Unassociated shell command "error: no valid Python version"
make: "../../lang/python/../../lang/python/../../lang/python/../../lang/python/pyversion.mk" line 187: Could not find /buildlink3.mk
make: Fatal errors encountered -- cannot continue

make: stopped in /usr/pkgsrc/x11/py-gtk2
*** Error code 1

Stop.
make: stopped in /usr/pkgsrc/x11/py-gtk2
*** Error code 1

Stop.
make: stopped in /usr/pkgsrc/math/gnumeric
*** Error code 1

Stop.
make: stopped in /usr/pkgsrc/math/gnumeric
*** Error code 1

Stop.
make: stopped in /usr/pkgsrc/math/gnumeric
*** Error code 1

Stop.
make: stopped in /usr/pkgsrc/local/default-install
*** Error code 1

Stop.
make: stopped in /usr/pkgsrc/local/default-install


>How-To-Repeat:

Create a meta-package that just includes gnumeric with the following
line:

DEPENDS+=	gnumeric-[0-9]*:../../math/gnumeric

Then make sure that gnumeric and x11/py-gtk2 are not installed,
and try to build this meta-package.


>Fix:

This is just a suggestion, I'm pretty sure there is a better fix :-)
Apply the following patch to lang/python/extension.mk:

######################################################################
--- extension.mk	12 Jun 2004 21:18:31 -0000	1.11
+++ extension.mk	24 Nov 2004 19:02:28 -0000
@@ -3,8 +3,12 @@
 # derive a python version from the package name if possible
 # optionally handled quoted package names
 .if defined(PKGNAME_REQD)
-PYTHON_VERSION_REQD?= ${PKGNAME_REQD:C/^[^-]*py([^-]*)-.*/\1/}
+PYTHON_VERSION_GUESS=	${PKGNAME_REQD:C/^[^-]*py([^-]*)-.*/\1/}
+.if ${PYTHON_VERSION_GUESS} != ${PKGNAME_REQD}
+PYTHON_VERSION_REQD?=	${PYTHON_VERSION_GUESS}
 .endif
+.endif
+
 
 .include "../../lang/python/pyversion.mk"
 
######################################################################

>Unformatted: