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

1.63    ! joerg       1: # $NetBSD: pyversion.mk,v 1.62 2009/01/23 18:02:32 joerg 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.60      snj        11: #      Possible values: 21 23 24 25
1.44      rillig     12: #      Default: 24
                     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.60      snj        21: #      Possible values: 25 24 23 21
1.59      tnn        22: #      Default: 25 24 23
1.44      rillig     23: #
                     24: # PYTHON_VERSIONS_INCOMPATIBLE
                     25: #      The Python versions that are NOT acceptable for the package.
                     26: #
1.60      snj        27: #      Possible values: 21 23 24 25
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: #
                     42: #      Example: py24
                     43: #
                     44: # PYVERSSUFFIX
                     45: #      The suffix to executables and in the library path, equal to
                     46: #      sys.version[0:3].
                     47: #
                     48: #      Example: 2.4
                     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: 
                     56: .include "../../mk/bsd.prefs.mk"
                     57: 
1.46      rillig     58: BUILD_DEFS+=           PYTHON_VERSION_DEFAULT
                     59: BUILD_DEFS_EFFECTS+=   PYPACKAGE
                     60: 
1.43      drochner   61: PYTHON_VERSION_DEFAULT?=               24
1.59      tnn        62: PYTHON_VERSIONS_ACCEPTED?=             25 24 23
1.56      joerg      63: PYTHON_VERSIONS_INCOMPATIBLE?=         # empty by default
                     64: 
1.39      reed       65: BUILDLINK_API_DEPENDS.python23?=               python23>=2.3
                     66: BUILDLINK_API_DEPENDS.python24?=               python24>=2.4
1.50      xtraeme    67: BUILDLINK_API_DEPENDS.python25?=               python25>=2.5.1
1.4       drochner   68: 
1.1       drochner   69: # transform the list into individual variables
                     70: .for pv in ${PYTHON_VERSIONS_ACCEPTED}
1.28      tv         71: .if empty(PYTHON_VERSIONS_INCOMPATIBLE:M${pv})
1.1       drochner   72: _PYTHON_VERSION_${pv}_OK=      yes
1.56      joerg      73: _PYTHON_VERSIONS_ACCEPTED+=    ${pv}
1.28      tv         74: .endif
1.1       drochner   75: .endfor
                     76: 
                     77: #
                     78: # choose a python version where to add,
                     79: # try to be intelligent
                     80: #
1.2       drochner   81: # if a version is explicitely required, take it
                     82: .if defined(PYTHON_VERSION_REQD)
1.40      joerg      83: # but check if it is acceptable first, error out otherwise
                     84: . if defined(_PYTHON_VERSION_${PYTHON_VERSION_REQD}_OK)
1.2       drochner   85: _PYTHON_VERSION=       ${PYTHON_VERSION_REQD}
1.40      joerg      86: . endif
                     87: .else
                     88: # if the default is accepted, it is first choice
                     89: . if !defined(_PYTHON_VERSION)
                     90: . if defined(_PYTHON_VERSION_${PYTHON_VERSION_DEFAULT}_OK)
1.1       drochner   91: _PYTHON_VERSION=       ${PYTHON_VERSION_DEFAULT}
1.40      joerg      92: . endif
                     93: . endif
1.1       drochner   94: # prefer an already installed version, in order of "accepted"
1.40      joerg      95: . if !defined(_PYTHON_VERSION)
                     96: . for pv in ${PYTHON_VERSIONS_ACCEPTED}
                     97: . if defined(_PYTHON_VERSION_${pv}_OK)
1.1       drochner   98: _PYTHON_VERSION?=      ${pv}
1.40      joerg      99: . endif
                    100: . endfor
                    101: . endif
1.1       drochner  102: .endif
1.40      joerg     103: 
                    104: # No supported version found, annotate to simplify statements below.
1.1       drochner  105: .if !defined(_PYTHON_VERSION)
1.40      joerg     106: _PYTHON_VERSION=       none
1.1       drochner  107: .endif
                    108: 
1.57      tnn       109: .if ${_PYTHON_VERSION} == "25"
                    110: PYPKGSRCDIR=   ../../lang/python25
1.50      xtraeme   111: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python25}:${PYPKGSRCDIR}
                    112: PYPACKAGE=     python25
                    113: PYVERSSUFFIX=  2.5
                    114: PYPKGPREFIX=   py25
                    115: .elif ${_PYTHON_VERSION} == "24"
1.30      recht     116: PYPKGSRCDIR=   ../../lang/python24
1.39      reed      117: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python24}:${PYPKGSRCDIR}
1.30      recht     118: PYPACKAGE=     python24
                    119: PYVERSSUFFIX=  2.4
                    120: PYPKGPREFIX=   py24
                    121: .elif ${_PYTHON_VERSION} == "23"
1.21      drochner  122: PYPKGSRCDIR=   ../../lang/python23
1.39      reed      123: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python23}:${PYPKGSRCDIR}
1.21      drochner  124: PYPACKAGE=     python23
                    125: PYVERSSUFFIX=  2.3
                    126: PYPKGPREFIX=   py23
1.8       drochner  127: .else
1.48      rillig    128: PKG_FAIL_REASON+=   "No valid Python version"
1.1       drochner  129: .endif
1.5       drochner  130: 
1.38      rillig    131: PTHREAD_OPTS+= require
1.33      jlam      132: .include "../../mk/pthread.buildlink3.mk"
1.38      rillig    133: 
1.33      jlam      134: .if defined(PYTHON_FOR_BUILD_ONLY)
1.36      seb       135: BUILDLINK_DEPMETHOD.python?=   build
1.11      jlam      136: .endif
1.37      kristerw  137: .if defined(PYPKGSRCDIR)
1.33      jlam      138: .include "${PYPKGSRCDIR}/buildlink3.mk"
1.37      kristerw  139: .endif
1.11      jlam      140: 
                    141: PYTHONBIN=     ${LOCALBASE}/bin/python${PYVERSSUFFIX}
                    142: 
1.61      snj       143: .if exists(${PYTHONBIN})
1.11      jlam      144: PYINC!=        ${PYTHONBIN} -c "import distutils.sysconfig; \
                    145:        print distutils.sysconfig.get_python_inc(0, \"\")" || ${ECHO} ""
                    146: PYLIB!=        ${PYTHONBIN} -c "import distutils.sysconfig; \
                    147:        print distutils.sysconfig.get_python_lib(0, 1, \"\")" || ${ECHO} ""
                    148: PYSITELIB!=    ${PYTHONBIN} -c "import distutils.sysconfig; \
                    149:        print distutils.sysconfig.get_python_lib(0, 0, \"\")" || ${ECHO} ""
1.29      recht     150: 
                    151: PRINT_PLIST_AWK+=      /^@dirrm ${PYINC:S|/|\\/|g}$$/ { next; }
                    152: PRINT_PLIST_AWK+=      /^@dirrm ${PYSITELIB:S|/|\\/|g}$$/ { next; }
                    153: PRINT_PLIST_AWK+=      /^@dirrm ${PYLIB:S|/|\\/|g}$$/ { next; }
                    154: 
                    155: PRINT_PLIST_AWK+=      /^(@dirrm )?${PYINC:S|/|\\/|g}/ \
                    156:                        { gsub(/${PYINC:S|/|\\/|g}/, "$${PYINC}"); \
                    157:                                print; next; }
                    158: PRINT_PLIST_AWK+=      /^(@dirrm )?${PYSITELIB:S|/|\\/|g}/ \
                    159:                        { gsub(/${PYSITELIB:S|/|\\/|g}/, "$${PYSITELIB}"); \
                    160:                                print; next; }
                    161: PRINT_PLIST_AWK+=      /^(@dirrm )?${PYLIB:S|/|\\/|g}/ \
                    162:                        { gsub(/${PYLIB:S|/|\\/|g}/, "$${PYLIB}"); \
                    163:                                print; next; }
1.6       drochner  164: .endif
1.2       drochner  165: 
1.47      rillig    166: ALL_ENV+=      PYTHON=${PYTHONBIN}
                    167: 
1.2       drochner  168: .endif # PYTHON_PYVERSION_MK

CVSweb <webmaster@jp.NetBSD.org>