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

1.46    ! rillig      1: # $NetBSD: pyversion.mk,v 1.45 2006/09/07 22:12:15 rillig Exp $
1.44      rillig      2: 
                      3: # This file determines which Python version is used as a dependency for
                      4: # a package.
                      5: #
                      6: # The following variables may be set by the pkgsrc user in mk.conf:
                      7: #
                      8: # PYTHON_VERSION_DEFAULT
                      9: #      The preferred Python version to use.
                     10: #
                     11: #      Possible values: 15 20 21 22 23 24
                     12: #      Default: 24
                     13: #
                     14: # The following variables may be set by a package before including this
                     15: # file:
                     16: #
                     17: # PYTHON_VERSIONS_ACCEPTED
                     18: #      The Python versions that are acceptable for the package. The
                     19: #      order of the entries matters.
                     20: #
                     21: #      Possible values: 24 23 22 21 20 15
                     22: #      Default: (all)
                     23: #
                     24: # PYTHON_VERSIONS_INCOMPATIBLE
                     25: #      The Python versions that are NOT acceptable for the package.
                     26: #
                     27: #      Possible values: 15 20 21 22 23 24
                     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.46    ! rillig     36: # Keywords: python
        !            37: #
1.2       drochner   38: 
                     39: .if !defined(PYTHON_PYVERSION_MK)
                     40: PYTHON_PYVERSION_MK=   defined
1.1       drochner   41: 
                     42: .include "../../mk/bsd.prefs.mk"
                     43: 
1.46    ! rillig     44: BUILD_DEFS+=           PYTHON_VERSION_DEFAULT
        !            45: BUILD_DEFS_EFFECTS+=   PYPACKAGE
        !            46: 
1.43      drochner   47: PYTHON_VERSION_DEFAULT?=               24
1.17      schmonz    48: .if ${OPSYS} == "Darwin"
1.32      recht      49: PYTHON_VERSIONS_INCOMPATIBLE+=         22 21 20 15
1.28      tv         50: .endif
1.31      recht      51: PYTHON_VERSIONS_ACCEPTED?=             24 23 22 21 20
1.28      tv         52: PYTHON_VERSIONS_INCOMPATIBLE?=         # empty by default
1.1       drochner   53: 
1.39      reed       54: BUILDLINK_API_DEPENDS.python15?=               python15>=1.5
                     55: BUILDLINK_API_DEPENDS.python20?=               python20>=2.0
                     56: BUILDLINK_API_DEPENDS.python21?=               python21>=2.1
                     57: BUILDLINK_API_DEPENDS.python22?=               python22>=2.2
                     58: BUILDLINK_API_DEPENDS.python23?=               python23>=2.3
                     59: BUILDLINK_API_DEPENDS.python24?=               python24>=2.4
1.4       drochner   60: 
1.1       drochner   61: # transform the list into individual variables
                     62: .for pv in ${PYTHON_VERSIONS_ACCEPTED}
1.28      tv         63: .if empty(PYTHON_VERSIONS_INCOMPATIBLE:M${pv})
1.1       drochner   64: _PYTHON_VERSION_${pv}_OK=      yes
1.28      tv         65: .endif
1.1       drochner   66: .endfor
                     67: 
                     68: #
                     69: # choose a python version where to add,
                     70: # try to be intelligent
                     71: #
1.2       drochner   72: # if a version is explicitely required, take it
                     73: .if defined(PYTHON_VERSION_REQD)
1.40      joerg      74: # but check if it is acceptable first, error out otherwise
                     75: . if defined(_PYTHON_VERSION_${PYTHON_VERSION_REQD}_OK)
1.2       drochner   76: _PYTHON_VERSION=       ${PYTHON_VERSION_REQD}
1.40      joerg      77: . endif
                     78: .else
                     79: # if the default is accepted, it is first choice
                     80: . if !defined(_PYTHON_VERSION)
                     81: . if defined(_PYTHON_VERSION_${PYTHON_VERSION_DEFAULT}_OK)
1.1       drochner   82: _PYTHON_VERSION=       ${PYTHON_VERSION_DEFAULT}
1.40      joerg      83: . endif
                     84: . endif
1.1       drochner   85: # prefer an already installed version, in order of "accepted"
1.40      joerg      86: . if !defined(_PYTHON_VERSION)
                     87: . for pv in ${PYTHON_VERSIONS_ACCEPTED}
                     88: . if defined(_PYTHON_VERSION_${pv}_OK)
1.1       drochner   89: _PYTHON_VERSION?=      ${pv}
1.40      joerg      90: . endif
                     91: . endfor
                     92: . endif
1.1       drochner   93: .endif
1.40      joerg      94: 
                     95: # No supported version found, annotate to simplify statements below.
1.1       drochner   96: .if !defined(_PYTHON_VERSION)
1.40      joerg      97: _PYTHON_VERSION=       none
1.1       drochner   98: .endif
                     99: 
                    100: #
1.5       drochner  101: # set variables for the version we decided to use:
                    102: #  PYVERSSUFFIX: suffix to executables and in library path,
                    103: #                equal to sys.version[0:3]
                    104: #  PYPKGPREFIX: prefix to use in PKGNAME for extensions which can install
                    105: #               to multiple Python versions
1.1       drochner  106: #
1.30      recht     107: .if ${_PYTHON_VERSION} == "24"
                    108: PYPKGSRCDIR=   ../../lang/python24
1.39      reed      109: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python24}:${PYPKGSRCDIR}
1.30      recht     110: PYPACKAGE=     python24
                    111: PYVERSSUFFIX=  2.4
                    112: PYPKGPREFIX=   py24
                    113: .elif ${_PYTHON_VERSION} == "23"
1.21      drochner  114: PYPKGSRCDIR=   ../../lang/python23
1.39      reed      115: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python23}:${PYPKGSRCDIR}
1.21      drochner  116: PYPACKAGE=     python23
                    117: PYVERSSUFFIX=  2.3
                    118: PYPKGPREFIX=   py23
                    119: .elif ${_PYTHON_VERSION} == "22"
1.10      jlam      120: PYPKGSRCDIR=   ../../lang/python22
1.39      reed      121: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python22}:${PYPKGSRCDIR}
1.14      jlam      122: PYPACKAGE=     python22
1.5       drochner  123: PYVERSSUFFIX=  2.2
1.2       drochner  124: PYPKGPREFIX=   py22
                    125: .elif ${_PYTHON_VERSION} == "21"
1.10      jlam      126: PYPKGSRCDIR=   ../../lang/python21
1.14      jlam      127: PYPACKAGE=     python21
1.39      reed      128: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python21}:${PYPKGSRCDIR}
1.5       drochner  129: PYVERSSUFFIX=  2.1
1.1       drochner  130: PYPKGPREFIX=   py21
                    131: .elif ${_PYTHON_VERSION} == "20"
1.10      jlam      132: PYPKGSRCDIR=   ../../lang/python20
1.14      jlam      133: PYPACKAGE=     python20
1.39      reed      134: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python20}:${PYPKGSRCDIR}
1.5       drochner  135: PYVERSSUFFIX=  2.0
1.1       drochner  136: PYPKGPREFIX=   py20
1.7       drochner  137: .elif ${_PYTHON_VERSION} == "15"
1.10      jlam      138: PYPKGSRCDIR=   ../../lang/python15
1.14      jlam      139: PYPACKAGE=     python15
1.39      reed      140: PYDEPENDENCY=  ${BUILDLINK_API_DEPENDS.python15}:${PYPKGSRCDIR}
1.7       drochner  141: PYVERSSUFFIX=  1.5
                    142: PYPKGPREFIX=   py15
                    143: .if !defined(PYTHON_DISTUTILS_BOOTSTRAP)
1.42      joerg     144: BUILD_DEPENDS+=        py15-distutils-[0-9]*:../../devel/py-distutils
1.7       drochner  145: .endif
1.8       drochner  146: .else
                    147: # force an error
1.37      kristerw  148: PKG_SKIP_REASON+=   "No valid Python version"
1.1       drochner  149: .endif
1.5       drochner  150: 
1.38      rillig    151: PTHREAD_OPTS+= require
1.33      jlam      152: .include "../../mk/pthread.buildlink3.mk"
1.38      rillig    153: 
1.33      jlam      154: .if defined(PYTHON_FOR_BUILD_ONLY)
1.36      seb       155: BUILDLINK_DEPMETHOD.python?=   build
1.11      jlam      156: .endif
1.37      kristerw  157: .if defined(PYPKGSRCDIR)
1.33      jlam      158: .include "${PYPKGSRCDIR}/buildlink3.mk"
1.37      kristerw  159: .endif
1.11      jlam      160: 
                    161: PYTHONBIN=     ${LOCALBASE}/bin/python${PYVERSSUFFIX}
                    162: 
1.41      joerg     163: .if exists(${PYTHONBIN}) && !defined(PYTHON_DISTUTILS_BOOTSTRAP)
1.11      jlam      164: PYINC!=        ${PYTHONBIN} -c "import distutils.sysconfig; \
                    165:        print distutils.sysconfig.get_python_inc(0, \"\")" || ${ECHO} ""
                    166: PYLIB!=        ${PYTHONBIN} -c "import distutils.sysconfig; \
                    167:        print distutils.sysconfig.get_python_lib(0, 1, \"\")" || ${ECHO} ""
                    168: PYSITELIB!=    ${PYTHONBIN} -c "import distutils.sysconfig; \
                    169:        print distutils.sysconfig.get_python_lib(0, 0, \"\")" || ${ECHO} ""
1.29      recht     170: 
                    171: PRINT_PLIST_AWK+=      /^@dirrm ${PYINC:S|/|\\/|g}$$/ { next; }
                    172: PRINT_PLIST_AWK+=      /^@dirrm ${PYSITELIB:S|/|\\/|g}$$/ { next; }
                    173: PRINT_PLIST_AWK+=      /^@dirrm ${PYLIB:S|/|\\/|g}$$/ { next; }
                    174: 
                    175: PRINT_PLIST_AWK+=      /^(@dirrm )?${PYINC:S|/|\\/|g}/ \
                    176:                        { gsub(/${PYINC:S|/|\\/|g}/, "$${PYINC}"); \
                    177:                                print; next; }
                    178: PRINT_PLIST_AWK+=      /^(@dirrm )?${PYSITELIB:S|/|\\/|g}/ \
                    179:                        { gsub(/${PYSITELIB:S|/|\\/|g}/, "$${PYSITELIB}"); \
                    180:                                print; next; }
                    181: PRINT_PLIST_AWK+=      /^(@dirrm )?${PYLIB:S|/|\\/|g}/ \
                    182:                        { gsub(/${PYLIB:S|/|\\/|g}/, "$${PYLIB}"); \
                    183:                                print; next; }
1.6       drochner  184: .endif
1.2       drochner  185: 
                    186: .endif # PYTHON_PYVERSION_MK

CVSweb <webmaster@jp.NetBSD.org>