/[ports]/head/Mk/Uses/python.mk
ViewVC logotype

Contents of /head/Mk/Uses/python.mk

Parent Directory Parent Directory | Revision Log Revision Log


Revision 414168 - (show annotations) (download)
Thu Apr 28 12:17:09 2016 UTC (8 years, 2 months ago) by antoine
File MIME type: text/plain
File size: 23797 byte(s)
Remove ${PORTSDIR} from python _DEPENDS

1 # $FreeBSD$
2 #
3 # Provide support for Python related ports. This includes detecting Python
4 # interpreters, ports providing package and modules for python as well as
5 # consumer ports requiring Python at build or run time.
6 #
7 # Feature: python
8 # Usage: USES=python or USES=python:args
9 # Valid ARGS: <version>, build, run, test
10 #
11 # version If your port requires only some set of Python versions, you
12 # can set this to [min]-[max] or min+ or -max or as an
13 # explicit version or as a meta port version (eg. 3.3-3.4 for
14 # [min]-[max], 2.7+ or -3.3 for min+ and -max, 2.7 for an
15 # explicit version or 3 for a meta port version). Example:
16 #
17 # USES=python:2.7 # Only use Python 2.7
18 # USES=python:3.3+ # Use Python 3.3 or newer
19 # USES=python:3.3-3.4 # Use Python 3.3 or 3.4
20 # USES=python:-3.3 # Use any Python up to 3.3
21 # USES=python:2 # Use the Python 2 meta port
22 # USES=python # Use the set default Python
23 # # version
24 #
25 # build Indicates that Python is needed at build time and adds
26 # it to BUILD_DEPENDS.
27 # run Indicates that Python is needed at run time and adds
28 # it to RUN_DEPENDS.
29 # test Indicates that Python is needed at test time and adds
30 # it to TEST_DEPENDS.
31 #
32 # If build, run and test are omitted, Python will be added as BUILD_DEPENDS,
33 # RUN_DEPENDS and TEST_DEPENDS. PYTHON_NO_DEPENDS can be set to not add any
34 # dependencies.
35 #
36 # Variables, which can be set by a user:
37 #
38 # PYTHON_VERSION - The chosen Python interpreter including the version,
39 # e.g. python2.7, python3.3, etc. This allows the user
40 # to override the currently chosen default version and
41 # to install the port for a specific Python version.
42 # It must not be set by a port.
43 #
44 # Variables, which can be set by the port:
45 #
46 # USE_PYTHON - A list of additional features and functionality to
47 # enable. Supported features are:
48 #
49 # concurrent - Indicates that the port can be installed for
50 # different python versions at the same time. The port
51 # is supposed to use a unique prefix for certain
52 # directories using USES=uniquefiles:dirs (see the
53 # uniquefiles.mk Uses for details about the
54 # directories), if set to yes. Binaries receive an
55 # additional suffix, based on ${PYTHON_VER}.
56 #
57 # The values for the uniquefiles USES are set as
58 # follows:
59 #
60 # UNIQUE_PREFIX= ${PYTHON_PKGNAMEPREFIX}
61 # UNIQUE_SUFFIX= -${PYTHON_VER}
62 #
63 # If the port is installed for the current default
64 # python version, scripts and binaries in
65 #
66 # ${PREFIX}/bin
67 # ${PREFIX}/sbin
68 # ${PREFIX}/libexec
69 #
70 # are linked from the prefixed version to the
71 # prefix-less original name, e.g.
72 # bin/foo-2.7 --> bin/foo.
73 #
74 # distutils - Use distutils as do-configure, do-build and
75 # do-install targets.
76 #
77 # autoplist - Automatically generates the packaging list for a
78 # port that uses distutils when defined.
79 # requires: distutils
80 #
81 # py3kplist - Automatically generates Python 3.x compatible
82 # __pycache__ entries from a Python 2.x packaging list
83 # when defined. Use this for ports that do *not* use
84 # standard Python packaging mechanisms such as
85 # distutils, and support *both* Python 2.x and 3.x.
86 # Not needed, if USE_PYTHON=autoplist is set.
87 #
88 # pythonprefix - Says that the port installs in ${PYTHONBASE} instead
89 # of ${PREFIX}.
90 #
91 # noegginfo - Skip an egg-info entry from plist, if defined.
92 #
93 # PYTHON_CMD - Python's command line file name, including the
94 # version number (used for dependencies).
95 # default: ${PYTHONBASE}/bin/${PYTHON_VERSION}
96 #
97 # PYSETUP - Name of the setup script used by the distutils
98 # package.
99 # default: setup.py
100 #
101 # PYDISTUTILS_PKGNAME
102 # - Internal name in the distutils for egg-info.
103 # default: ${PORTNAME}
104 #
105 # PYDISTUTILS_PKGVERSION
106 # - Internal version in the distutils for egg-info.
107 # default: ${PORTVERSION}
108 #
109 # PYDISTUTILS_CONFIGURE_TARGET
110 # - Pass this command to distutils on configure stage.
111 # default: config
112 #
113 # PYDISTUTILS_BUILD_TARGET
114 # - Pass this command to distutils on build stage.
115 # default: build
116 #
117 # PYDISTUTILS_INSTALL_TARGET
118 # - Pass this command to distutils on install stage.
119 # default: install
120 #
121 # PYDISTUTILS_CONFIGUREARGS
122 # - Arguments to config with distutils.
123 # default: <empty>
124 #
125 # PYDISTUTILS_BUILDARGS
126 # - Arguments to build with distutils.
127 # default: <empty>
128 #
129 # PYDISTUTILS_INSTALLARGS
130 # - Arguments to install with distutils.
131 # default: -c -O1 --prefix=${PREFIX} --single-version-externally-managed --root=${STAGEDIR}
132 #
133 # PYDISTUTILS_EGGINFO
134 # - Canonical name for egg-info.
135 # default: ${PYDISTUTILS_PKGNAME:C/[^A-Za-z0-9.]+/_/g}-${PYDISTUTILS_PKGVERSION:C/[^A-Za-z0-9.]+/_/g}-py${PYTHON_VER}.egg-info
136 #
137 # The following variables can be read by ports and must not be modified:
138 #
139 # PYTHONBASE - The installation prefix of the chosen Python
140 # interpreter, e.g. /usr/local
141 #
142 # PYTHON_PORTVERSION
143 # - Version number suitable for ${PORTVERSION}.
144 #
145 # PYTHON_PORTSDIR - The port directory of the chosen Python interpreter
146 #
147 # PYTHON_REL - The release number of the chosen Python interpreter
148 # without dots, e.g. 2706, 3401, ...
149 #
150 # PYTHON_SUFFIX - The major-minor release number of the chosen Python
151 # interpreter without dots, e.g. 27, 34, ...
152 # Used for prefixes and suffixes.
153 #
154 # PYTHON_MAJOR_VER - The major release version of the chosen Python
155 # interpreter, e.g. 2, 3, ...
156 #
157 # PYTHON_VER - The major-minor release version of the chosen Python
158 # interpreter, e.g. 2.7, 3.4, ...
159 #
160 # PYTHON_ABIVER - Additional ABI flags set by the chosen Python
161 # interpreter, e.g. md
162 #
163 # PYTHON_INCLUDEDIR - Location of the Python include files.
164 # default: ${PYTHONBASE}/include/${PYTHON_VERSION}
165 #
166 # PYTHON_LIBDIR - Base of the python library tree
167 # default: ${PYTHONBASE}/lib/${PYTHON_VERSION}
168 #
169 # PYTHON_SITELIBDIR - Location of the site-packages tree. Don't change,
170 # unless you know what you do.
171 # default: ${PYTHON_LIBDIR}/site-packages
172 #
173 # There are PREFIX-clean variants of the PYTHON_*DIR variables above.
174 # They are meant to be used by ports instead of the above variables, so the
175 # ports respect ${PREFIX} (unless USE_PYTHON=pythonprefix is specified).
176 #
177 # PYTHONPREFIX_INCLUDEDIR default: ${PREFIX}/include/${PYTHON_VERSION}
178 # PYTHONPREFIX_LIBDIR default: ${PREFIX}/lib/${PYTHON_VERSION}
179 # PYTHONPREFIX_SITELIBDIR default: ${PYTHONPREFIX_LIBDIR}/site-packages
180 #
181 # PYTHON_PLATFORM - Python's idea of the OS release.
182 # This is faked with ${OPSYS} and ${OSREL} until we
183 # find out how to delay defining a variable until
184 # after a certain target has been built.
185 #
186 # PYTHON_PKGNAMEPREFIX
187 # - Use this as a ${PKGNAMEPREFIX} to distinguish
188 # packages for different Python versions.
189 # default: py${PYTHON_SUFFIX}-
190 #
191 # Using USES=python.mk also will add some useful entries to PLIST_SUB:
192 #
193 # PYTHON_INCLUDEDIR=${PYTHONPREFIX_INCLUDEDIR:S;${PREFIX}/;;}
194 # PYTHON_LIBDIR=${PYTHONPREFIX_LIBDIR:S;${PREFIX}/;;}
195 # PYTHON_PLATFORM=${PYTHON_PLATFORM}
196 # PYTHON_SITELIBDIR=${PYTHONPREFIX_SITELIBDIR:S;${PREFIX}/;;}
197 # PYTHON_VER=${PYTHON_VER}
198 # PYTHON_VERSION=${PYTHON_VERSION}
199 #
200 #
201 # Deprecated variables, which exist for compatibility and will be removed
202 # soon:
203 #
204 # PYTHON_DEFAULT_VERSION
205 # PYTHON2_DEFAULT_VERSION
206 # PYTHON3_DEFAULT_VERSION
207 # - Deprecated, use PYTHON[2,3]_DEFAULT instead,
208 # see bsd.default-versions.mk
209 #
210 # PYTHON_PKGNAMESUFFIX
211 # - Deprecated, use PYTHON_PKGNAMEPREFIX instead
212 # default: -py${PYTHON_SUFFIX}
213 #
214 # PYDISTUTILS_INSTALLNOSINGLE
215 # - Deprecated without replacement
216 #
217 # MAINTAINER: python@FreeBSD.org
218
219 .if !defined(_INCLUDE_USES_PYTHON_MK)
220 _INCLUDE_USES_PYTHON_MK= yes
221
222 # What Python version and what Python interpreters are currently supported?
223 # When adding a version, please keep the comment in
224 # Mk/bsd.default-versions.mk in sync.
225 _PYTHON_VERSIONS= 2.7 3.4 3.5 3.3 # preferred first
226 _PYTHON_PORTBRANCH= 2.7 # ${_PYTHON_VERSIONS:[1]}
227 _PYTHON_BASECMD= ${LOCALBASE}/bin/python
228 _PYTHON_RELPORTDIR= lang/python
229
230 # Make each individual feature available as _PYTHON_FEATURE_<FEATURENAME>
231 .for var in ${USE_PYTHON}
232 _PYTHON_FEATURE_${var:tu}= yes
233 .endfor
234
235 # Make sure that no dependency or some other environment variable
236 # pollutes the build/run dependency detection
237 .undef _PYTHON_BUILD_DEP
238 .undef _PYTHON_RUN_DEP
239 .undef _PYTHON_TEST_DEP
240 _PYTHON_ARGS= ${python_ARGS:S/,/ /g}
241 .if ${_PYTHON_ARGS:Mbuild}
242 _PYTHON_BUILD_DEP= yes
243 _PYTHON_ARGS:= ${_PYTHON_ARGS:Nbuild}
244 .endif
245 .if ${_PYTHON_ARGS:Mrun}
246 _PYTHON_RUN_DEP= yes
247 _PYTHON_ARGS:= ${_PYTHON_ARGS:Nrun}
248 .endif
249 .if ${_PYTHON_ARGS:Mtest}
250 _PYTHON_TEST_DEP= yes
251 _PYTHON_ARGS:= ${_PYTHON_ARGS:Ntest}
252 .endif
253
254 # The port does not specify a build, run or test dependency, assume all are
255 # required.
256 .if !defined(_PYTHON_BUILD_DEP) && !defined(_PYTHON_RUN_DEP) && \
257 !defined(_PYTHON_TEST_DEP) && !defined(PYTHON_NO_DEPENDS)
258 _PYTHON_BUILD_DEP= yes
259 _PYTHON_RUN_DEP= yes
260 _PYTHON_TEST_DEP= yes
261 .endif
262
263 # Determine version number of Python to use
264 .include "${PORTSDIR}/Mk/bsd.default-versions.mk"
265
266 .if defined(PYTHON_DEFAULT_VERSION)
267 WARNING+= "PYTHON_DEFAULT_VERSION is defined, consider using DEFAULT_VERSIONS=python=${PYTHON_DEFAULT_VERSION:S/^python//} instead"
268 .endif
269 .if defined(PYTHON2_DEFAULT_VERSION)
270 WARNING+= "PYTHON2_DEFAULT_VERSION is defined, consider using DEFAULT_VERSIONS=python2=${PYTHON2_DEFAULT_VERSION:S/^python//} instead"
271 .endif
272 .if defined(PYTHON3_DEFAULT_VERSION)
273 WARNING+= "PYTHON3_DEFAULT_VERSION is defined, consider using DEFAULT_VERSIONS=python3=${PYTHON3_DEFAULT_VERSION:S/^python//} instead"
274 .endif
275
276 .if exists(${LOCALBASE}/bin/python)
277 .if !defined(_PYTHON_DEFAULT_VERSION)
278 _PYTHON_DEFAULT_VERSION!= (${LOCALBASE}/bin/python -c \
279 'import sys; print("%d.%d" % sys.version_info[:2])' 2> /dev/null \
280 || ${ECHO_CMD} ${_PYTHON_PORTBRANCH}) | ${TAIL} -1
281 .endif
282 _EXPORTED_VARS+= _PYTHON_DEFAULT_VERSION
283 .if defined(PYTHON_DEFAULT) && (${PYTHON_DEFAULT} != ${_PYTHON_DEFAULT_VERSION})
284 WARNING+= "Your requested default python version ${PYTHON_DEFAULT} is different from the installed default python interpreter version ${_PYTHON_DEFAULT_VERSION}"
285 .endif
286 PYTHON_DEFAULT_VERSION= python${_PYTHON_DEFAULT_VERSION}
287 .else
288 PYTHON_DEFAULT_VERSION= python${PYTHON_DEFAULT}
289 .endif # exists(${LOCALBASE}/bin/python)
290
291 # Is only a meta-port version defined?
292 .if ${PYTHON_DEFAULT_VERSION} == "python2"
293 PYTHON2_DEFAULT_VERSION?= python${PYTHON2_DEFAULT}
294 .elif ${PYTHON_DEFAULT_VERSION:R} == "python2"
295 PYTHON2_DEFAULT_VERSION= ${PYTHON_DEFAULT_VERSION}
296 .else
297 PYTHON2_DEFAULT_VERSION?= python${PYTHON2_DEFAULT}
298 .endif
299 .if ${PYTHON_DEFAULT_VERSION} == "python3"
300 PYTHON3_DEFAULT_VERSION?= python${PYTHON3_DEFAULT}
301 .elif ${PYTHON_DEFAULT_VERSION:R} == "python3"
302 PYTHON3_DEFAULT_VERSION= ${PYTHON_DEFAULT_VERSION}
303 .else
304 PYTHON3_DEFAULT_VERSION?= python${PYTHON3_DEFAULT}
305 .endif
306
307 .if ${_PYTHON_ARGS} == "2"
308 _PYTHON_ARGS= ${PYTHON2_DEFAULT_VERSION:S/^python//}
309 _WANTS_META_PORT= 2
310 .elif ${_PYTHON_ARGS} == "3"
311 _PYTHON_ARGS= ${PYTHON3_DEFAULT_VERSION:S/^python//}
312 _WANTS_META_PORT= 3
313 .endif # ${_PYTHON_ARGS} == "2"
314
315 .if defined(PYTHON_VERSION)
316 # A port/user requests a specific python version for its dependencies via
317 # DEPENDS_ARGS, since it requires the specific python version itself.
318 # Several things can happen now:
319 # a) the dependency supports the requested version -> everything's fine
320 # b) the dependency does not support the requested version
321 # 1) the dependency works in a way that the different python
322 # versions do not matter -> everything's fine
323 # 2) the dependency is likely to break due to the conflict
324 # nothing's fine
325 #
326 # b.2) needs to be resolved. Due to the complexity of how different pieces of
327 # software are built, we can't solve this automatically. Instead, let's assume
328 # that maintainers know what they are doing and assume PYTHON_VERSION to be a
329 # hint. Just warn maintainers, if the versions do not match
330 # (_PYTHON_VERSION_NONSUPPORTED).
331 _PYTHON_VERSION:= ${PYTHON_VERSION:S/^python//}
332 .else
333 _PYTHON_VERSION:= ${PYTHON_DEFAULT_VERSION:S/^python//}
334 .endif # defined(PYTHON_VERSION)
335
336 # Validate Python version whether it meets the version restriction.
337 _PYTHON_VERSION_CHECK:= ${_PYTHON_ARGS:C/^([1-9]\.[0-9])$/\1-\1/}
338 _PYTHON_VERSION_MINIMUM_TMP:= ${_PYTHON_VERSION_CHECK:C/([1-9]\.[0-9])[-+].*/\1/}
339 _PYTHON_VERSION_MINIMUM:= ${_PYTHON_VERSION_MINIMUM_TMP:M[1-9].[0-9]}
340 _PYTHON_VERSION_MAXIMUM_TMP:= ${_PYTHON_VERSION_CHECK:C/.*-([1-9]\.[0-9])/\1/}
341 _PYTHON_VERSION_MAXIMUM:= ${_PYTHON_VERSION_MAXIMUM_TMP:M[1-9].[0-9]}
342
343 .undef _PYTHON_VERSION_NONSUPPORTED
344 .if !empty(_PYTHON_VERSION_MINIMUM) && (${_PYTHON_VERSION} < ${_PYTHON_VERSION_MINIMUM})
345 _PYTHON_VERSION_NONSUPPORTED= ${_PYTHON_VERSION_MINIMUM} at least
346 .elif !empty(_PYTHON_VERSION_MAXIMUM) && (${_PYTHON_VERSION} > ${_PYTHON_VERSION_MAXIMUM})
347 _PYTHON_VERSION_NONSUPPORTED= ${_PYTHON_VERSION_MAXIMUM} at most
348 .endif
349
350 # If we have an unsupported version of Python, try another.
351 .if defined(_PYTHON_VERSION_NONSUPPORTED)
352 .if defined(PYTHON_VERSION) || defined(PYTHON_CMD)
353 _PV:= ${_PYTHON_VERSION} # preserve the specified python version
354 WARNING+= "needs Python ${_PYTHON_VERSION_NONSUPPORTED}. But a port depending on this one specified ${_PV}"
355 .endif # defined(PYTHON_VERSION) || defined(PYTHON_CMD)
356 .undef _PYTHON_VERSION
357 .for ver in ${PYTHON2_DEFAULT} ${PYTHON3_DEFAULT} ${_PYTHON_VERSIONS}
358 __VER= ${ver}
359 .if !defined(_PYTHON_VERSION) && \
360 !(!empty(_PYTHON_VERSION_MINIMUM) && ( \
361 ${__VER} < ${_PYTHON_VERSION_MINIMUM})) && \
362 !(!empty(_PYTHON_VERSION_MAXIMUM) && ( \
363 ${__VER} > ${_PYTHON_VERSION_MAXIMUM}))
364 _PYTHON_VERSION= ${ver}
365 .endif
366 .endfor
367 .if !defined(_PYTHON_VERSION)
368 IGNORE= needs an unsupported version of Python
369 .endif
370 .endif # defined(_PYTHON_VERSION_NONSUPPORTED)
371
372 # Pass PYTHON_VERSION down the dependency chain. This ensures that
373 # port A -> B -> C all will use the same python version and do not
374 # try to find a different one, if the passed version fits into
375 # the supported version range.
376 PYTHON_VERSION?= python${_PYTHON_VERSION}
377 .if !defined(PYTHON_NO_DEPENDS)
378 DEPENDS_ARGS+= PYTHON_VERSION=${PYTHON_VERSION}
379 .endif
380
381 # NOTE:
382 #
383 # PYTHON_VERSION will hold whatever is passed down the dependency chain.
384 # If a user runs `make PYTHON_VERSION=python3.3, PYTHON_VERSION will be
385 # set to 'python3.3'. A port however may require a different version,
386 # which is stored (above) in _PYTHON_VERSION.
387 # Every python bit below hence should use python${_PYTHON_VERSION}, since
388 # this is the value, the _port_ requires
389 #
390
391 # Got the correct python version, set some publicly accessible variables
392 PYTHON_VER= ${_PYTHON_VERSION}
393 PYTHON_SUFFIX= ${_PYTHON_VERSION:S/.//g}
394 PYTHON_MAJOR_VER= ${PYTHON_VER:R}
395 PYTHON_REL= # empty
396 PYTHON_ABIVER= # empty
397 PYTHON_PORTSDIR= ${_PYTHON_RELPORTDIR}${PYTHON_SUFFIX}
398 # Protect partial checkouts from Mk/Scripts/functions.sh:export_ports_env().
399 .if !defined(_PORTS_ENV_CHECK) || exists(${PORTSDIR}/${PYTHON_PORTSDIR})
400 .include "${PORTSDIR}/${PYTHON_PORTSDIR}/Makefile.version"
401 .endif
402 # Create a 4 integer version string, prefixing 0 to the last token if
403 # it's a single character. Only use the the first 3 tokens of
404 # PORTVERSION to support pre-release versions (rc3, alpha4, etc) of
405 # any Python port (lang/pythonXY)
406 PYTHON_REL= ${PYTHON_PORTVERSION:C/^([0-9]+\.[0-9]+\.[0-9]+).*/\1/:C/\.([0-9]+)$/.0\1/:C/\.0?([0-9][0-9])$/.\1/:S/.//g}
407
408 # Might be overridden by calling ports
409 PYTHON_CMD?= ${_PYTHON_BASECMD}${_PYTHON_VERSION}
410 .if exists(${PYTHON_CMD}-config) && ${PYTHON_VER} != 2.7
411 PYTHON_ABIVER!= ${PYTHON_CMD}-config --abiflags
412 .endif
413
414 .if !defined(PYTHONBASE)
415 PYTHONBASE!= (${PYTHON_CMD} -c 'import sys; print(sys.prefix)' \
416 2> /dev/null || ${ECHO_CMD} ${LOCALBASE}) | ${TAIL} -1
417 .endif
418 _EXPORTED_VARS+= PYTHONBASE
419
420 PYTHON_INCLUDEDIR= ${PYTHONBASE}/include/python${_PYTHON_VERSION}${PYTHON_ABIVER}
421 PYTHON_LIBDIR= ${PYTHONBASE}/lib/python${_PYTHON_VERSION}
422 PYTHON_PLATFORM= ${OPSYS:tl}${OSREL:C/\.[0-9.]*//}
423 PYTHON_SITELIBDIR= ${PYTHON_LIBDIR}/site-packages
424 PYTHON_PKGNAMEPREFIX= py${PYTHON_SUFFIX}-
425 PYTHON_PKGNAMESUFFIX= -py${PYTHON_SUFFIX}
426
427 PYTHONPREFIX_INCLUDEDIR= ${PYTHON_INCLUDEDIR:S;${PYTHONBASE};${PREFIX};}
428 PYTHONPREFIX_LIBDIR= ${PYTHON_LIBDIR:S;${PYTHONBASE};${PREFIX};}
429 PYTHONPREFIX_SITELIBDIR= ${PYTHON_SITELIBDIR:S;${PYTHONBASE};${PREFIX};}
430
431 # Used for recording the installed files.
432 _PYTHONPKGLIST= ${WRKDIR}/.PLIST.pymodtmp
433
434 # Ports bound to a certain python version SHOULD
435 # - use the PYTHON_PKGNAMEPREFIX
436 # - use directories using the PYTHON_PKGNAMEPREFIX
437 # - install binaries using the required PYTHON_VER, with
438 # the default python version creating a symlink to the original binary
439 # name (for staging-aware ports).
440 #
441 # What makes a port 'bound' to a certain python version?
442 # - it installs data into PYTHON_SITELIBDIR, PYTHON_INCLUDEDIR, ...
443 # - it links against libpython*.so
444 # - it uses USE_PYTHON=distutils
445 #
446
447 .if defined(_PYTHON_FEATURE_CONCURRENT)
448 _USES_POST+= uniquefiles:dirs
449 .if ${PYTHON_VERSION} == ${PYTHON_DEFAULT_VERSION}
450 UNIQUE_DEFAULT_LINKS= yes
451 .else
452 UNIQUE_DEFAULT_LINKS= no
453 .endif
454 UNIQUE_PREFIX= ${PYTHON_PKGNAMEPREFIX}
455 UNIQUE_SUFFIX= -${PYTHON_VER}
456
457 .if defined(_PYTHON_FEATURE_AUTOPLIST)
458 UNIQUE_FIND_SUFFIX_FILES= \
459 ${SED} -e 's|^${PREFIX}/||' ${_PYTHONPKGLIST} ${TMPPLIST} | \
460 ${GREP} -e '^bin/.*$$\|^sbin/.*$$\|^libexec/.*$$'
461 .else
462 UNIQUE_FIND_SUFFIX_FILES= \
463 ${GREP} -he '^bin/.*$$\|^sbin/.*$$\|^libexec/.*$$' ${TMPPLIST} 2>/dev/null
464 .endif
465 .endif # defined(_PYTHON_FEATURE_CONCURRENT)
466
467 _CURRENTPORT:= ${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}
468 .if defined(_PYTHON_FEATURE_DISTUTILS) && \
469 ${_CURRENTPORT:S/${PYTHON_SUFFIX}$//} != ${PYTHON_PKGNAMEPREFIX}setuptools
470 BUILD_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}setuptools${PYTHON_SUFFIX}>0:devel/py-setuptools${PYTHON_SUFFIX}
471 RUN_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}setuptools${PYTHON_SUFFIX}>0:devel/py-setuptools${PYTHON_SUFFIX}
472 .endif
473
474 # distutils support
475 PYSETUP?= setup.py
476 PYDISTUTILS_SETUP?= -c \
477 "import sys; import setuptools; \
478 __file__='${PYSETUP}'; sys.argv[0]='${PYSETUP}'; \
479 exec(compile(open(__file__, 'rb').read().replace(b'\\r\\n', b'\\n'), __file__, 'exec'))"
480 PYDISTUTILS_CONFIGUREARGS?= # empty
481 PYDISTUTILS_BUILDARGS?= # empty
482 PYDISTUTILS_INSTALLARGS?= -c -O1 --prefix=${PREFIX}
483 .if defined(_PYTHON_FEATURE_DISTUTILS)
484 . if !defined(PYDISTUTILS_INSTALLNOSINGLE)
485 PYDISTUTILS_INSTALLARGS+= --single-version-externally-managed
486 . endif
487 PYDISTUTILS_INSTALLARGS+= --root=${STAGEDIR}
488 .endif
489 PYDISTUTILS_INSTALLARGS:= --record ${_PYTHONPKGLIST} \
490 ${PYDISTUTILS_INSTALLARGS}
491
492 PYDISTUTILS_PKGNAME?= ${PORTNAME}
493 PYDISTUTILS_PKGVERSION?=${PORTVERSION}
494 PYDISTUTILS_EGGINFO?= ${PYDISTUTILS_PKGNAME:C/[^A-Za-z0-9.]+/_/g}-${PYDISTUTILS_PKGVERSION:C/[^A-Za-z0-9.]+/_/g}-py${PYTHON_VER}.egg-info
495 PYDISTUTILS_EGGINFODIR?=${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}
496
497 .if !defined(_PYTHON_FEATURE_NOEGGINFO) && \
498 !defined(_PYTHON_FEATURE_AUTOPLIST) && \
499 defined(_PYTHON_FEATURE_DISTUTILS) && \
500 defined(PYTHON_REL)
501 _USES_stage+= 933:add-plist-egginfo
502 add-plist-egginfo:
503 . for egginfo in ${PYDISTUTILS_EGGINFO}
504 if [ -d "${PYDISTUTILS_EGGINFODIR}/${egginfo}" ]; then \
505 ${LS} ${PYDISTUTILS_EGGINFODIR}/${egginfo} | while read f; do \
506 ${ECHO_CMD} ${PYDISTUTILS_EGGINFODIR:S;^${STAGEDIR}${PREFIX}/;;}/${egginfo}/$${f} >> ${TMPPLIST}; \
507 done; \
508 fi;
509 . endfor
510 .endif
511
512 .if defined(_PYTHON_FEATURE_AUTOPLIST) && defined(_PYTHON_FEATURE_DISTUTILS)
513 _RELSITELIBDIR= ${PYTHONPREFIX_SITELIBDIR:S;${PREFIX}/;;}
514 _RELLIBDIR= ${PYTHONPREFIX_LIBDIR:S;${PREFIX}/;;}
515
516 _USES_stage+= 934:add-plist-pymod
517 add-plist-pymod:
518 @${SED} -e 's|^${STAGEDIR}${PREFIX}/||' \
519 -e 's|^${PREFIX}/||' \
520 -e 's|^\(man/.*man[0-9]\)/\(.*\.[0-9]\)$$|\1/\2.gz|' \
521 -e 's|[[:alnum:]|[:space:]]*/\.\./*||g; s|/\./|/|g' \
522 ${_PYTHONPKGLIST} | ${SORT} >> ${TMPPLIST}
523
524 .else
525 .if ${PYTHON_REL} >= 3200 && defined(_PYTHON_FEATURE_PY3KPLIST)
526 # When Python version is 3.2+ we rewrite all the filenames
527 # of TMPPLIST that end with .py[co], so that they conform
528 # to PEP 3147 (see http://www.python.org/dev/peps/pep-3147/)
529 PYMAGICTAG= ${PYTHON_CMD} -c 'import imp; print(imp.get_tag())'
530 .if ${PYTHON_REL} < 3500
531 PYOEXTENSION= pyo
532 .else
533 PYOEXTENSION= opt-1.pyc
534 .endif
535 _USES_stage+= 935:add-plist-python
536 add-plist-python:
537 @${AWK} '\
538 /\.py[co]$$/ && !($$0 ~ "/" pc "/") {id = match($$0, /\/[^\/]+\.py[co]$$/); if (id != 0) {d = substr($$0, 1, RSTART - 1); dirs[d] = 1}; sub(/\.pyc$$/, "." mt "&"); sub(/\.pyo$$/, "." mt "." pyo); sub(/[^\/]+\.py[co]$$/, pc "/&"); print; next} \
539 /^@dirrm / {d = substr($$0, 8); if (d in dirs) {print $$0 "/" pc}; print $$0; next} \
540 /^@dirrmtry / {d = substr($$0, 11); if (d in dirs) {print $$0 "/" pc}; print $$0; next} \
541 {print} \
542 ' \
543 pc="__pycache__" mt="$$(${PYMAGICTAG})" pyo="${PYOEXTENSION}" \
544 ${TMPPLIST} > ${TMPPLIST}.pyc_tmp
545 @${MV} ${TMPPLIST}.pyc_tmp ${TMPPLIST}
546 .endif # ${PYTHON_REL} >= 3200 && defined(_PYTHON_FEATURE_PY3KPLIST)
547 .endif # defined(_PYTHON_FEATURE_AUTOPLIST) && defined(_PYTHON_FEATURE_DISTUTILS)
548
549 # Fix for programs that build python from a GNU auto* environment
550 CONFIGURE_ENV+= PYTHON="${PYTHON_CMD}"
551
552 # By default CMake picks up the highest available version of Python package.
553 # Enforce the version required by the port or the default.
554 CMAKE_ARGS+= -DPython_ADDITIONAL_VERSIONS=${PYTHON_VER}
555
556 # Python 3rd-party modules
557 PYGAME= ${PYTHON_PKGNAMEPREFIX}game>0:devel/py-game
558 PYNUMERIC= ${PYTHON_SITELIBDIR}/Numeric/Numeric.py:math/py-numeric
559 PYNUMPY= ${PYTHON_SITELIBDIR}/numpy/core/numeric.py:math/py-numpy
560
561 # dependencies
562 .if defined(_PYTHON_BUILD_DEP)
563 BUILD_DEPENDS+= ${PYTHON_CMD}:${PYTHON_PORTSDIR}
564 .if defined(_WANTS_META_PORT)
565 BUILD_DEPENDS+= python${_WANTS_META_PORT}:${_PYTHON_RELPORTDIR}${_WANTS_META_PORT}
566 .endif
567 .endif
568 .if defined(_PYTHON_RUN_DEP)
569 RUN_DEPENDS+= ${PYTHON_CMD}:${PYTHON_PORTSDIR}
570 .if defined(_WANTS_META_PORT)
571 RUN_DEPENDS+= python${_WANTS_META_PORT}:${_PYTHON_RELPORTDIR}${_WANTS_META_PORT}
572 .endif
573 .endif
574 .if defined(_PYTHON_TEST_DEP)
575 TEST_DEPENDS+= ${PYTHON_CMD}:${PYTHON_PORTSDIR}
576 .if defined(_WANTS_META_PORT)
577 TEST_DEPENDS+= python${_WANTS_META_PORT}:${_PYTHON_RELPORTDIR}${_WANTS_META_PORT}
578 .endif
579 .endif
580
581 # set $PREFIX as Python's one
582 .if defined(_PYTHON_FEATURE_PYTHONPREFIX)
583 PREFIX= ${PYTHONBASE}
584 .endif
585
586 # Substitutions for pkg-plist
587 # Use a short form of the PYTHONPREFIX_*DIR variables; we don't need the
588 # base directory in the plist file.
589 PLIST_SUB+= PYTHON_INCLUDEDIR=${PYTHONPREFIX_INCLUDEDIR:S;${PREFIX}/;;} \
590 PYTHON_LIBDIR=${PYTHONPREFIX_LIBDIR:S;${PREFIX}/;;} \
591 PYTHON_PLATFORM=${PYTHON_PLATFORM} \
592 PYTHON_SITELIBDIR=${PYTHONPREFIX_SITELIBDIR:S;${PREFIX}/;;} \
593 PYTHON_VER=${PYTHON_VER} \
594 PYTHON_VERSION=python${_PYTHON_VERSION}
595
596 _USES_POST+= python
597 .endif # _INCLUDE_USES_PYTHON_MK
598
599 .if defined(_POSTMKINCLUDED) && !defined(_INCLUDE_USES_PYTHON_POST_MK)
600 _INCLUDE_USES_PYTHON_POST_MK= yes
601
602 # py-distutils support
603 PYDISTUTILS_CONFIGURE_TARGET?= config
604 PYDISTUTILS_BUILD_TARGET?= build
605 PYDISTUTILS_INSTALL_TARGET?= install
606
607 .if defined(_PYTHON_FEATURE_DISTUTILS)
608 LDSHARED?= ${CC} -shared
609 MAKE_ENV+= LDSHARED="${LDSHARED}" PYTHONDONTWRITEBYTECODE= PYTHONOPTIMIZE=
610
611 .if !target(do-configure) && !defined(HAS_CONFIGURE) && !defined(GNU_CONFIGURE)
612 do-configure:
613 @(cd ${BUILD_WRKSRC}; ${SETENV} ${MAKE_ENV} ${PYTHON_CMD} ${PYDISTUTILS_SETUP} ${PYDISTUTILS_CONFIGURE_TARGET} ${PYDISTUTILS_CONFIGUREARGS})
614 .endif
615
616 .if !target(do-build)
617 do-build:
618 @(cd ${BUILD_WRKSRC}; ${SETENV} ${MAKE_ENV} ${PYTHON_CMD} ${PYDISTUTILS_SETUP} ${PYDISTUTILS_BUILD_TARGET} ${PYDISTUTILS_BUILDARGS})
619 .endif
620
621 .if !target(do-install)
622 do-install:
623 @(cd ${INSTALL_WRKSRC}; ${SETENV} ${MAKE_ENV} ${PYTHON_CMD} ${PYDISTUTILS_SETUP} ${PYDISTUTILS_INSTALL_TARGET} ${PYDISTUTILS_INSTALLARGS})
624 .endif
625 .endif # defined(_PYTHON_FEATURE_DISTUTILS)
626 .endif # defined(_POSTMKINCLUDED) && !defined(_INCLUDE_USES_PYTHON_POST_MK)

Properties

Name Value
svn:eol-style native
svn:keywords FreeBSD=%H
svn:mime-type text/plain

  ViewVC Help
Powered by ViewVC 1.1.27