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

1.112   ! wiz         1: # $NetBSD: pyversion.mk,v 1.111 2014/01/18 19:50:27 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.110     wiz        11: #      Possible values: 26 27 33
1.96      wiz        12: #      Default: 27
1.44      rillig     13: #
1.104     cheusov    14: # === Infrastructure variables ===
                     15: #
1.101     cheusov    16: # PYTHON_VERSION_REQD
1.104     cheusov    17: #      Python version to use. This variable should not be set in
                     18: #      packages.  Normally it is used by bulk build tools.
1.101     cheusov    19: #
                     20: #      Possible: ${PYTHON_VERSIONS_ACCEPTED}
                     21: #      Default:  ${PYTHON_VERSION_DEFAULT}
                     22: #
1.48      rillig     23: # === Package-settable variables ===
1.44      rillig     24: #
                     25: # PYTHON_VERSIONS_ACCEPTED
                     26: #      The Python versions that are acceptable for the package. The
1.48      rillig     27: #      order of the entries matters, since earlier entries are
1.62      joerg      28: #      preferred over later ones.
1.44      rillig     29: #
1.110     wiz        30: #      Possible values: 33 27 26
                     31: #      Default: (33) 27 26
1.92      joerg      32: #
1.112   ! wiz        33: # PYTHON_VERSIONS_INCLUDE_3X
        !            34: #      Wether the default PYTHON_VERSIONS_ACCEPTED should include
        !            35: #      3.x versions for for this package or not.
        !            36: #      This variable must be set before including bsd.prefs.mk.
        !            37: #
        !            38: #      Possible values: yes no
        !            39: #      Default: no
        !            40: #
1.44      rillig     41: # PYTHON_VERSIONS_INCOMPATIBLE
                     42: #      The Python versions that are NOT acceptable for the package.
                     43: #
1.110     wiz        44: #      Possible values: 26 27 33
1.112   ! wiz        45: #      Default: (depends on the platform)
1.44      rillig     46: #
                     47: # PYTHON_FOR_BUILD_ONLY
                     48: #      Whether Python is needed only at build time or at run time.
                     49: #
1.108     riastrad   50: #      Possible values: yes no tool
                     51: #      Default: no
1.44      rillig     52: #
1.103     cheusov    53: # PYTHON_SELF_CONFLICT
                     54: #      If set to "yes", additional CONFLICTS entries are added for
                     55: #      registering a conflict between pyNN-<modulename> packages.
                     56: #
                     57: #      Possible values: yes no
                     58: #      Default: no
                     59: #
1.52      rillig     60: # === Defined variables ===
                     61: #
                     62: # PYPKGPREFIX
                     63: #      The prefix to use in PKGNAME for extensions which are meant
                     64: #      to be installed for multiple Python versions.
                     65: #
1.96      wiz        66: #      Example: py27
1.52      rillig     67: #
                     68: # PYVERSSUFFIX
                     69: #      The suffix to executables and in the library path, equal to
                     70: #      sys.version[0:3].
                     71: #
1.96      wiz        72: #      Example: 2.7
1.52      rillig     73: #
1.46      rillig     74: # Keywords: python
                     75: #
1.2       drochner   76: 
                     77: .if !defined(PYTHON_PYVERSION_MK)
                     78: PYTHON_PYVERSION_MK=   defined
1.1       drochner   79: 
1.66      joerg      80: # derive a python version from the package name if possible
                     81: # optionally handled quoted package names
                     82: .if defined(PKGNAME_REQD) && !empty(PKGNAME_REQD:Mpy[0-9][0-9]-*) || \
                     83:     defined(PKGNAME_REQD) && !empty(PKGNAME_REQD:M*-py[0-9][0-9]-*)
                     84: PYTHON_VERSION_REQD?= ${PKGNAME_REQD:C/(^.*-|^)py([0-9][0-9])-.*/\2/}
                     85: .elif defined(PKGNAME_OLD) && !empty(PKGNAME_OLD:Mpy[0-9][0-9]-*) || \
                     86:       defined(PKGNAME_OLD) && !empty(PKGNAME_OLD:M*-py[0-9][0-9]-*)
                     87: PYTHON_VERSION_REQD?= ${PKGNAME_OLD:C/(^.*-|^)py([0-9][0-9])-.*/\2/}
                     88: .endif
                     89: 
1.1       drochner   90: .include "../../mk/bsd.prefs.mk"
                     91: 
1.46      rillig     92: BUILD_DEFS+=           PYTHON_VERSION_DEFAULT
                     93: BUILD_DEFS_EFFECTS+=   PYPACKAGE
                     94: 
1.96      wiz        95: PYTHON_VERSION_DEFAULT?=               27
1.112   ! wiz        96: .if ${PYTHON_VERSIONS_INCLUDE_3X:U:tl} == "yes"
1.110     wiz        97: PYTHON_VERSIONS_ACCEPTED?=             33 27 26
1.112   ! wiz        98: .else
        !            99: PYTHON_VERSIONS_ACCEPTED?=             27 26
        !           100: .endif
1.56      joerg     101: PYTHON_VERSIONS_INCOMPATIBLE?=         # empty by default
                    102: 
1.70      snj       103: BUILDLINK_API_DEPENDS.python26?=               python26>=2.6
1.84      obache    104: BUILDLINK_API_DEPENDS.python27?=               python27>=2.7
1.105     tsarna    105: BUILDLINK_API_DEPENDS.python33?=               python33>=3.3
1.4       drochner  106: 
1.1       drochner  107: # transform the list into individual variables
                    108: .for pv in ${PYTHON_VERSIONS_ACCEPTED}
1.28      tv        109: .if empty(PYTHON_VERSIONS_INCOMPATIBLE:M${pv})
1.1       drochner  110: _PYTHON_VERSION_${pv}_OK=      yes
1.56      joerg     111: _PYTHON_VERSIONS_ACCEPTED+=    ${pv}
1.28      tv        112: .endif
1.1       drochner  113: .endfor
                    114: 
                    115: #
                    116: # choose a python version where to add,
                    117: # try to be intelligent
                    118: #
1.2       drochner  119: # if a version is explicitely required, take it
                    120: .if defined(PYTHON_VERSION_REQD)
1.40      joerg     121: # but check if it is acceptable first, error out otherwise
                    122: . if defined(_PYTHON_VERSION_${PYTHON_VERSION_REQD}_OK)
1.2       drochner  123: _PYTHON_VERSION=       ${PYTHON_VERSION_REQD}
1.40      joerg     124: . endif
                    125: .else
                    126: # if the default is accepted, it is first choice
                    127: . if !defined(_PYTHON_VERSION)
                    128: . if defined(_PYTHON_VERSION_${PYTHON_VERSION_DEFAULT}_OK)
1.1       drochner  129: _PYTHON_VERSION=       ${PYTHON_VERSION_DEFAULT}
1.40      joerg     130: . endif
                    131: . endif
1.1       drochner  132: # prefer an already installed version, in order of "accepted"
1.40      joerg     133: . if !defined(_PYTHON_VERSION)
                    134: . for pv in ${PYTHON_VERSIONS_ACCEPTED}
                    135: . if defined(_PYTHON_VERSION_${pv}_OK)
1.1       drochner  136: _PYTHON_VERSION?=      ${pv}
1.40      joerg     137: . endif
                    138: . endfor
                    139: . endif
1.1       drochner  140: .endif
1.40      joerg     141: 
1.87      wiz       142: #
                    143: # Variable assignment for multi-python packages
                    144: MULTI+=        PYTHON_VERSION_REQD=${_PYTHON_VERSION}
                    145: 
1.40      joerg     146: # No supported version found, annotate to simplify statements below.
1.1       drochner  147: .if !defined(_PYTHON_VERSION)
1.40      joerg     148: _PYTHON_VERSION=       none
1.1       drochner  149: .endif
                    150: 
1.103     cheusov   151: # Additional CONFLICTS
                    152: .if ${PYTHON_SELF_CONFLICT:U:tl} == "yes"
                    153: .for i in ${PYTHON_VERSIONS_ACCEPTED:N${_PYTHON_VERSION}}
                    154: CONFLICTS +=   ${PKGNAME:S/py${_PYTHON_VERSION}/py${i}/:C/-[0-9].*$/-[0-9]*/}
                    155: .endfor
                    156: .endif # PYCONFLICTS
                    157: 
                    158: #
1.100     drochner  159: PLIST_VARS+=   py2x py3x
                    160: 
1.105     tsarna    161: .if ${_PYTHON_VERSION} == "33"
                    162: PYPKGSRCDIR=   ../../lang/python33
                    163: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python33}:${PYPKGSRCDIR}
                    164: PYPACKAGE=     python33
                    165: PYVERSSUFFIX=  3.3
                    166: PYPKGPREFIX=   py33
                    167: PLIST.py3x=    yes
1.89      reed      168: .elif ${_PYTHON_VERSION} == "27"
1.83      obache    169: PYPKGSRCDIR=   ../../lang/python27
                    170: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python27}:${PYPKGSRCDIR}
                    171: PYPACKAGE=     python27
                    172: PYVERSSUFFIX=  2.7
                    173: PYPKGPREFIX=   py27
1.100     drochner  174: PLIST.py2x=    yes
1.83      obache    175: .elif ${_PYTHON_VERSION} == "26"
1.68      wiz       176: PYPKGSRCDIR=   ../../lang/python26
                    177: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python26}:${PYPKGSRCDIR}
                    178: PYPACKAGE=     python26
                    179: PYVERSSUFFIX=  2.6
                    180: PYPKGPREFIX=   py26
1.100     drochner  181: PLIST.py2x=    yes
1.8       drochner  182: .else
1.48      rillig    183: PKG_FAIL_REASON+=   "No valid Python version"
1.93      joerg     184: PYPKGPREFIX=
1.1       drochner  185: .endif
1.5       drochner  186: 
1.38      rillig    187: PTHREAD_OPTS+= require
1.33      jlam      188: .include "../../mk/pthread.buildlink3.mk"
1.38      rillig    189: 
1.109     riastrad  190: PYTHON_FOR_BUILD_ONLY?=                no
1.37      kristerw  191: .if defined(PYPKGSRCDIR)
1.108     riastrad  192: .  if !empty(PYTHON_FOR_BUILD_ONLY:M[tT][oO][oO][lL])
                    193: TOOL_DEPENDS+=                 ${PYDEPENDENCY}
1.107     riastrad  194: .  else
1.108     riastrad  195: .    if !empty(PYTHON_FOR_BUILD_ONLY:M[yY][eE][sS])
                    196: BUILDLINK_DEPMETHOD.python?=   build
                    197: .    endif
1.107     riastrad  198: .    include "${PYPKGSRCDIR}/buildlink3.mk"
                    199: .  endif
1.37      kristerw  200: .endif
1.11      jlam      201: 
                    202: PYTHONBIN=     ${LOCALBASE}/bin/python${PYVERSSUFFIX}
1.78      joerg     203: PYTHONCONFIG=  ${LOCALBASE}/bin/python${PYVERSSUFFIX}-config
1.73      joerg     204: PY_COMPILE_ALL= \
                    205:        ${PYTHONBIN} ${PREFIX}/lib/python${PYVERSSUFFIX}/compileall.py -q
                    206: PY_COMPILE_O_ALL= \
                    207:        ${PYTHONBIN} -O ${PREFIX}/lib/python${PYVERSSUFFIX}/compileall.py -q
1.11      jlam      208: 
1.61      snj       209: .if exists(${PYTHONBIN})
1.11      jlam      210: PYINC!=        ${PYTHONBIN} -c "import distutils.sysconfig; \
1.85      obache    211:        print (distutils.sysconfig.get_python_inc(0, \"\"))" || ${ECHO} ""
1.11      jlam      212: PYLIB!=        ${PYTHONBIN} -c "import distutils.sysconfig; \
1.85      obache    213:        print (distutils.sysconfig.get_python_lib(0, 1, \"\"))" || ${ECHO} ""
1.11      jlam      214: PYSITELIB!=    ${PYTHONBIN} -c "import distutils.sysconfig; \
1.85      obache    215:        print (distutils.sysconfig.get_python_lib(0, 0, \"\"))" || ${ECHO} ""
1.72      joerg     216: 
                    217: PRINT_PLIST_AWK+=      /^${PYINC:S|/|\\/|g}/ \
1.82      obache    218:                        { gsub(/${PYINC:S|/|\\/|g}/, "$${PYINC}") }
1.72      joerg     219: PRINT_PLIST_AWK+=      /^${PYSITELIB:S|/|\\/|g}/ \
1.82      obache    220:                        { gsub(/${PYSITELIB:S|/|\\/|g}/, "$${PYSITELIB}") }
1.72      joerg     221: PRINT_PLIST_AWK+=      /^${PYLIB:S|/|\\/|g}/ \
1.82      obache    222:                        { gsub(/${PYLIB:S|/|\\/|g}/, "$${PYLIB}") }
1.6       drochner  223: .endif
1.2       drochner  224: 
1.47      rillig    225: ALL_ENV+=      PYTHON=${PYTHONBIN}
1.80      drochner  226: .if defined(USE_CMAKE)
                    227: # used by FindPythonInterp.cmake and FindPythonLibs.cmake
                    228: CMAKE_ARGS+=   -DPYVERSSUFFIX:STRING=${PYVERSSUFFIX}
                    229: .endif
1.47      rillig    230: 
1.2       drochner  231: .endif # PYTHON_PYVERSION_MK

CVSweb <webmaster@jp.NetBSD.org>