| @@ -1,204 +1,211 @@ | | | @@ -1,204 +1,211 @@ |
1 | # $NetBSD: pyversion.mk,v 1.98 2012/04/08 20:17:10 wiz Exp $ | | 1 | # $NetBSD: pyversion.mk,v 1.99 2012/05/06 13:18:30 obache Exp $ |
2 | | | 2 | |
3 | # This file determines which Python version is used as a dependency for | | 3 | # This file determines which Python version is used as a dependency for |
4 | # a package. | | 4 | # a package. |
5 | # | | 5 | # |
6 | # === User-settable variables === | | 6 | # === User-settable variables === |
7 | # | | 7 | # |
8 | # PYTHON_VERSION_DEFAULT | | 8 | # PYTHON_VERSION_DEFAULT |
9 | # The preferred Python version to use. | | 9 | # The preferred Python version to use. |
10 | # | | 10 | # |
11 | # Possible values: 25 26 27 31 | | 11 | # Possible values: 25 26 27 31 32 |
12 | # Default: 27 | | 12 | # Default: 27 |
13 | # | | 13 | # |
14 | # === Package-settable variables === | | 14 | # === Package-settable variables === |
15 | # | | 15 | # |
16 | # PYTHON_VERSIONS_ACCEPTED | | 16 | # PYTHON_VERSIONS_ACCEPTED |
17 | # The Python versions that are acceptable for the package. The | | 17 | # The Python versions that are acceptable for the package. The |
18 | # order of the entries matters, since earlier entries are | | 18 | # order of the entries matters, since earlier entries are |
19 | # preferred over later ones. | | 19 | # preferred over later ones. |
20 | # | | 20 | # |
21 | # Possible values: 31 27 26 25 | | 21 | # Possible values: 32 31 27 26 25 |
22 | # Default: (31) 27 26 25 | | 22 | # Default: (32 31) 27 26 25 |
23 | # | | 23 | # |
24 | # PYTHON_VERSIONS_INCLUDE_3X | | 24 | # PYTHON_VERSIONS_INCLUDE_3X |
25 | # Wether the default PYTHON_VERSIONS_ACCEPTED should include | | 25 | # Wether the default PYTHON_VERSIONS_ACCEPTED should include |
26 | # 3.x versions for for this package or not. | | 26 | # 3.x versions for for this package or not. |
27 | # This variable must be set before including bsd.prefs.mk. | | 27 | # This variable must be set before including bsd.prefs.mk. |
28 | # | | 28 | # |
29 | # Possible values: yes no | | 29 | # Possible values: yes no |
30 | # Default: no | | 30 | # Default: no |
31 | # | | 31 | # |
32 | # PYTHON_VERSIONS_INCOMPATIBLE | | 32 | # PYTHON_VERSIONS_INCOMPATIBLE |
33 | # The Python versions that are NOT acceptable for the package. | | 33 | # The Python versions that are NOT acceptable for the package. |
34 | # | | 34 | # |
35 | # Possible values: 25 26 27 31 | | 35 | # Possible values: 25 26 27 31 32 |
36 | # Default: (depends on the platform) | | 36 | # Default: (depends on the platform) |
37 | # | | 37 | # |
38 | # PYTHON_FOR_BUILD_ONLY | | 38 | # PYTHON_FOR_BUILD_ONLY |
39 | # Whether Python is needed only at build time or at run time. | | 39 | # Whether Python is needed only at build time or at run time. |
40 | # | | 40 | # |
41 | # Possible values: (defined) (undefined) | | 41 | # Possible values: (defined) (undefined) |
42 | # Default: (undefined) | | 42 | # Default: (undefined) |
43 | # | | 43 | # |
44 | # === Defined variables === | | 44 | # === Defined variables === |
45 | # | | 45 | # |
46 | # PYPKGPREFIX | | 46 | # PYPKGPREFIX |
47 | # The prefix to use in PKGNAME for extensions which are meant | | 47 | # The prefix to use in PKGNAME for extensions which are meant |
48 | # to be installed for multiple Python versions. | | 48 | # to be installed for multiple Python versions. |
49 | # | | 49 | # |
50 | # Example: py27 | | 50 | # Example: py27 |
51 | # | | 51 | # |
52 | # PYVERSSUFFIX | | 52 | # PYVERSSUFFIX |
53 | # The suffix to executables and in the library path, equal to | | 53 | # The suffix to executables and in the library path, equal to |
54 | # sys.version[0:3]. | | 54 | # sys.version[0:3]. |
55 | # | | 55 | # |
56 | # Example: 2.7 | | 56 | # Example: 2.7 |
57 | # | | 57 | # |
58 | # Keywords: python | | 58 | # Keywords: python |
59 | # | | 59 | # |
60 | | | 60 | |
61 | .if !defined(PYTHON_PYVERSION_MK) | | 61 | .if !defined(PYTHON_PYVERSION_MK) |
62 | PYTHON_PYVERSION_MK= defined | | 62 | PYTHON_PYVERSION_MK= defined |
63 | | | 63 | |
64 | # derive a python version from the package name if possible | | 64 | # derive a python version from the package name if possible |
65 | # optionally handled quoted package names | | 65 | # optionally handled quoted package names |
66 | .if defined(PKGNAME_REQD) && !empty(PKGNAME_REQD:Mpy[0-9][0-9]-*) || \ | | 66 | .if defined(PKGNAME_REQD) && !empty(PKGNAME_REQD:Mpy[0-9][0-9]-*) || \ |
67 | defined(PKGNAME_REQD) && !empty(PKGNAME_REQD:M*-py[0-9][0-9]-*) | | 67 | defined(PKGNAME_REQD) && !empty(PKGNAME_REQD:M*-py[0-9][0-9]-*) |
68 | PYTHON_VERSION_REQD?= ${PKGNAME_REQD:C/(^.*-|^)py([0-9][0-9])-.*/\2/} | | 68 | PYTHON_VERSION_REQD?= ${PKGNAME_REQD:C/(^.*-|^)py([0-9][0-9])-.*/\2/} |
69 | .elif defined(PKGNAME_OLD) && !empty(PKGNAME_OLD:Mpy[0-9][0-9]-*) || \ | | 69 | .elif defined(PKGNAME_OLD) && !empty(PKGNAME_OLD:Mpy[0-9][0-9]-*) || \ |
70 | defined(PKGNAME_OLD) && !empty(PKGNAME_OLD:M*-py[0-9][0-9]-*) | | 70 | defined(PKGNAME_OLD) && !empty(PKGNAME_OLD:M*-py[0-9][0-9]-*) |
71 | PYTHON_VERSION_REQD?= ${PKGNAME_OLD:C/(^.*-|^)py([0-9][0-9])-.*/\2/} | | 71 | PYTHON_VERSION_REQD?= ${PKGNAME_OLD:C/(^.*-|^)py([0-9][0-9])-.*/\2/} |
72 | .endif | | 72 | .endif |
73 | | | 73 | |
74 | .include "../../mk/bsd.prefs.mk" | | 74 | .include "../../mk/bsd.prefs.mk" |
75 | | | 75 | |
76 | BUILD_DEFS+= PYTHON_VERSION_DEFAULT | | 76 | BUILD_DEFS+= PYTHON_VERSION_DEFAULT |
77 | BUILD_DEFS_EFFECTS+= PYPACKAGE | | 77 | BUILD_DEFS_EFFECTS+= PYPACKAGE |
78 | | | 78 | |
79 | PYTHON_VERSION_DEFAULT?= 27 | | 79 | PYTHON_VERSION_DEFAULT?= 27 |
80 | .if ${PYTHON_VERSIONS_INCLUDE_3X:U:tl} == "yes" | | 80 | .if ${PYTHON_VERSIONS_INCLUDE_3X:U:tl} == "yes" |
81 | PYTHON_VERSIONS_ACCEPTED?= 31 27 26 25 | | 81 | PYTHON_VERSIONS_ACCEPTED?= 32 31 27 26 25 |
82 | .else | | 82 | .else |
83 | PYTHON_VERSIONS_ACCEPTED?= 27 26 25 | | 83 | PYTHON_VERSIONS_ACCEPTED?= 27 26 25 |
84 | .endif | | 84 | .endif |
85 | PYTHON_VERSIONS_INCOMPATIBLE?= # empty by default | | 85 | PYTHON_VERSIONS_INCOMPATIBLE?= # empty by default |
86 | | | 86 | |
87 | BUILDLINK_API_DEPENDS.python25?= python25>=2.5.1 | | 87 | BUILDLINK_API_DEPENDS.python25?= python25>=2.5.1 |
88 | BUILDLINK_API_DEPENDS.python26?= python26>=2.6 | | 88 | BUILDLINK_API_DEPENDS.python26?= python26>=2.6 |
89 | BUILDLINK_API_DEPENDS.python27?= python27>=2.7 | | 89 | BUILDLINK_API_DEPENDS.python27?= python27>=2.7 |
90 | BUILDLINK_API_DEPENDS.python31?= python31>=3.1 | | 90 | BUILDLINK_API_DEPENDS.python31?= python31>=3.1 |
| | | 91 | BUILDLINK_API_DEPENDS.python32?= python32>=3.2 |
91 | | | 92 | |
92 | # transform the list into individual variables | | 93 | # transform the list into individual variables |
93 | .for pv in ${PYTHON_VERSIONS_ACCEPTED} | | 94 | .for pv in ${PYTHON_VERSIONS_ACCEPTED} |
94 | .if empty(PYTHON_VERSIONS_INCOMPATIBLE:M${pv}) | | 95 | .if empty(PYTHON_VERSIONS_INCOMPATIBLE:M${pv}) |
95 | _PYTHON_VERSION_${pv}_OK= yes | | 96 | _PYTHON_VERSION_${pv}_OK= yes |
96 | _PYTHON_VERSIONS_ACCEPTED+= ${pv} | | 97 | _PYTHON_VERSIONS_ACCEPTED+= ${pv} |
97 | .endif | | 98 | .endif |
98 | .endfor | | 99 | .endfor |
99 | | | 100 | |
100 | # | | 101 | # |
101 | # choose a python version where to add, | | 102 | # choose a python version where to add, |
102 | # try to be intelligent | | 103 | # try to be intelligent |
103 | # | | 104 | # |
104 | # if a version is explicitely required, take it | | 105 | # if a version is explicitely required, take it |
105 | .if defined(PYTHON_VERSION_REQD) | | 106 | .if defined(PYTHON_VERSION_REQD) |
106 | # but check if it is acceptable first, error out otherwise | | 107 | # but check if it is acceptable first, error out otherwise |
107 | . if defined(_PYTHON_VERSION_${PYTHON_VERSION_REQD}_OK) | | 108 | . if defined(_PYTHON_VERSION_${PYTHON_VERSION_REQD}_OK) |
108 | _PYTHON_VERSION= ${PYTHON_VERSION_REQD} | | 109 | _PYTHON_VERSION= ${PYTHON_VERSION_REQD} |
109 | . endif | | 110 | . endif |
110 | .else | | 111 | .else |
111 | # if the default is accepted, it is first choice | | 112 | # if the default is accepted, it is first choice |
112 | . if !defined(_PYTHON_VERSION) | | 113 | . if !defined(_PYTHON_VERSION) |
113 | . if defined(_PYTHON_VERSION_${PYTHON_VERSION_DEFAULT}_OK) | | 114 | . if defined(_PYTHON_VERSION_${PYTHON_VERSION_DEFAULT}_OK) |
114 | _PYTHON_VERSION= ${PYTHON_VERSION_DEFAULT} | | 115 | _PYTHON_VERSION= ${PYTHON_VERSION_DEFAULT} |
115 | . endif | | 116 | . endif |
116 | . endif | | 117 | . endif |
117 | # prefer an already installed version, in order of "accepted" | | 118 | # prefer an already installed version, in order of "accepted" |
118 | . if !defined(_PYTHON_VERSION) | | 119 | . if !defined(_PYTHON_VERSION) |
119 | . for pv in ${PYTHON_VERSIONS_ACCEPTED} | | 120 | . for pv in ${PYTHON_VERSIONS_ACCEPTED} |
120 | . if defined(_PYTHON_VERSION_${pv}_OK) | | 121 | . if defined(_PYTHON_VERSION_${pv}_OK) |
121 | _PYTHON_VERSION?= ${pv} | | 122 | _PYTHON_VERSION?= ${pv} |
122 | . endif | | 123 | . endif |
123 | . endfor | | 124 | . endfor |
124 | . endif | | 125 | . endif |
125 | .endif | | 126 | .endif |
126 | | | 127 | |
127 | # | | 128 | # |
128 | # Variable assignment for multi-python packages | | 129 | # Variable assignment for multi-python packages |
129 | MULTI+= PYTHON_VERSION_REQD=${_PYTHON_VERSION} | | 130 | MULTI+= PYTHON_VERSION_REQD=${_PYTHON_VERSION} |
130 | | | 131 | |
131 | # No supported version found, annotate to simplify statements below. | | 132 | # No supported version found, annotate to simplify statements below. |
132 | .if !defined(_PYTHON_VERSION) | | 133 | .if !defined(_PYTHON_VERSION) |
133 | _PYTHON_VERSION= none | | 134 | _PYTHON_VERSION= none |
134 | .endif | | 135 | .endif |
135 | | | 136 | |
136 | .if ${_PYTHON_VERSION} == "31" | | 137 | .if ${_PYTHON_VERSION} == "32" |
| | | 138 | PYPKGSRCDIR= ../../lang/python32 |
| | | 139 | PYDEPENDENCY= ${BUILDLINK_API_DEPENDS.python32}:${PYPKGSRCDIR} |
| | | 140 | PYPACKAGE= python32 |
| | | 141 | PYVERSSUFFIX= 3.2 |
| | | 142 | PYPKGPREFIX= py32 |
| | | 143 | .elif ${_PYTHON_VERSION} == "31" |
137 | PYPKGSRCDIR= ../../lang/python31 | | 144 | PYPKGSRCDIR= ../../lang/python31 |
138 | PYDEPENDENCY= ${BUILDLINK_API_DEPENDS.python31}:${PYPKGSRCDIR} | | 145 | PYDEPENDENCY= ${BUILDLINK_API_DEPENDS.python31}:${PYPKGSRCDIR} |
139 | PYPACKAGE= python31 | | 146 | PYPACKAGE= python31 |
140 | PYVERSSUFFIX= 3.1 | | 147 | PYVERSSUFFIX= 3.1 |
141 | PYPKGPREFIX= py31 | | 148 | PYPKGPREFIX= py31 |
142 | .elif ${_PYTHON_VERSION} == "27" | | 149 | .elif ${_PYTHON_VERSION} == "27" |
143 | PYPKGSRCDIR= ../../lang/python27 | | 150 | PYPKGSRCDIR= ../../lang/python27 |
144 | PYDEPENDENCY= ${BUILDLINK_API_DEPENDS.python27}:${PYPKGSRCDIR} | | 151 | PYDEPENDENCY= ${BUILDLINK_API_DEPENDS.python27}:${PYPKGSRCDIR} |
145 | PYPACKAGE= python27 | | 152 | PYPACKAGE= python27 |
146 | PYVERSSUFFIX= 2.7 | | 153 | PYVERSSUFFIX= 2.7 |
147 | PYPKGPREFIX= py27 | | 154 | PYPKGPREFIX= py27 |
148 | .elif ${_PYTHON_VERSION} == "26" | | 155 | .elif ${_PYTHON_VERSION} == "26" |
149 | PYPKGSRCDIR= ../../lang/python26 | | 156 | PYPKGSRCDIR= ../../lang/python26 |
150 | PYDEPENDENCY= ${BUILDLINK_API_DEPENDS.python26}:${PYPKGSRCDIR} | | 157 | PYDEPENDENCY= ${BUILDLINK_API_DEPENDS.python26}:${PYPKGSRCDIR} |
151 | PYPACKAGE= python26 | | 158 | PYPACKAGE= python26 |
152 | PYVERSSUFFIX= 2.6 | | 159 | PYVERSSUFFIX= 2.6 |
153 | PYPKGPREFIX= py26 | | 160 | PYPKGPREFIX= py26 |
154 | .elif ${_PYTHON_VERSION} == "25" | | 161 | .elif ${_PYTHON_VERSION} == "25" |
155 | PYPKGSRCDIR= ../../lang/python25 | | 162 | PYPKGSRCDIR= ../../lang/python25 |
156 | PYDEPENDENCY= ${BUILDLINK_API_DEPENDS.python25}:${PYPKGSRCDIR} | | 163 | PYDEPENDENCY= ${BUILDLINK_API_DEPENDS.python25}:${PYPKGSRCDIR} |
157 | PYPACKAGE= python25 | | 164 | PYPACKAGE= python25 |
158 | PYVERSSUFFIX= 2.5 | | 165 | PYVERSSUFFIX= 2.5 |
159 | PYPKGPREFIX= py25 | | 166 | PYPKGPREFIX= py25 |
160 | .else | | 167 | .else |
161 | PKG_FAIL_REASON+= "No valid Python version" | | 168 | PKG_FAIL_REASON+= "No valid Python version" |
162 | PYPKGPREFIX= | | 169 | PYPKGPREFIX= |
163 | .endif | | 170 | .endif |
164 | | | 171 | |
165 | PTHREAD_OPTS+= require | | 172 | PTHREAD_OPTS+= require |
166 | .include "../../mk/pthread.buildlink3.mk" | | 173 | .include "../../mk/pthread.buildlink3.mk" |
167 | | | 174 | |
168 | .if defined(PYTHON_FOR_BUILD_ONLY) | | 175 | .if defined(PYTHON_FOR_BUILD_ONLY) |
169 | BUILDLINK_DEPMETHOD.python?= build | | 176 | BUILDLINK_DEPMETHOD.python?= build |
170 | .endif | | 177 | .endif |
171 | .if defined(PYPKGSRCDIR) | | 178 | .if defined(PYPKGSRCDIR) |
172 | .include "${PYPKGSRCDIR}/buildlink3.mk" | | 179 | .include "${PYPKGSRCDIR}/buildlink3.mk" |
173 | .endif | | 180 | .endif |
174 | | | 181 | |
175 | PYTHONBIN= ${LOCALBASE}/bin/python${PYVERSSUFFIX} | | 182 | PYTHONBIN= ${LOCALBASE}/bin/python${PYVERSSUFFIX} |
176 | PYTHONCONFIG= ${LOCALBASE}/bin/python${PYVERSSUFFIX}-config | | 183 | PYTHONCONFIG= ${LOCALBASE}/bin/python${PYVERSSUFFIX}-config |
177 | PY_COMPILE_ALL= \ | | 184 | PY_COMPILE_ALL= \ |
178 | ${PYTHONBIN} ${PREFIX}/lib/python${PYVERSSUFFIX}/compileall.py -q | | 185 | ${PYTHONBIN} ${PREFIX}/lib/python${PYVERSSUFFIX}/compileall.py -q |
179 | PY_COMPILE_O_ALL= \ | | 186 | PY_COMPILE_O_ALL= \ |
180 | ${PYTHONBIN} -O ${PREFIX}/lib/python${PYVERSSUFFIX}/compileall.py -q | | 187 | ${PYTHONBIN} -O ${PREFIX}/lib/python${PYVERSSUFFIX}/compileall.py -q |
181 | | | 188 | |
182 | .if exists(${PYTHONBIN}) | | 189 | .if exists(${PYTHONBIN}) |
183 | PYINC!= ${PYTHONBIN} -c "import distutils.sysconfig; \ | | 190 | PYINC!= ${PYTHONBIN} -c "import distutils.sysconfig; \ |
184 | print (distutils.sysconfig.get_python_inc(0, \"\"))" || ${ECHO} "" | | 191 | print (distutils.sysconfig.get_python_inc(0, \"\"))" || ${ECHO} "" |
185 | PYLIB!= ${PYTHONBIN} -c "import distutils.sysconfig; \ | | 192 | PYLIB!= ${PYTHONBIN} -c "import distutils.sysconfig; \ |
186 | print (distutils.sysconfig.get_python_lib(0, 1, \"\"))" || ${ECHO} "" | | 193 | print (distutils.sysconfig.get_python_lib(0, 1, \"\"))" || ${ECHO} "" |
187 | PYSITELIB!= ${PYTHONBIN} -c "import distutils.sysconfig; \ | | 194 | PYSITELIB!= ${PYTHONBIN} -c "import distutils.sysconfig; \ |
188 | print (distutils.sysconfig.get_python_lib(0, 0, \"\"))" || ${ECHO} "" | | 195 | print (distutils.sysconfig.get_python_lib(0, 0, \"\"))" || ${ECHO} "" |
189 | | | 196 | |
190 | PRINT_PLIST_AWK+= /^${PYINC:S|/|\\/|g}/ \ | | 197 | PRINT_PLIST_AWK+= /^${PYINC:S|/|\\/|g}/ \ |
191 | { gsub(/${PYINC:S|/|\\/|g}/, "$${PYINC}") } | | 198 | { gsub(/${PYINC:S|/|\\/|g}/, "$${PYINC}") } |
192 | PRINT_PLIST_AWK+= /^${PYSITELIB:S|/|\\/|g}/ \ | | 199 | PRINT_PLIST_AWK+= /^${PYSITELIB:S|/|\\/|g}/ \ |
193 | { gsub(/${PYSITELIB:S|/|\\/|g}/, "$${PYSITELIB}") } | | 200 | { gsub(/${PYSITELIB:S|/|\\/|g}/, "$${PYSITELIB}") } |
194 | PRINT_PLIST_AWK+= /^${PYLIB:S|/|\\/|g}/ \ | | 201 | PRINT_PLIST_AWK+= /^${PYLIB:S|/|\\/|g}/ \ |
195 | { gsub(/${PYLIB:S|/|\\/|g}/, "$${PYLIB}") } | | 202 | { gsub(/${PYLIB:S|/|\\/|g}/, "$${PYLIB}") } |
196 | .endif | | 203 | .endif |
197 | | | 204 | |
198 | ALL_ENV+= PYTHON=${PYTHONBIN} | | 205 | ALL_ENV+= PYTHON=${PYTHONBIN} |
199 | .if defined(USE_CMAKE) | | 206 | .if defined(USE_CMAKE) |
200 | # used by FindPythonInterp.cmake and FindPythonLibs.cmake | | 207 | # used by FindPythonInterp.cmake and FindPythonLibs.cmake |
201 | CMAKE_ARGS+= -DPYVERSSUFFIX:STRING=${PYVERSSUFFIX} | | 208 | CMAKE_ARGS+= -DPYVERSSUFFIX:STRING=${PYVERSSUFFIX} |
202 | .endif | | 209 | .endif |
203 | | | 210 | |
204 | .endif # PYTHON_PYVERSION_MK | | 211 | .endif # PYTHON_PYVERSION_MK |