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