Annotation of pkgsrc/lang/python/pyversion.mk, revision 1.88

1.88    ! obache      1: # $NetBSD: pyversion.mk,v 1.87 2011/03/12 14:07:13 wiz Exp $
1.44      rillig      2: 
                      3: # This file determines which Python version is used as a dependency for
                      4: # a package.
                      5: #
1.48      rillig      6: # === User-settable variables ===
1.44      rillig      7: #
                      8: # PYTHON_VERSION_DEFAULT
                      9: #      The preferred Python version to use.
                     10: #
1.83      obache     11: #      Possible values: 24 25 26 27
1.79      joerg      12: #      Default: 26
1.44      rillig     13: #
1.48      rillig     14: # === Package-settable variables ===
1.44      rillig     15: #
                     16: # PYTHON_VERSIONS_ACCEPTED
                     17: #      The Python versions that are acceptable for the package. The
1.48      rillig     18: #      order of the entries matters, since earlier entries are
1.62      joerg      19: #      preferred over later ones.
1.44      rillig     20: #
1.83      obache     21: #      Possible values: 27 26 25 24
                     22: #      Default: 27 26 25 24
1.44      rillig     23: #
                     24: # PYTHON_VERSIONS_INCOMPATIBLE
                     25: #      The Python versions that are NOT acceptable for the package.
                     26: #
1.83      obache     27: #      Possible values: 24 25 26 27
1.44      rillig     28: #      Default: (depends on the platform)
                     29: #
                     30: # PYTHON_FOR_BUILD_ONLY
                     31: #      Whether Python is needed only at build time or at run time.
                     32: #
                     33: #      Possible values: (defined) (undefined)
                     34: #      Default: (undefined)
                     35: #
1.52      rillig     36: # === Defined variables ===
                     37: #
                     38: # PYPKGPREFIX
                     39: #      The prefix to use in PKGNAME for extensions which are meant
                     40: #      to be installed for multiple Python versions.
                     41: #
1.83      obache     42: #      Example: py26
1.52      rillig     43: #
                     44: # PYVERSSUFFIX
                     45: #      The suffix to executables and in the library path, equal to
                     46: #      sys.version[0:3].
                     47: #
1.83      obache     48: #      Example: 2.6
1.52      rillig     49: #
1.46      rillig     50: # Keywords: python
                     51: #
1.2       drochner   52: 
                     53: .if !defined(PYTHON_PYVERSION_MK)
                     54: PYTHON_PYVERSION_MK=   defined
1.1       drochner   55: 
1.66      joerg      56: # derive a python version from the package name if possible
                     57: # optionally handled quoted package names
                     58: .if defined(PKGNAME_REQD) && !empty(PKGNAME_REQD:Mpy[0-9][0-9]-*) || \
                     59:     defined(PKGNAME_REQD) && !empty(PKGNAME_REQD:M*-py[0-9][0-9]-*)
                     60: PYTHON_VERSION_REQD?= ${PKGNAME_REQD:C/(^.*-|^)py([0-9][0-9])-.*/\2/}
                     61: .elif defined(PKGNAME_OLD) && !empty(PKGNAME_OLD:Mpy[0-9][0-9]-*) || \
                     62:       defined(PKGNAME_OLD) && !empty(PKGNAME_OLD:M*-py[0-9][0-9]-*)
                     63: PYTHON_VERSION_REQD?= ${PKGNAME_OLD:C/(^.*-|^)py([0-9][0-9])-.*/\2/}
                     64: .endif
                     65: 
1.1       drochner   66: .include "../../mk/bsd.prefs.mk"
                     67: 
1.46      rillig     68: BUILD_DEFS+=           PYTHON_VERSION_DEFAULT
                     69: BUILD_DEFS_EFFECTS+=   PYPACKAGE
                     70: 
1.75      tron       71: PYTHON_VERSION_DEFAULT?=               26
1.88    ! obache     72: PYTHON_VERSIONS_ACCEPTED?=             27 26 25 24
1.56      joerg      73: PYTHON_VERSIONS_INCOMPATIBLE?=         # empty by default
                     74: 
1.39      reed       75: BUILDLINK_API_DEPENDS.python24?=               python24>=2.4
1.50      xtraeme    76: BUILDLINK_API_DEPENDS.python25?=               python25>=2.5.1
1.70      snj        77: BUILDLINK_API_DEPENDS.python26?=               python26>=2.6
1.84      obache     78: BUILDLINK_API_DEPENDS.python27?=               python27>=2.7
1.4       drochner   79: 
1.1       drochner   80: # transform the list into individual variables
                     81: .for pv in ${PYTHON_VERSIONS_ACCEPTED}
1.28      tv         82: .if empty(PYTHON_VERSIONS_INCOMPATIBLE:M${pv})
1.1       drochner   83: _PYTHON_VERSION_${pv}_OK=      yes
1.56      joerg      84: _PYTHON_VERSIONS_ACCEPTED+=    ${pv}
1.28      tv         85: .endif
1.1       drochner   86: .endfor
                     87: 
                     88: #
                     89: # choose a python version where to add,
                     90: # try to be intelligent
                     91: #
1.2       drochner   92: # if a version is explicitely required, take it
                     93: .if defined(PYTHON_VERSION_REQD)
1.40      joerg      94: # but check if it is acceptable first, error out otherwise
                     95: . if defined(_PYTHON_VERSION_${PYTHON_VERSION_REQD}_OK)
1.2       drochner   96: _PYTHON_VERSION=       ${PYTHON_VERSION_REQD}
1.40      joerg      97: . endif
                     98: .else
                     99: # if the default is accepted, it is first choice
                    100: . if !defined(_PYTHON_VERSION)
                    101: . if defined(_PYTHON_VERSION_${PYTHON_VERSION_DEFAULT}_OK)
1.1       drochner  102: _PYTHON_VERSION=       ${PYTHON_VERSION_DEFAULT}
1.40      joerg     103: . endif
                    104: . endif
1.1       drochner  105: # prefer an already installed version, in order of "accepted"
1.40      joerg     106: . if !defined(_PYTHON_VERSION)
                    107: . for pv in ${PYTHON_VERSIONS_ACCEPTED}
                    108: . if defined(_PYTHON_VERSION_${pv}_OK)
1.1       drochner  109: _PYTHON_VERSION?=      ${pv}
1.40      joerg     110: . endif
                    111: . endfor
                    112: . endif
1.1       drochner  113: .endif
1.40      joerg     114: 
1.87      wiz       115: #
                    116: # Variable assignment for multi-python packages
                    117: MULTI+=        PYTHON_VERSION_REQD=${_PYTHON_VERSION}
                    118: 
1.40      joerg     119: # No supported version found, annotate to simplify statements below.
1.1       drochner  120: .if !defined(_PYTHON_VERSION)
1.40      joerg     121: _PYTHON_VERSION=       none
1.1       drochner  122: .endif
                    123: 
1.83      obache    124: .if ${_PYTHON_VERSION} == "27"
                    125: PYPKGSRCDIR=   ../../lang/python27
                    126: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python27}:${PYPKGSRCDIR}
                    127: PYPACKAGE=     python27
                    128: PYVERSSUFFIX=  2.7
                    129: PYPKGPREFIX=   py27
                    130: PYDISTUTILS_CREATES_EGGFILES=  yes
                    131: .elif ${_PYTHON_VERSION} == "26"
1.68      wiz       132: PYPKGSRCDIR=   ../../lang/python26
                    133: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python26}:${PYPKGSRCDIR}
                    134: PYPACKAGE=     python26
                    135: PYVERSSUFFIX=  2.6
                    136: PYPKGPREFIX=   py26
1.81      gdt       137: PYDISTUTILS_CREATES_EGGFILES=  yes
1.68      wiz       138: .elif ${_PYTHON_VERSION} == "25"
1.57      tnn       139: PYPKGSRCDIR=   ../../lang/python25
1.50      xtraeme   140: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python25}:${PYPKGSRCDIR}
                    141: PYPACKAGE=     python25
                    142: PYVERSSUFFIX=  2.5
                    143: PYPKGPREFIX=   py25
1.81      gdt       144: PYDISTUTILS_CREATES_EGGFILES=  yes
1.50      xtraeme   145: .elif ${_PYTHON_VERSION} == "24"
1.30      recht     146: PYPKGSRCDIR=   ../../lang/python24
1.39      reed      147: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python24}:${PYPKGSRCDIR}
1.30      recht     148: PYPACKAGE=     python24
                    149: PYVERSSUFFIX=  2.4
                    150: PYPKGPREFIX=   py24
1.81      gdt       151: PYDISTUTILS_CREATES_EGGFILES=  no
1.8       drochner  152: .else
1.48      rillig    153: PKG_FAIL_REASON+=   "No valid Python version"
1.1       drochner  154: .endif
1.5       drochner  155: 
1.38      rillig    156: PTHREAD_OPTS+= require
1.33      jlam      157: .include "../../mk/pthread.buildlink3.mk"
1.38      rillig    158: 
1.33      jlam      159: .if defined(PYTHON_FOR_BUILD_ONLY)
1.36      seb       160: BUILDLINK_DEPMETHOD.python?=   build
1.11      jlam      161: .endif
1.37      kristerw  162: .if defined(PYPKGSRCDIR)
1.33      jlam      163: .include "${PYPKGSRCDIR}/buildlink3.mk"
1.37      kristerw  164: .endif
1.11      jlam      165: 
                    166: PYTHONBIN=     ${LOCALBASE}/bin/python${PYVERSSUFFIX}
1.78      joerg     167: PYTHONCONFIG=  ${LOCALBASE}/bin/python${PYVERSSUFFIX}-config
1.73      joerg     168: PY_COMPILE_ALL= \
                    169:        ${PYTHONBIN} ${PREFIX}/lib/python${PYVERSSUFFIX}/compileall.py -q
                    170: PY_COMPILE_O_ALL= \
                    171:        ${PYTHONBIN} -O ${PREFIX}/lib/python${PYVERSSUFFIX}/compileall.py -q
1.11      jlam      172: 
1.61      snj       173: .if exists(${PYTHONBIN})
1.11      jlam      174: PYINC!=        ${PYTHONBIN} -c "import distutils.sysconfig; \
1.85      obache    175:        print (distutils.sysconfig.get_python_inc(0, \"\"))" || ${ECHO} ""
1.11      jlam      176: PYLIB!=        ${PYTHONBIN} -c "import distutils.sysconfig; \
1.85      obache    177:        print (distutils.sysconfig.get_python_lib(0, 1, \"\"))" || ${ECHO} ""
1.11      jlam      178: PYSITELIB!=    ${PYTHONBIN} -c "import distutils.sysconfig; \
1.85      obache    179:        print (distutils.sysconfig.get_python_lib(0, 0, \"\"))" || ${ECHO} ""
1.72      joerg     180: 
                    181: PRINT_PLIST_AWK+=      /^${PYINC:S|/|\\/|g}/ \
1.82      obache    182:                        { gsub(/${PYINC:S|/|\\/|g}/, "$${PYINC}") }
1.72      joerg     183: PRINT_PLIST_AWK+=      /^${PYSITELIB:S|/|\\/|g}/ \
1.82      obache    184:                        { gsub(/${PYSITELIB:S|/|\\/|g}/, "$${PYSITELIB}") }
1.72      joerg     185: PRINT_PLIST_AWK+=      /^${PYLIB:S|/|\\/|g}/ \
1.82      obache    186:                        { gsub(/${PYLIB:S|/|\\/|g}/, "$${PYLIB}") }
1.6       drochner  187: .endif
1.2       drochner  188: 
1.47      rillig    189: ALL_ENV+=      PYTHON=${PYTHONBIN}
1.80      drochner  190: .if defined(USE_CMAKE)
                    191: # used by FindPythonInterp.cmake and FindPythonLibs.cmake
                    192: CMAKE_ARGS+=   -DPYVERSSUFFIX:STRING=${PYVERSSUFFIX}
                    193: .endif
1.47      rillig    194: 
1.2       drochner  195: .endif # PYTHON_PYVERSION_MK

CVSweb <webmaster@jp.NetBSD.org>