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

1.53    ! joerg       1: # $NetBSD: pyversion.mk,v 1.52 2008/02/20 10:43:55 rillig 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.50      xtraeme    11: #      Possible values: 15 20 21 22 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.50      xtraeme    24: #      Possible values: 25 24 23 22 21 20 15
1.44      rillig     25: #      Default: (all)
                     26: #
                     27: # PYTHON_VERSIONS_INCOMPATIBLE
                     28: #      The Python versions that are NOT acceptable for the package.
                     29: #
1.50      xtraeme    30: #      Possible values: 15 20 21 22 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.17      schmonz    65: .if ${OPSYS} == "Darwin"
1.32      recht      66: PYTHON_VERSIONS_INCOMPATIBLE+=         22 21 20 15
1.28      tv         67: .endif
1.51      joerg      68: PYTHON_VERSIONS_ACCEPTED?=             24 23 22 21 20
1.28      tv         69: PYTHON_VERSIONS_INCOMPATIBLE?=         # empty by default
1.1       drochner   70: 
1.39      reed       71: BUILDLINK_API_DEPENDS.python15?=               python15>=1.5
                     72: BUILDLINK_API_DEPENDS.python20?=               python20>=2.0
                     73: BUILDLINK_API_DEPENDS.python21?=               python21>=2.1
                     74: BUILDLINK_API_DEPENDS.python22?=               python22>=2.2
                     75: BUILDLINK_API_DEPENDS.python23?=               python23>=2.3
                     76: BUILDLINK_API_DEPENDS.python24?=               python24>=2.4
1.50      xtraeme    77: BUILDLINK_API_DEPENDS.python25?=               python25>=2.5.1
1.4       drochner   78: 
1.1       drochner   79: # transform the list into individual variables
                     80: .for pv in ${PYTHON_VERSIONS_ACCEPTED}
1.28      tv         81: .if empty(PYTHON_VERSIONS_INCOMPATIBLE:M${pv})
1.1       drochner   82: _PYTHON_VERSION_${pv}_OK=      yes
1.28      tv         83: .endif
1.1       drochner   84: .endfor
                     85: 
                     86: #
                     87: # choose a python version where to add,
                     88: # try to be intelligent
                     89: #
1.2       drochner   90: # if a version is explicitely required, take it
                     91: .if defined(PYTHON_VERSION_REQD)
1.40      joerg      92: # but check if it is acceptable first, error out otherwise
                     93: . if defined(_PYTHON_VERSION_${PYTHON_VERSION_REQD}_OK)
1.2       drochner   94: _PYTHON_VERSION=       ${PYTHON_VERSION_REQD}
1.40      joerg      95: . endif
                     96: .else
                     97: # if the default is accepted, it is first choice
                     98: . if !defined(_PYTHON_VERSION)
                     99: . if defined(_PYTHON_VERSION_${PYTHON_VERSION_DEFAULT}_OK)
1.1       drochner  100: _PYTHON_VERSION=       ${PYTHON_VERSION_DEFAULT}
1.40      joerg     101: . endif
                    102: . endif
1.1       drochner  103: # prefer an already installed version, in order of "accepted"
1.40      joerg     104: . if !defined(_PYTHON_VERSION)
                    105: . for pv in ${PYTHON_VERSIONS_ACCEPTED}
                    106: . if defined(_PYTHON_VERSION_${pv}_OK)
1.1       drochner  107: _PYTHON_VERSION?=      ${pv}
1.40      joerg     108: . endif
                    109: . endfor
                    110: . endif
1.1       drochner  111: .endif
1.40      joerg     112: 
                    113: # No supported version found, annotate to simplify statements below.
1.1       drochner  114: .if !defined(_PYTHON_VERSION)
1.40      joerg     115: _PYTHON_VERSION=       none
1.1       drochner  116: .endif
                    117: 
1.53    ! joerg     118: .if ${_PYTHON_VERSION} == "25" && exists(../../wip/python25/Makefile)
1.50      xtraeme   119: PYPKGSRCDIR=   ../../wip/python25
                    120: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python25}:${PYPKGSRCDIR}
                    121: PYPACKAGE=     python25
                    122: PYVERSSUFFIX=  2.5
                    123: PYPKGPREFIX=   py25
                    124: .elif ${_PYTHON_VERSION} == "24"
1.30      recht     125: PYPKGSRCDIR=   ../../lang/python24
1.39      reed      126: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python24}:${PYPKGSRCDIR}
1.30      recht     127: PYPACKAGE=     python24
                    128: PYVERSSUFFIX=  2.4
                    129: PYPKGPREFIX=   py24
                    130: .elif ${_PYTHON_VERSION} == "23"
1.21      drochner  131: PYPKGSRCDIR=   ../../lang/python23
1.39      reed      132: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python23}:${PYPKGSRCDIR}
1.21      drochner  133: PYPACKAGE=     python23
                    134: PYVERSSUFFIX=  2.3
                    135: PYPKGPREFIX=   py23
                    136: .elif ${_PYTHON_VERSION} == "22"
1.10      jlam      137: PYPKGSRCDIR=   ../../lang/python22
1.39      reed      138: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python22}:${PYPKGSRCDIR}
1.14      jlam      139: PYPACKAGE=     python22
1.5       drochner  140: PYVERSSUFFIX=  2.2
1.2       drochner  141: PYPKGPREFIX=   py22
                    142: .elif ${_PYTHON_VERSION} == "21"
1.10      jlam      143: PYPKGSRCDIR=   ../../lang/python21
1.14      jlam      144: PYPACKAGE=     python21
1.39      reed      145: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python21}:${PYPKGSRCDIR}
1.5       drochner  146: PYVERSSUFFIX=  2.1
1.1       drochner  147: PYPKGPREFIX=   py21
                    148: .elif ${_PYTHON_VERSION} == "20"
1.10      jlam      149: PYPKGSRCDIR=   ../../lang/python20
1.14      jlam      150: PYPACKAGE=     python20
1.39      reed      151: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python20}:${PYPKGSRCDIR}
1.5       drochner  152: PYVERSSUFFIX=  2.0
1.1       drochner  153: PYPKGPREFIX=   py20
1.7       drochner  154: .elif ${_PYTHON_VERSION} == "15"
1.10      jlam      155: PYPKGSRCDIR=   ../../lang/python15
1.14      jlam      156: PYPACKAGE=     python15
1.39      reed      157: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python15}:${PYPKGSRCDIR}
1.7       drochner  158: PYVERSSUFFIX=  1.5
                    159: PYPKGPREFIX=   py15
                    160: .if !defined(PYTHON_DISTUTILS_BOOTSTRAP)
1.42      joerg     161: BUILD_DEPENDS+=        py15-distutils-[0-9]*:../../devel/py-distutils
1.7       drochner  162: .endif
1.8       drochner  163: .else
1.48      rillig    164: PKG_FAIL_REASON+=   "No valid Python version"
1.1       drochner  165: .endif
1.5       drochner  166: 
1.38      rillig    167: PTHREAD_OPTS+= require
1.33      jlam      168: .include "../../mk/pthread.buildlink3.mk"
1.38      rillig    169: 
1.33      jlam      170: .if defined(PYTHON_FOR_BUILD_ONLY)
1.36      seb       171: BUILDLINK_DEPMETHOD.python?=   build
1.11      jlam      172: .endif
1.37      kristerw  173: .if defined(PYPKGSRCDIR)
1.33      jlam      174: .include "${PYPKGSRCDIR}/buildlink3.mk"
1.37      kristerw  175: .endif
1.11      jlam      176: 
                    177: PYTHONBIN=     ${LOCALBASE}/bin/python${PYVERSSUFFIX}
                    178: 
1.41      joerg     179: .if exists(${PYTHONBIN}) && !defined(PYTHON_DISTUTILS_BOOTSTRAP)
1.11      jlam      180: PYINC!=        ${PYTHONBIN} -c "import distutils.sysconfig; \
                    181:        print distutils.sysconfig.get_python_inc(0, \"\")" || ${ECHO} ""
                    182: PYLIB!=        ${PYTHONBIN} -c "import distutils.sysconfig; \
                    183:        print distutils.sysconfig.get_python_lib(0, 1, \"\")" || ${ECHO} ""
                    184: PYSITELIB!=    ${PYTHONBIN} -c "import distutils.sysconfig; \
                    185:        print distutils.sysconfig.get_python_lib(0, 0, \"\")" || ${ECHO} ""
1.29      recht     186: 
                    187: PRINT_PLIST_AWK+=      /^@dirrm ${PYINC:S|/|\\/|g}$$/ { next; }
                    188: PRINT_PLIST_AWK+=      /^@dirrm ${PYSITELIB:S|/|\\/|g}$$/ { next; }
                    189: PRINT_PLIST_AWK+=      /^@dirrm ${PYLIB:S|/|\\/|g}$$/ { next; }
                    190: 
                    191: PRINT_PLIST_AWK+=      /^(@dirrm )?${PYINC:S|/|\\/|g}/ \
                    192:                        { gsub(/${PYINC:S|/|\\/|g}/, "$${PYINC}"); \
                    193:                                print; next; }
                    194: PRINT_PLIST_AWK+=      /^(@dirrm )?${PYSITELIB:S|/|\\/|g}/ \
                    195:                        { gsub(/${PYSITELIB:S|/|\\/|g}/, "$${PYSITELIB}"); \
                    196:                                print; next; }
                    197: PRINT_PLIST_AWK+=      /^(@dirrm )?${PYLIB:S|/|\\/|g}/ \
                    198:                        { gsub(/${PYLIB:S|/|\\/|g}/, "$${PYLIB}"); \
                    199:                                print; next; }
1.6       drochner  200: .endif
1.2       drochner  201: 
1.47      rillig    202: ALL_ENV+=      PYTHON=${PYTHONBIN}
                    203: 
1.2       drochner  204: .endif # PYTHON_PYVERSION_MK

CVSweb <webmaster@jp.NetBSD.org>