Subject: Re: PYTHON_VERSION_DEFAULT and installed Python
To: None <tech-pkg@netbsd.org>
From: None <joerg@britannica.bec.de>
List: tech-pkg
Date: 06/04/2006 14:55:16
--7AUc2qLy4jB3hD7Z
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Sat, Jun 03, 2006 at 04:22:29AM +0000, Johnny C. Lam wrote:
> On Fri, Jun 02, 2006 at 11:57:01PM +0200, joerg@britannica.bec.de wrote:
> > can I remove the current installed checks for python versions and let
> > the default only get decided by PYTHON_DEFAULT_VERSION? The current
> > behaviour is IMO very error prune and a user can always use
> > PYTHON_VERSION_REQD to force a specific Python version.
> 
> Yes, please do so.  I would like us to remove all instances of "use
> whichever is installed first" from pkgsrc.

Attached is a patch which implements three changes:
(a) Remove the logic to check for installed Python versions.
(b) Enforce that PYTHON_VERSION_REQD is supported by the package.
That means the version is in PYTHON_VERSION_ACCEPTED, but not in
PYTHON_VERSION_INCOMPATIBLE.
(c) When the default version cannot fulfill the needs of a package, the
first working version from PYTHON_VERSION_ACCEPTED is taken.

Joerg

--7AUc2qLy4jB3hD7Z
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="pyversion.mk.diff"

Index: pyversion.mk
===================================================================
RCS file: /cvsroot/pkgsrc/lang/python/pyversion.mk,v
retrieving revision 1.39
diff -u -r1.39 pyversion.mk
--- pyversion.mk	6 Apr 2006 06:22:13 -0000	1.39
+++ pyversion.mk	4 Jun 2006 12:55:02 -0000
@@ -26,64 +26,36 @@
 .endif
 .endfor
 
-# check what is installed
-.if exists(${LOCALBASE}/bin/python2.4)
-_PYTHON_VERSION_24_INSTALLED=	yes
-.endif
-.if exists(${LOCALBASE}/bin/python2.3)
-_PYTHON_VERSION_23_INSTALLED=	yes
-.endif
-.if exists(${LOCALBASE}/bin/python2.2)
-_PYTHON_VERSION_22_INSTALLED=	yes
-.endif
-.if exists(${LOCALBASE}/bin/python2.1)
-_PYTHON_VERSION_21_INSTALLED=	yes
-.endif
-.if exists(${LOCALBASE}/bin/python2.0)
-_PYTHON_VERSION_20_INSTALLED=	yes
-.endif
-.if exists(${LOCALBASE}/bin/python1.5)
-_PYTHON_VERSION_15_INSTALLED=	yes
-.endif
-
 #
 # choose a python version where to add,
 # try to be intelligent
 #
 # if a version is explicitely required, take it
 .if defined(PYTHON_VERSION_REQD)
+# but check if it is acceptable first, error out otherwise
+. if defined(_PYTHON_VERSION_${PYTHON_VERSION_REQD}_OK)
 _PYTHON_VERSION=	${PYTHON_VERSION_REQD}
-.endif
-# if the default is already installed, it is first choice
-.if !defined(_PYTHON_VERSION)
-.if defined(_PYTHON_VERSION_${PYTHON_VERSION_DEFAULT}_OK)
-.if defined(_PYTHON_VERSION_${PYTHON_VERSION_DEFAULT}_INSTALLED)
+. endif
+.else
+# if the default is accepted, it is first choice
+. if !defined(_PYTHON_VERSION)
+. if defined(_PYTHON_VERSION_${PYTHON_VERSION_DEFAULT}_OK)
 _PYTHON_VERSION=	${PYTHON_VERSION_DEFAULT}
-.endif
-.endif
-.endif
+. endif
+. endif
 # prefer an already installed version, in order of "accepted"
-.if !defined(_PYTHON_VERSION)
-.for pv in ${PYTHON_VERSIONS_ACCEPTED}
-.if defined(_PYTHON_VERSION_${pv}_OK)
-.if defined(_PYTHON_VERSION_${pv}_INSTALLED)
+. if !defined(_PYTHON_VERSION)
+. for pv in ${PYTHON_VERSIONS_ACCEPTED}
+. if defined(_PYTHON_VERSION_${pv}_OK)
 _PYTHON_VERSION?=	${pv}
-.else
-# keep information as last resort - see below
-_PYTHON_VERSION_FIRSTACCEPTED?=	${pv}
-.endif
-.endif
-.endfor
+. endif
+. endfor
+. endif
 .endif
-# if the default is OK for the addon pkg, take this
-.if !defined(_PYTHON_VERSION)
-.if defined(_PYTHON_VERSION_${PYTHON_VERSION_DEFAULT}_OK)
-_PYTHON_VERSION=	${PYTHON_VERSION_DEFAULT}
-.endif
-.endif
-# take the first one accepted by the package
+
+# No supported version found, annotate to simplify statements below.
 .if !defined(_PYTHON_VERSION)
-_PYTHON_VERSION=	${_PYTHON_VERSION_FIRSTACCEPTED}
+_PYTHON_VERSION=	none
 .endif
 
 #

--7AUc2qLy4jB3hD7Z--