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

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

CVSweb <webmaster@jp.NetBSD.org>