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