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

1.62    ! joerg       1: # $NetBSD: pyversion.mk,v 1.61 2008/11/29 19:30:33 snj 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.17      schmonz    65: .if ${OPSYS} == "Darwin"
1.60      snj        66: PYTHON_VERSIONS_INCOMPATIBLE+=         21
1.28      tv         67: .endif
1.56      joerg      68: 
1.39      reed       69: BUILDLINK_API_DEPENDS.python21?=               python21>=2.1
                     70: BUILDLINK_API_DEPENDS.python23?=               python23>=2.3
                     71: BUILDLINK_API_DEPENDS.python24?=               python24>=2.4
1.50      xtraeme    72: BUILDLINK_API_DEPENDS.python25?=               python25>=2.5.1
1.4       drochner   73: 
1.1       drochner   74: # transform the list into individual variables
                     75: .for pv in ${PYTHON_VERSIONS_ACCEPTED}
1.28      tv         76: .if empty(PYTHON_VERSIONS_INCOMPATIBLE:M${pv})
1.1       drochner   77: _PYTHON_VERSION_${pv}_OK=      yes
1.56      joerg      78: _PYTHON_VERSIONS_ACCEPTED+=    ${pv}
1.28      tv         79: .endif
1.1       drochner   80: .endfor
                     81: 
                     82: #
                     83: # choose a python version where to add,
                     84: # try to be intelligent
                     85: #
1.2       drochner   86: # if a version is explicitely required, take it
                     87: .if defined(PYTHON_VERSION_REQD)
1.40      joerg      88: # but check if it is acceptable first, error out otherwise
                     89: . if defined(_PYTHON_VERSION_${PYTHON_VERSION_REQD}_OK)
1.2       drochner   90: _PYTHON_VERSION=       ${PYTHON_VERSION_REQD}
1.40      joerg      91: . endif
                     92: .else
                     93: # if the default is accepted, it is first choice
                     94: . if !defined(_PYTHON_VERSION)
                     95: . if defined(_PYTHON_VERSION_${PYTHON_VERSION_DEFAULT}_OK)
1.1       drochner   96: _PYTHON_VERSION=       ${PYTHON_VERSION_DEFAULT}
1.40      joerg      97: . endif
                     98: . endif
1.1       drochner   99: # prefer an already installed version, in order of "accepted"
1.40      joerg     100: . if !defined(_PYTHON_VERSION)
                    101: . for pv in ${PYTHON_VERSIONS_ACCEPTED}
                    102: . if defined(_PYTHON_VERSION_${pv}_OK)
1.1       drochner  103: _PYTHON_VERSION?=      ${pv}
1.40      joerg     104: . endif
                    105: . endfor
                    106: . endif
1.1       drochner  107: .endif
1.40      joerg     108: 
                    109: # No supported version found, annotate to simplify statements below.
1.1       drochner  110: .if !defined(_PYTHON_VERSION)
1.40      joerg     111: _PYTHON_VERSION=       none
1.1       drochner  112: .endif
                    113: 
1.57      tnn       114: .if ${_PYTHON_VERSION} == "25"
                    115: PYPKGSRCDIR=   ../../lang/python25
1.50      xtraeme   116: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python25}:${PYPKGSRCDIR}
                    117: PYPACKAGE=     python25
                    118: PYVERSSUFFIX=  2.5
                    119: PYPKGPREFIX=   py25
                    120: .elif ${_PYTHON_VERSION} == "24"
1.30      recht     121: PYPKGSRCDIR=   ../../lang/python24
1.39      reed      122: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python24}:${PYPKGSRCDIR}
1.30      recht     123: PYPACKAGE=     python24
                    124: PYVERSSUFFIX=  2.4
                    125: PYPKGPREFIX=   py24
                    126: .elif ${_PYTHON_VERSION} == "23"
1.21      drochner  127: PYPKGSRCDIR=   ../../lang/python23
1.39      reed      128: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python23}:${PYPKGSRCDIR}
1.21      drochner  129: PYPACKAGE=     python23
                    130: PYVERSSUFFIX=  2.3
                    131: PYPKGPREFIX=   py23
1.2       drochner  132: .elif ${_PYTHON_VERSION} == "21"
1.10      jlam      133: PYPKGSRCDIR=   ../../lang/python21
1.14      jlam      134: PYPACKAGE=     python21
1.39      reed      135: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python21}:${PYPKGSRCDIR}
1.5       drochner  136: PYVERSSUFFIX=  2.1
1.1       drochner  137: PYPKGPREFIX=   py21
1.8       drochner  138: .else
1.48      rillig    139: PKG_FAIL_REASON+=   "No valid Python version"
1.1       drochner  140: .endif
1.5       drochner  141: 
1.38      rillig    142: PTHREAD_OPTS+= require
1.33      jlam      143: .include "../../mk/pthread.buildlink3.mk"
1.38      rillig    144: 
1.33      jlam      145: .if defined(PYTHON_FOR_BUILD_ONLY)
1.36      seb       146: BUILDLINK_DEPMETHOD.python?=   build
1.11      jlam      147: .endif
1.37      kristerw  148: .if defined(PYPKGSRCDIR)
1.33      jlam      149: .include "${PYPKGSRCDIR}/buildlink3.mk"
1.37      kristerw  150: .endif
1.11      jlam      151: 
                    152: PYTHONBIN=     ${LOCALBASE}/bin/python${PYVERSSUFFIX}
                    153: 
1.61      snj       154: .if exists(${PYTHONBIN})
1.11      jlam      155: PYINC!=        ${PYTHONBIN} -c "import distutils.sysconfig; \
                    156:        print distutils.sysconfig.get_python_inc(0, \"\")" || ${ECHO} ""
                    157: PYLIB!=        ${PYTHONBIN} -c "import distutils.sysconfig; \
                    158:        print distutils.sysconfig.get_python_lib(0, 1, \"\")" || ${ECHO} ""
                    159: PYSITELIB!=    ${PYTHONBIN} -c "import distutils.sysconfig; \
                    160:        print distutils.sysconfig.get_python_lib(0, 0, \"\")" || ${ECHO} ""
1.29      recht     161: 
                    162: PRINT_PLIST_AWK+=      /^@dirrm ${PYINC:S|/|\\/|g}$$/ { next; }
                    163: PRINT_PLIST_AWK+=      /^@dirrm ${PYSITELIB:S|/|\\/|g}$$/ { next; }
                    164: PRINT_PLIST_AWK+=      /^@dirrm ${PYLIB:S|/|\\/|g}$$/ { next; }
                    165: 
                    166: PRINT_PLIST_AWK+=      /^(@dirrm )?${PYINC:S|/|\\/|g}/ \
                    167:                        { gsub(/${PYINC:S|/|\\/|g}/, "$${PYINC}"); \
                    168:                                print; next; }
                    169: PRINT_PLIST_AWK+=      /^(@dirrm )?${PYSITELIB:S|/|\\/|g}/ \
                    170:                        { gsub(/${PYSITELIB:S|/|\\/|g}/, "$${PYSITELIB}"); \
                    171:                                print; next; }
                    172: PRINT_PLIST_AWK+=      /^(@dirrm )?${PYLIB:S|/|\\/|g}/ \
                    173:                        { gsub(/${PYLIB:S|/|\\/|g}/, "$${PYLIB}"); \
                    174:                                print; next; }
1.6       drochner  175: .endif
1.2       drochner  176: 
1.47      rillig    177: ALL_ENV+=      PYTHON=${PYTHONBIN}
                    178: 
1.2       drochner  179: .endif # PYTHON_PYVERSION_MK

CVSweb <webmaster@jp.NetBSD.org>