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

1.107     riastrad    1: # $NetBSD: pyversion.mk,v 1.106 2013/04/29 10:49:37 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.106     wiz        11: #      Possible values: 26 27 32 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.106     wiz        30: #      Possible values: 33 32 27 26
                     31: #      Default: (33 32) 27 26
1.92      joerg      32: #
                     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
1.44      rillig     40: #
                     41: # PYTHON_VERSIONS_INCOMPATIBLE
                     42: #      The Python versions that are NOT acceptable for the package.
                     43: #
1.106     wiz        44: #      Possible values: 26 27 32 33
1.44      rillig     45: #      Default: (depends on the platform)
                     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.92      joerg      96: .if ${PYTHON_VERSIONS_INCLUDE_3X:U:tl} == "yes"
1.106     wiz        97: PYTHON_VERSIONS_ACCEPTED?=             33 32 27 26
1.92      joerg      98: .else
1.102     wiz        99: PYTHON_VERSIONS_ACCEPTED?=             27 26
1.92      joerg     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.99      obache    105: BUILDLINK_API_DEPENDS.python32?=               python32>=3.2
1.105     tsarna    106: BUILDLINK_API_DEPENDS.python33?=               python33>=3.3
1.4       drochner  107: 
1.1       drochner  108: # transform the list into individual variables
                    109: .for pv in ${PYTHON_VERSIONS_ACCEPTED}
1.28      tv        110: .if empty(PYTHON_VERSIONS_INCOMPATIBLE:M${pv})
1.1       drochner  111: _PYTHON_VERSION_${pv}_OK=      yes
1.56      joerg     112: _PYTHON_VERSIONS_ACCEPTED+=    ${pv}
1.28      tv        113: .endif
1.1       drochner  114: .endfor
                    115: 
                    116: #
                    117: # choose a python version where to add,
                    118: # try to be intelligent
                    119: #
1.2       drochner  120: # if a version is explicitely required, take it
                    121: .if defined(PYTHON_VERSION_REQD)
1.40      joerg     122: # but check if it is acceptable first, error out otherwise
                    123: . if defined(_PYTHON_VERSION_${PYTHON_VERSION_REQD}_OK)
1.2       drochner  124: _PYTHON_VERSION=       ${PYTHON_VERSION_REQD}
1.40      joerg     125: . endif
                    126: .else
                    127: # if the default is accepted, it is first choice
                    128: . if !defined(_PYTHON_VERSION)
                    129: . if defined(_PYTHON_VERSION_${PYTHON_VERSION_DEFAULT}_OK)
1.1       drochner  130: _PYTHON_VERSION=       ${PYTHON_VERSION_DEFAULT}
1.40      joerg     131: . endif
                    132: . endif
1.1       drochner  133: # prefer an already installed version, in order of "accepted"
1.40      joerg     134: . if !defined(_PYTHON_VERSION)
                    135: . for pv in ${PYTHON_VERSIONS_ACCEPTED}
                    136: . if defined(_PYTHON_VERSION_${pv}_OK)
1.1       drochner  137: _PYTHON_VERSION?=      ${pv}
1.40      joerg     138: . endif
                    139: . endfor
                    140: . endif
1.1       drochner  141: .endif
1.40      joerg     142: 
1.87      wiz       143: #
                    144: # Variable assignment for multi-python packages
                    145: MULTI+=        PYTHON_VERSION_REQD=${_PYTHON_VERSION}
                    146: 
1.40      joerg     147: # No supported version found, annotate to simplify statements below.
1.1       drochner  148: .if !defined(_PYTHON_VERSION)
1.40      joerg     149: _PYTHON_VERSION=       none
1.1       drochner  150: .endif
                    151: 
1.103     cheusov   152: # Additional CONFLICTS
                    153: .if ${PYTHON_SELF_CONFLICT:U:tl} == "yes"
                    154: .for i in ${PYTHON_VERSIONS_ACCEPTED:N${_PYTHON_VERSION}}
                    155: CONFLICTS +=   ${PKGNAME:S/py${_PYTHON_VERSION}/py${i}/:C/-[0-9].*$/-[0-9]*/}
                    156: .endfor
                    157: .endif # PYCONFLICTS
                    158: 
                    159: #
1.100     drochner  160: PLIST_VARS+=   py2x py3x
                    161: 
1.105     tsarna    162: .if ${_PYTHON_VERSION} == "33"
                    163: PYPKGSRCDIR=   ../../lang/python33
                    164: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python33}:${PYPKGSRCDIR}
                    165: PYPACKAGE=     python33
                    166: PYVERSSUFFIX=  3.3
                    167: PYPKGPREFIX=   py33
                    168: PLIST.py3x=    yes
                    169: .elif ${_PYTHON_VERSION} == "32"
1.99      obache    170: PYPKGSRCDIR=   ../../lang/python32
                    171: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python32}:${PYPKGSRCDIR}
                    172: PYPACKAGE=     python32
                    173: PYVERSSUFFIX=  3.2
                    174: PYPKGPREFIX=   py32
1.100     drochner  175: PLIST.py3x=    yes
1.89      reed      176: .elif ${_PYTHON_VERSION} == "27"
1.83      obache    177: PYPKGSRCDIR=   ../../lang/python27
                    178: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python27}:${PYPKGSRCDIR}
                    179: PYPACKAGE=     python27
                    180: PYVERSSUFFIX=  2.7
                    181: PYPKGPREFIX=   py27
1.100     drochner  182: PLIST.py2x=    yes
1.83      obache    183: .elif ${_PYTHON_VERSION} == "26"
1.68      wiz       184: PYPKGSRCDIR=   ../../lang/python26
                    185: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python26}:${PYPKGSRCDIR}
                    186: PYPACKAGE=     python26
                    187: PYVERSSUFFIX=  2.6
                    188: PYPKGPREFIX=   py26
1.100     drochner  189: PLIST.py2x=    yes
1.8       drochner  190: .else
1.48      rillig    191: PKG_FAIL_REASON+=   "No valid Python version"
1.93      joerg     192: PYPKGPREFIX=
1.1       drochner  193: .endif
1.5       drochner  194: 
1.38      rillig    195: PTHREAD_OPTS+= require
1.33      jlam      196: .include "../../mk/pthread.buildlink3.mk"
1.38      rillig    197: 
1.37      kristerw  198: .if defined(PYPKGSRCDIR)
1.108   ! riastrad  199: .  if !empty(PYTHON_FOR_BUILD_ONLY:M[tT][oO][oO][lL])
        !           200: TOOL_DEPENDS+=                 ${PYDEPENDENCY}
1.107     riastrad  201: .  else
1.108   ! riastrad  202: .    if !empty(PYTHON_FOR_BUILD_ONLY:M[yY][eE][sS])
        !           203: BUILDLINK_DEPMETHOD.python?=   build
        !           204: .    endif
1.107     riastrad  205: .    include "${PYPKGSRCDIR}/buildlink3.mk"
                    206: .  endif
1.37      kristerw  207: .endif
1.11      jlam      208: 
                    209: PYTHONBIN=     ${LOCALBASE}/bin/python${PYVERSSUFFIX}
1.78      joerg     210: PYTHONCONFIG=  ${LOCALBASE}/bin/python${PYVERSSUFFIX}-config
1.73      joerg     211: PY_COMPILE_ALL= \
                    212:        ${PYTHONBIN} ${PREFIX}/lib/python${PYVERSSUFFIX}/compileall.py -q
                    213: PY_COMPILE_O_ALL= \
                    214:        ${PYTHONBIN} -O ${PREFIX}/lib/python${PYVERSSUFFIX}/compileall.py -q
1.11      jlam      215: 
1.61      snj       216: .if exists(${PYTHONBIN})
1.11      jlam      217: PYINC!=        ${PYTHONBIN} -c "import distutils.sysconfig; \
1.85      obache    218:        print (distutils.sysconfig.get_python_inc(0, \"\"))" || ${ECHO} ""
1.11      jlam      219: PYLIB!=        ${PYTHONBIN} -c "import distutils.sysconfig; \
1.85      obache    220:        print (distutils.sysconfig.get_python_lib(0, 1, \"\"))" || ${ECHO} ""
1.11      jlam      221: PYSITELIB!=    ${PYTHONBIN} -c "import distutils.sysconfig; \
1.85      obache    222:        print (distutils.sysconfig.get_python_lib(0, 0, \"\"))" || ${ECHO} ""
1.72      joerg     223: 
                    224: PRINT_PLIST_AWK+=      /^${PYINC:S|/|\\/|g}/ \
1.82      obache    225:                        { gsub(/${PYINC:S|/|\\/|g}/, "$${PYINC}") }
1.72      joerg     226: PRINT_PLIST_AWK+=      /^${PYSITELIB:S|/|\\/|g}/ \
1.82      obache    227:                        { gsub(/${PYSITELIB:S|/|\\/|g}/, "$${PYSITELIB}") }
1.72      joerg     228: PRINT_PLIST_AWK+=      /^${PYLIB:S|/|\\/|g}/ \
1.82      obache    229:                        { gsub(/${PYLIB:S|/|\\/|g}/, "$${PYLIB}") }
1.6       drochner  230: .endif
1.2       drochner  231: 
1.47      rillig    232: ALL_ENV+=      PYTHON=${PYTHONBIN}
1.80      drochner  233: .if defined(USE_CMAKE)
                    234: # used by FindPythonInterp.cmake and FindPythonLibs.cmake
                    235: CMAKE_ARGS+=   -DPYVERSSUFFIX:STRING=${PYVERSSUFFIX}
                    236: .endif
1.47      rillig    237: 
1.2       drochner  238: .endif # PYTHON_PYVERSION_MK

CVSweb <webmaster@jp.NetBSD.org>