From owner-freebsd-ports@FreeBSD.ORG Sat Oct 11 21:31:07 2003 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1DC0316A4B3 for ; Sat, 11 Oct 2003 21:31:07 -0700 (PDT) Received: from sbtm.yonsei.net (sbtm.yonsei.net [61.100.191.60]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7D40E43F85 for ; Sat, 11 Oct 2003 21:31:05 -0700 (PDT) (envelope-from perky@sbtm.yonsei.net) Received: by sbtm.yonsei.net (Postfix, from userid 1001) id 74DDC2840F; Sun, 12 Oct 2003 13:31:03 +0900 (KST) Date: Sun, 12 Oct 2003 13:31:03 +0900 From: Hye-Shik Chang To: ports@FreeBSD.org Message-ID: <20031012043103.GA38679@i18n.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Organization: Yonsei University User-Agent: Mutt/1.5.4i Subject: Request for Comments: bsd.python.mk improvement for version checking X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Oct 2003 04:31:07 -0000 Hi! I'm going to commit this modification to enable python ports to check Python's version. With this patch, you'll be able to use it this way. USE_PYTHON= yes # backward compatible USE_PYTHON= 2.2 # same as PYTHON_VERSION=python2.2 USE_PYTHON= 2.1+ # 2.1 at least USE_PYTHON= 2.0-2.2 # from 2.0 to 2.2 USE_PYTHON= -2.3 # up to 2.3. 2.4 is not allowed. If you have an interest on this, please test the patch for your python ports. Any comments, suggestions, and/or patches are very welcome. Thank you in advance! Index: bsd.python.mk =================================================================== RCS file: /home/pcvs/ports/Mk/bsd.python.mk,v retrieving revision 1.36 diff -u -r1.36 bsd.python.mk --- bsd.python.mk 4 Oct 2003 05:17:10 -0000 1.36 +++ bsd.python.mk 12 Oct 2003 02:42:49 -0000 @@ -13,7 +13,9 @@ # make your life easier when dealing with ports related to the Python # language. It's automatically included when USE_PYTHON or PYTHON_VERSION # is defined in the ports' makefile. Define PYTHON_VERSION to override the -# defaults that USE_PYTHON would give you. +# defaults that USE_PYTHON would give you. If your port requires only some +# set of Python versions, you can define USE_PYTHON as [min]-[max] or +# min+. (eg. 2.1-2.3, 2.0+ or -2.2) # # The variables: # @@ -39,6 +41,10 @@ # packages for different Python versions. # default: py${PYTHON_SUFFIX}- # +# PYTHON_PKGNAMESUFFIX: If your port's name is more popular without `py-' +# prefix, use this as a ${PKGNAMESUFFIX} alternatively. +# default: -py${PYTHON_SUFFIX} +# # PYTHON_PLATFORM: Python's idea of the OS release. # XXX This is faked with ${OPSYS} and ${OSREL} until I # find out how to delay defining a variable until after @@ -99,24 +105,77 @@ # PYSETUP: Name of the setup script used by the distutils package. # default: setup.py +_PYTHON_PORTBRANCH= 2.3 +_PYTHON_PORTVERSION= 2.3.2 +_PYTHON_ALLBRANCHES= 2.3 2.2 2.1 2.0 1.5 2.4 # preferred first + +.if defined(USE_ZOPE) +PYTHON_VERSION= python2.2 +.endif + +.if defined(PYTHON_VERSION) +_PYTHON_VERSION!= echo "${PYTHON_VERSION}" | ${SED} 's/^python//' +_PYTHON_CMD= ${LOCALBASE}/bin/${PYTHON_VERSION} +.else # Determine the currently installed version. If Python is not installed, a # default version number is substituted and the corresponding Python # distribution will be built through the dependency processing. .if defined(PYTHON_CMD) -_PYTHON_VERSION!= ${PYTHON_CMD} -c 'import sys; print sys.version[:3]' -.elif defined(USE_ZOPE) -_PYTHON_VERSION= 2.1 +_PYTHON_CMD= ${PYTHON_CMD} .else -_PYTHON_VERSION!= (${LOCALBASE}/bin/python -c 'import sys; print sys.version[:3]') 2> /dev/null \ - || echo 2.3 +_PYTHON_CMD= ${LOCALBASE}/bin/python +.endif +_PYTHON_VERSION!= ${_PYTHON_CMD} -c \ + 'import sys; print sys.version[:3]' 2> /dev/null \ + || echo ${_PYTHON_PORTBRANCH} +.endif # defined(PYTHON_VERSION) + +# Validate Python version whether it meets USE_PYTHON version restriction. +_PYTHON_VERSION_CHECK!= echo "${USE_PYTHON}" | \ + ${SED} 's/^\([1-9]\.[0-9]\)$$/\1-\1/' +_PYTHON_VERSION_MINIMUM!= echo "${_PYTHON_VERSION_CHECK}" | \ + ${SED} -n 's/.*\([1-9]\.[0-9]\)[-+].*/\1/p' +_PYTHON_VERSION_MAXIMUM!= echo "${_PYTHON_VERSION_CHECK}" | \ + ${SED} -n 's/.*-\([1-9]\.[0-9]\).*/\1/p' +.if !empty(_PYTHON_VERSION_MINIMUM) && ( \ + ${_PYTHON_VERSION} < ${_PYTHON_VERSION_MINIMUM}) +_PYTHON_VERSION_NONSUPPORTED= ${_PYTHON_VERSION_MINIMUM} at least +.elif !empty(_PYTHON_VERSION_MAXIMUM) && ( \ + ${_PYTHON_VERSION} > ${_PYTHON_VERSION_MAXIMUM}) +_PYTHON_VERSION_NONSUPPORTED= ${_PYTHON_VERSION_MAXIMUM} at most .endif + +# If we have an unsupported version of Python, try another. +.if defined(_PYTHON_VERSION_NONSUPPORTED) +.if defined(PYTHON_VERSION) || defined(PYTHON_CMD) +IGNORE= needs Python ${_PYTHON_VERSION_NONSUPPORTED}.\ + But you specified ${_PYTHON_VERSION} +.else +.undef _PYTHON_VERSION +.for ver in ${_PYTHON_ALLBRANCHES} +__VER= ${ver} +.if !defined(_PYTHON_VERSION) && \ + !(!empty(_PYTHON_VERSION_MINIMUM) && ( \ + ${__VER} < ${_PYTHON_VERSION_MINIMUM})) && \ + !(!empty(_PYTHON_VERSION_MAXIMUM) && ( \ + ${__VER} > ${_PYTHON_VERSION_MAXIMUM})) +_PYTHON_VERSION= ${ver} +_PYTHON_CMD= ${LOCALBASE}/bin/python${ver} +.endif +.endfor +.if !defined(_PYTHON_VERSION) +IGNORE= needs an unsupported version of Python +_PYTHON_VERSION= ${_PYTHON_PORTBRANCH} # just to avoid version sanity checking. +.endif +.endif # defined(PYTHON_VERSION) || defined(PYTHON_CMD) +.endif # defined(_PYTHON_VERSION_NONSUPPORTED) + PYTHON_VERSION?= python${_PYTHON_VERSION} -_PYTHON_PORTVERSION= 2.3.2 -PYTHON_CMD?= ${PYTHONBASE}/bin/${PYTHON_VERSION} +PYTHON_CMD?= ${_PYTHON_CMD} PYTHONBASE!= (${PYTHON_CMD} -c 'import sys; print sys.prefix') \ 2> /dev/null || echo ${LOCALBASE} -PYTHON_PORTVERSION!= (${PYTHON_CMD} -c 'import string, sys; \ - print string.split(sys.version)[0]') 2> /dev/null \ +PYTHON_PORTVERSION!=(${PYTHON_CMD} -c 'import string, sys; \ + print string.split(sys.version)[0]') 2> /dev/null \ || echo ${_PYTHON_PORTVERSION} # Python-2.4 @@ -207,6 +266,7 @@ PYTHON_INCLUDEDIR= ${PYTHONBASE}/include/${PYTHON_VERSION} PYTHON_LIBDIR= ${PYTHONBASE}/lib/${PYTHON_VERSION} PYTHON_PKGNAMEPREFIX= py${PYTHON_SUFFIX}- +PYTHON_PKGNAMESUFFIX= -py${PYTHON_SUFFIX} PYTHON_PLATFORM!= expr ${OPSYS:L}${OSREL} : '\(.*\)\.' PYTHON_SITELIBDIR= ${PYTHON_LIBDIR}/site-packages