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

1.60    ! snj         1: # $NetBSD: pyversion.mk,v 1.59 2008/04/25 16:27:45 tnn 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.49      rillig     19: #      preferred over later ones. If the package doesn't work with
                     20: #      older Python versions but only with newer ones, please use
                     21: #      PYTHON_VERSIONS_INCOMPATIBLE instead, since it will
                     22: #      automatically include future versions.
1.44      rillig     23: #
1.60    ! snj        24: #      Possible values: 25 24 23 21
1.59      tnn        25: #      Default: 25 24 23
1.44      rillig     26: #
                     27: # PYTHON_VERSIONS_INCOMPATIBLE
                     28: #      The Python versions that are NOT acceptable for the package.
                     29: #
1.60    ! snj        30: #      Possible values: 21 23 24 25
1.44      rillig     31: #      Default: (depends on the platform)
                     32: #
                     33: # PYTHON_FOR_BUILD_ONLY
                     34: #      Whether Python is needed only at build time or at run time.
                     35: #
                     36: #      Possible values: (defined) (undefined)
                     37: #      Default: (undefined)
                     38: #
1.52      rillig     39: # === Defined variables ===
                     40: #
                     41: # PYPKGPREFIX
                     42: #      The prefix to use in PKGNAME for extensions which are meant
                     43: #      to be installed for multiple Python versions.
                     44: #
                     45: #      Example: py24
                     46: #
                     47: # PYVERSSUFFIX
                     48: #      The suffix to executables and in the library path, equal to
                     49: #      sys.version[0:3].
                     50: #
                     51: #      Example: 2.4
                     52: #
1.46      rillig     53: # Keywords: python
                     54: #
1.2       drochner   55: 
                     56: .if !defined(PYTHON_PYVERSION_MK)
                     57: PYTHON_PYVERSION_MK=   defined
1.1       drochner   58: 
                     59: .include "../../mk/bsd.prefs.mk"
                     60: 
1.46      rillig     61: BUILD_DEFS+=           PYTHON_VERSION_DEFAULT
                     62: BUILD_DEFS_EFFECTS+=   PYPACKAGE
                     63: 
1.43      drochner   64: PYTHON_VERSION_DEFAULT?=               24
1.59      tnn        65: PYTHON_VERSIONS_ACCEPTED?=             25 24 23
1.56      joerg      66: PYTHON_VERSIONS_INCOMPATIBLE?=         # empty by default
                     67: 
1.17      schmonz    68: .if ${OPSYS} == "Darwin"
1.60    ! snj        69: PYTHON_VERSIONS_INCOMPATIBLE+=         21
1.28      tv         70: .endif
1.56      joerg      71: 
1.39      reed       72: BUILDLINK_API_DEPENDS.python21?=               python21>=2.1
                     73: BUILDLINK_API_DEPENDS.python23?=               python23>=2.3
                     74: BUILDLINK_API_DEPENDS.python24?=               python24>=2.4
1.50      xtraeme    75: BUILDLINK_API_DEPENDS.python25?=               python25>=2.5.1
1.4       drochner   76: 
1.1       drochner   77: # transform the list into individual variables
                     78: .for pv in ${PYTHON_VERSIONS_ACCEPTED}
1.28      tv         79: .if empty(PYTHON_VERSIONS_INCOMPATIBLE:M${pv})
1.1       drochner   80: _PYTHON_VERSION_${pv}_OK=      yes
1.56      joerg      81: _PYTHON_VERSIONS_ACCEPTED+=    ${pv}
1.28      tv         82: .endif
1.1       drochner   83: .endfor
                     84: 
                     85: #
                     86: # choose a python version where to add,
                     87: # try to be intelligent
                     88: #
1.2       drochner   89: # if a version is explicitely required, take it
                     90: .if defined(PYTHON_VERSION_REQD)
1.40      joerg      91: # but check if it is acceptable first, error out otherwise
                     92: . if defined(_PYTHON_VERSION_${PYTHON_VERSION_REQD}_OK)
1.2       drochner   93: _PYTHON_VERSION=       ${PYTHON_VERSION_REQD}
1.40      joerg      94: . endif
                     95: .else
                     96: # if the default is accepted, it is first choice
                     97: . if !defined(_PYTHON_VERSION)
                     98: . if defined(_PYTHON_VERSION_${PYTHON_VERSION_DEFAULT}_OK)
1.1       drochner   99: _PYTHON_VERSION=       ${PYTHON_VERSION_DEFAULT}
1.40      joerg     100: . endif
                    101: . endif
1.1       drochner  102: # prefer an already installed version, in order of "accepted"
1.40      joerg     103: . if !defined(_PYTHON_VERSION)
                    104: . for pv in ${PYTHON_VERSIONS_ACCEPTED}
                    105: . if defined(_PYTHON_VERSION_${pv}_OK)
1.1       drochner  106: _PYTHON_VERSION?=      ${pv}
1.40      joerg     107: . endif
                    108: . endfor
                    109: . endif
1.1       drochner  110: .endif
1.40      joerg     111: 
                    112: # No supported version found, annotate to simplify statements below.
1.1       drochner  113: .if !defined(_PYTHON_VERSION)
1.40      joerg     114: _PYTHON_VERSION=       none
1.1       drochner  115: .endif
                    116: 
1.57      tnn       117: .if ${_PYTHON_VERSION} == "25"
                    118: PYPKGSRCDIR=   ../../lang/python25
1.50      xtraeme   119: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python25}:${PYPKGSRCDIR}
                    120: PYPACKAGE=     python25
                    121: PYVERSSUFFIX=  2.5
                    122: PYPKGPREFIX=   py25
                    123: .elif ${_PYTHON_VERSION} == "24"
1.30      recht     124: PYPKGSRCDIR=   ../../lang/python24
1.39      reed      125: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python24}:${PYPKGSRCDIR}
1.30      recht     126: PYPACKAGE=     python24
                    127: PYVERSSUFFIX=  2.4
                    128: PYPKGPREFIX=   py24
                    129: .elif ${_PYTHON_VERSION} == "23"
1.21      drochner  130: PYPKGSRCDIR=   ../../lang/python23
1.39      reed      131: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python23}:${PYPKGSRCDIR}
1.21      drochner  132: PYPACKAGE=     python23
                    133: PYVERSSUFFIX=  2.3
                    134: PYPKGPREFIX=   py23
1.2       drochner  135: .elif ${_PYTHON_VERSION} == "21"
1.10      jlam      136: PYPKGSRCDIR=   ../../lang/python21
1.14      jlam      137: PYPACKAGE=     python21
1.39      reed      138: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python21}:${PYPKGSRCDIR}
1.5       drochner  139: PYVERSSUFFIX=  2.1
1.1       drochner  140: PYPKGPREFIX=   py21
1.8       drochner  141: .else
1.48      rillig    142: PKG_FAIL_REASON+=   "No valid Python version"
1.1       drochner  143: .endif
1.5       drochner  144: 
1.38      rillig    145: PTHREAD_OPTS+= require
1.33      jlam      146: .include "../../mk/pthread.buildlink3.mk"
1.38      rillig    147: 
1.33      jlam      148: .if defined(PYTHON_FOR_BUILD_ONLY)
1.36      seb       149: BUILDLINK_DEPMETHOD.python?=   build
1.11      jlam      150: .endif
1.37      kristerw  151: .if defined(PYPKGSRCDIR)
1.33      jlam      152: .include "${PYPKGSRCDIR}/buildlink3.mk"
1.37      kristerw  153: .endif
1.11      jlam      154: 
                    155: PYTHONBIN=     ${LOCALBASE}/bin/python${PYVERSSUFFIX}
                    156: 
1.41      joerg     157: .if exists(${PYTHONBIN}) && !defined(PYTHON_DISTUTILS_BOOTSTRAP)
1.11      jlam      158: PYINC!=        ${PYTHONBIN} -c "import distutils.sysconfig; \
                    159:        print distutils.sysconfig.get_python_inc(0, \"\")" || ${ECHO} ""
                    160: PYLIB!=        ${PYTHONBIN} -c "import distutils.sysconfig; \
                    161:        print distutils.sysconfig.get_python_lib(0, 1, \"\")" || ${ECHO} ""
                    162: PYSITELIB!=    ${PYTHONBIN} -c "import distutils.sysconfig; \
                    163:        print distutils.sysconfig.get_python_lib(0, 0, \"\")" || ${ECHO} ""
1.29      recht     164: 
                    165: PRINT_PLIST_AWK+=      /^@dirrm ${PYINC:S|/|\\/|g}$$/ { next; }
                    166: PRINT_PLIST_AWK+=      /^@dirrm ${PYSITELIB:S|/|\\/|g}$$/ { next; }
                    167: PRINT_PLIST_AWK+=      /^@dirrm ${PYLIB:S|/|\\/|g}$$/ { next; }
                    168: 
                    169: PRINT_PLIST_AWK+=      /^(@dirrm )?${PYINC:S|/|\\/|g}/ \
                    170:                        { gsub(/${PYINC:S|/|\\/|g}/, "$${PYINC}"); \
                    171:                                print; next; }
                    172: PRINT_PLIST_AWK+=      /^(@dirrm )?${PYSITELIB:S|/|\\/|g}/ \
                    173:                        { gsub(/${PYSITELIB:S|/|\\/|g}/, "$${PYSITELIB}"); \
                    174:                                print; next; }
                    175: PRINT_PLIST_AWK+=      /^(@dirrm )?${PYLIB:S|/|\\/|g}/ \
                    176:                        { gsub(/${PYLIB:S|/|\\/|g}/, "$${PYLIB}"); \
                    177:                                print; next; }
1.6       drochner  178: .endif
1.2       drochner  179: 
1.47      rillig    180: ALL_ENV+=      PYTHON=${PYTHONBIN}
                    181: 
1.2       drochner  182: .endif # PYTHON_PYVERSION_MK

CVSweb <webmaster@jp.NetBSD.org>