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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 569588 - (show annotations) (download)
Tue Mar 30 19:18:58 2021 UTC (3 years, 3 months ago) by sunpoet
File MIME type: text/plain
File size: 26619 byte(s)
Clean up PYTHON_PYOEXTENSION (followup of r500018)

PYTHON_PYOEXTENSION is only used by 2 ports (astro/weather and math/py-rpy2) now.

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[:version-spec][,arg,...]
9 # Valid ARGS: <version-spec>, patch, build, run, test, env
10 #
11 # version-spec Declarative specification for the Python version(s) the
12 # port supports. Subsets and ranges can be specified:
13 #
14 # * <version>
15 # * <minimum-version>-<maximum-version>
16 # * <minimum-version>+
17 # * -<maximum-version>
18 #
19 # Examples:
20 #
21 # USES=python:2.7 # Supports Python 2.7 Only
22 # USES=python:3.6+ # Supports Python 3.6 or later
23 # USES=python:3.6-3.9 # Supports Python 3.6 to 3.9
24 # USES=python:-3.8 # Supports Python up to 3.8
25 # USES=python # Supports 3.6+
26 #
27 # NOTE: <version-spec> should be as specific as possible, matching the versions
28 # upstream declares support for, without being incorrect. In particular,
29 # USES=python *without* a <version-spec> means 3.6+,
30 # including unreleased versions, which is probably incorrect.
31 #
32 # Not specifying a <version-spec> should only be used when a more specific
33 # <version-spec> cannot be specified due to syntax limitations, for
34 # example: 2.7,3.4-3.6, but even in this case, X.Y+ (2.7+), or -X.Y (-3.6)
35 # is preferred and likely more correct.
36 #
37 # patch Python is needed at patch time. Adds dependency to PATCH_DEPENDS.
38 # build Python is needed at build time. Adds dependency to BUILD_DEPENDS.
39 # run Python is needed at run time. Adds dependency to RUN_DEPENDS.
40 # test Python is needed at test time. Adds dependency to TEST_DEPENDS.
41 # env Does not depend on Python but needs the environment set up. This
42 # is mainly used when depending on flavored python ports, or when a
43 # correct PYTHON_CMD is required. It has the same effect as setting
44 # PYTHON_NO_DEPENDS.
45 #
46 # If build, run and test are omitted, Python will be added as BUILD_DEPENDS,
47 # RUN_DEPENDS and TEST_DEPENDS.
48 # patch is independant, it does not prevent the default build/run/test
49 # dependency.
50 # env or PYTHON_NO_DEPENDS can be set to not add any dependencies.
51 #
52 # Exported variables:
53 #
54 # PYTHON_VERSION - The chosen Python interpreter including the version,
55 # e.g. python2.7, python3.5, etc.
56 #
57 # Variables, which can be set by the port:
58 #
59 # USE_PYTHON - A list of additional features and functionality to
60 # enable. Supported features are:
61 #
62 # concurrent - Indicates that the port can be installed for
63 # different python versions at the same time. The port
64 # is supposed to use a unique prefix for certain
65 # directories using USES=uniquefiles:dirs (see the
66 # uniquefiles.mk Uses for details about the
67 # directories), if set to yes. Binaries receive an
68 # additional suffix, based on ${PYTHON_VER}.
69 #
70 # The values for the uniquefiles USES are set as
71 # follows:
72 #
73 # UNIQUE_PREFIX= ${PYTHON_PKGNAMEPREFIX}
74 # UNIQUE_SUFFIX= -${PYTHON_VER}
75 #
76 # If the port is installed for the current default
77 # python version, scripts and binaries in
78 #
79 # ${PREFIX}/bin
80 # ${PREFIX}/sbin
81 # ${PREFIX}/libexec
82 #
83 # are linked from the prefixed version to the
84 # prefix-less original name, e.g.
85 # bin/foo-2.7 --> bin/foo.
86 #
87 # cython - Depend on lang/cython at build-time.
88 #
89 # cython_run - Depend on lang/cython at run-time.
90 #
91 # flavors - Force creation of flavors for Python 2 and 3 default
92 # versions, where applicable.
93 #
94 # noflavors - Disable automatic creation of flavors if they would
95 # otherwise be created and they are not wanted.
96 #
97 # allflavors - Generate flavors for all possible versions and not
98 # simply the default ones. Only to be used for py-*
99 # ports that are part of the Python distribution, but
100 # kept as separate ports.
101 #
102 # optsuffix - Set PKGNAMESUFFIX to PYTHON_PKGNAMESUFFIX if not the
103 # default python version.
104 #
105 # distutils - Use distutils as do-configure, do-build and
106 # do-install targets. implies flavors.
107 #
108 # autoplist - Automatically generates the packaging list for a
109 # port that uses distutils when defined.
110 # requires: distutils
111 #
112 # py3kplist - Automatically generates Python 3.x compatible
113 # __pycache__ entries from a Python 2.x packaging list
114 # when defined. Use this for ports that do *not* use
115 # standard Python packaging mechanisms such as
116 # distutils, and support *both* Python 2.x and 3.x.
117 # Not needed, if USE_PYTHON=autoplist is set.
118 #
119 # pythonprefix - Says that the port installs in ${PYTHONBASE} instead
120 # of ${PREFIX}.
121 #
122 # noegginfo - Skip an egg-info entry from plist, if defined.
123 #
124 # PYTHON_CMD - Python's command line file name, including the
125 # version number (used for dependencies).
126 # default: ${PYTHONBASE}/bin/${PYTHON_VERSION}
127 #
128 # PYSETUP - Name of the setup script used by the distutils
129 # package.
130 # default: setup.py
131 #
132 # PYDISTUTILS_PKGNAME
133 # - Internal name in the distutils for egg-info.
134 # default: ${PORTNAME}
135 #
136 # PYDISTUTILS_PKGVERSION
137 # - Internal version in the distutils for egg-info.
138 # default: ${PORTVERSION}
139 #
140 # PYDISTUTILS_CONFIGURE_TARGET
141 # - Pass this command to distutils on configure stage.
142 # default: config
143 #
144 # PYDISTUTILS_BUILD_TARGET
145 # - Pass this command to distutils on build stage.
146 # default: build
147 #
148 # PYDISTUTILS_INSTALL_TARGET
149 # - Pass this command to distutils on install stage.
150 # default: install
151 #
152 # PYDISTUTILS_CONFIGUREARGS
153 # - Arguments to config with distutils.
154 # default: <empty>
155 #
156 # PYDISTUTILS_BUILDARGS
157 # - Arguments to build with distutils.
158 # default: <empty>
159 #
160 # PYDISTUTILS_INSTALLARGS
161 # - Arguments to install with distutils.
162 # default: -c -O1 --prefix=${PREFIX} --single-version-externally-managed --root=${STAGEDIR}
163 #
164 # PYDISTUTILS_EGGINFO
165 # - Canonical name for egg-info.
166 # default: ${PYDISTUTILS_PKGNAME:C/[^A-Za-z0-9.]+/_/g}-${PYDISTUTILS_PKGVERSION:C/[^A-Za-z0-9.]+/_/g}-py${PYTHON_VER}.egg-info
167 #
168 # The following variables can be read by ports and must not be modified:
169 #
170 # PYTHONBASE - The installation prefix of the chosen Python
171 # interpreter, e.g. /usr/local
172 #
173 # PYTHON_PORTVERSION
174 # - Version number suitable for ${PORTVERSION}.
175 #
176 # PYTHON_PORTSDIR - The port directory of the chosen Python interpreter
177 #
178 # PYTHON_REL - The release number of the chosen Python interpreter
179 # without dots, e.g. 2706, 3401, ...
180 #
181 # PYTHON_SUFFIX - The major-minor release number of the chosen Python
182 # interpreter without dots, e.g. 27, 36, ...
183 # Used for prefixes and suffixes.
184 #
185 # PYTHON_MAJOR_VER - The major release version of the chosen Python
186 # interpreter, e.g. 2, 3, ...
187 #
188 # PYTHON_VER - The major-minor release version of the chosen Python
189 # interpreter, e.g. 2.7, 3.6, ...
190 #
191 # PYTHON_ABIVER - Additional ABI flags set by the chosen Python
192 # interpreter, e.g. md
193 #
194 # PYTHON_INCLUDEDIR - Location of the Python include files.
195 # default: ${PYTHONBASE}/include/${PYTHON_VERSION}
196 #
197 # PYTHON_LIBDIR - Base of the python library tree
198 # default: ${PYTHONBASE}/lib/${PYTHON_VERSION}
199 #
200 # PYTHON_SITELIBDIR - Location of the site-packages tree. Don't change,
201 # unless you know what you do.
202 # default: ${PYTHON_LIBDIR}/site-packages
203 #
204 # There are PREFIX-clean variants of the PYTHON_*DIR variables above.
205 # They are meant to be used by ports instead of the above variables, so the
206 # ports respect ${PREFIX} (unless USE_PYTHON=pythonprefix is specified).
207 #
208 # PYTHONPREFIX_INCLUDEDIR default: ${PREFIX}/include/${PYTHON_VERSION}
209 # PYTHONPREFIX_LIBDIR default: ${PREFIX}/lib/${PYTHON_VERSION}
210 # PYTHONPREFIX_SITELIBDIR default: ${PYTHONPREFIX_LIBDIR}/site-packages
211 #
212 # PYTHON_PLATFORM - Python's idea of the OS release.
213 # This is faked with ${OPSYS} and ${OSREL} until we
214 # find out how to delay defining a variable until
215 # after a certain target has been built.
216 #
217 # PYTHON_PKGNAMEPREFIX
218 # - Use this as a ${PKGNAMEPREFIX} to distinguish
219 # packages for different Python versions.
220 # default: py${PYTHON_SUFFIX}-
221 #
222 # PYTHON_PKGNAMESUFFIX
223 # - Use this as a ${PKGNAMESUFFIX} to distinguish
224 # packages for different Python versions.
225 # default: -py${PYTHON_SUFFIX}
226 #
227 # Using USES=python also will add some useful entries to PLIST_SUB:
228 #
229 # PYTHON_INCLUDEDIR=${PYTHONPREFIX_INCLUDEDIR:S;${PREFIX}/;;}
230 # PYTHON_LIBDIR=${PYTHONPREFIX_LIBDIR:S;${PREFIX}/;;}
231 # PYTHON_PLATFORM=${PYTHON_PLATFORM}
232 # PYTHON_SITELIBDIR=${PYTHONPREFIX_SITELIBDIR:S;${PREFIX}/;;}
233 # PYTHON_SUFFIX=${PYTHON_SUFFIX}
234 # PYTHON_VER=${PYTHON_VER}
235 # PYTHON_VERSION=${PYTHON_VERSION}
236 #
237 # and PYTHON2 and PYTHON3 will be set according to the Python version:
238 #
239 # PYTHON2="" PYTHON3="@comment " for Python 2.x
240 # PYTHON2="@comment " PYTHON3="" for Python 3.x
241 #
242 # PYDISTUTILS_INSTALLNOSINGLE
243 # - Deprecated without replacement
244 #
245 # MAINTAINER: python@FreeBSD.org
246
247 .if !defined(_INCLUDE_USES_PYTHON_MK)
248 _INCLUDE_USES_PYTHON_MK= yes
249
250 # What Python version and what Python interpreters are currently supported?
251 # When adding a version, please keep the comment in
252 # Mk/bsd.default-versions.mk in sync.
253 _PYTHON_VERSIONS= 2.7 3.7 3.8 3.9 3.6 # preferred first
254 _PYTHON_PORTBRANCH= 2.7 # ${_PYTHON_VERSIONS:[1]}
255 _PYTHON_BASECMD= ${LOCALBASE}/bin/python
256 _PYTHON_RELPORTDIR= lang/python
257
258 # List all valid USE_PYTHON features here
259 _VALID_PYTHON_FEATURES= allflavors autoplist concurrent cython cython_run \
260 distutils flavors noegginfo noflavors optsuffix \
261 py3kplist pythonprefix
262 _INVALID_PYTHON_FEATURES=
263 .for var in ${USE_PYTHON}
264 . if empty(_VALID_PYTHON_FEATURES:M${var})
265 _INVALID_PYTHON_FEATURES+= ${var}
266 . endif
267 .endfor
268 .if !empty(_INVALID_PYTHON_FEATURES)
269 IGNORE= uses unknown USE_PYTHON features: ${_INVALID_PYTHON_FEATURES}
270 .endif
271
272 # Make each individual feature available as _PYTHON_FEATURE_<FEATURENAME>
273 .for var in ${USE_PYTHON}
274 _PYTHON_FEATURE_${var:C/=.*$//:tu}= ${var:C/.*=//:S/,/ /g}
275 .endfor
276
277 # distutils automatically generates flavors depending on the supported
278 # versions.
279 .if defined(_PYTHON_FEATURE_DISTUTILS)
280 _PYTHON_FEATURE_FLAVORS= yes
281 .endif
282
283 .if defined(_PYTHON_FEATURE_NOFLAVORS)
284 .undef _PYTHON_FEATURE_FLAVORS
285 .endif
286
287 # Make sure that no dependency or some other environment variable
288 # pollutes the build/run dependency detection
289 .undef _PYTHON_BUILD_DEP
290 .undef _PYTHON_RUN_DEP
291 .undef _PYTHON_TEST_DEP
292 _PYTHON_ARGS= ${python_ARGS:S/,/ /g}
293 .if ${_PYTHON_ARGS:Mpatch}
294 _PYTHON_PATCH_DEP= yes
295 _PYTHON_ARGS:= ${_PYTHON_ARGS:Npatch}
296 .endif
297 .if ${_PYTHON_ARGS:Mbuild}
298 _PYTHON_BUILD_DEP= yes
299 _PYTHON_ARGS:= ${_PYTHON_ARGS:Nbuild}
300 .endif
301 .if ${_PYTHON_ARGS:Mrun}
302 _PYTHON_RUN_DEP= yes
303 _PYTHON_ARGS:= ${_PYTHON_ARGS:Nrun}
304 .endif
305 .if ${_PYTHON_ARGS:Mtest}
306 _PYTHON_TEST_DEP= yes
307 _PYTHON_ARGS:= ${_PYTHON_ARGS:Ntest}
308 .endif
309 .if ${_PYTHON_ARGS:Menv}
310 PYTHON_NO_DEPENDS= yes
311 _PYTHON_ARGS:= ${_PYTHON_ARGS:Nenv}
312 .endif
313
314 # The port does not specify a build, run or test dependency, assume all are
315 # required.
316 .if !defined(_PYTHON_BUILD_DEP) && !defined(_PYTHON_RUN_DEP) && \
317 !defined(_PYTHON_TEST_DEP) && !defined(PYTHON_NO_DEPENDS)
318 _PYTHON_BUILD_DEP= yes
319 _PYTHON_RUN_DEP= yes
320 _PYTHON_TEST_DEP= yes
321 .endif
322
323 .if ${PYTHON2_DEFAULT} != ${PYTHON_DEFAULT} && ${PYTHON3_DEFAULT} != ${PYTHON_DEFAULT}
324 WARNING+= "PYTHON_DEFAULT must be a version present in PYTHON2_DEFAULT or PYTHON3_DEFAULT, if you want more Python flavors, set BUILD_ALL_PYTHON_FLAVORS in your make.conf"
325 .endif
326
327 .if ${_PYTHON_ARGS} == 2.7
328 DEV_WARNING+= "lang/python27 reached End of Life and will be removed on 2020-12-31, consider converting to a modern version of python"
329 .elif ${_PYTHON_ARGS} == 2
330 DEV_ERROR+= "USES=python:2 is no longer supported, use USES=python:2.7"
331 .elif ${_PYTHON_ARGS} == 3
332 DEV_ERROR+= "USES=python:3 is no longer supported, use USES=python:3.6+ or an appropriate version range"
333 .endif # ${_PYTHON_ARGS} == 2.7
334
335 _PYTHON_VERSION:= ${PYTHON_DEFAULT}
336
337 .if empty(_PYTHON_ARGS)
338 _PYTHON_ARGS= 3.6+
339 .endif
340
341 # Validate Python version whether it meets the version restriction.
342 _PYTHON_VERSION_CHECK:= ${_PYTHON_ARGS:C/^([1-9]\.[0-9])$/\1-\1/}
343 _PYTHON_VERSION_MINIMUM_TMP:= ${_PYTHON_VERSION_CHECK:C/([1-9]\.[0-9])[-+].*/\1/}
344 _PYTHON_VERSION_MINIMUM:= ${_PYTHON_VERSION_MINIMUM_TMP:M[1-9].[0-9]}
345 _PYTHON_VERSION_MAXIMUM_TMP:= ${_PYTHON_VERSION_CHECK:C/.*-([1-9]\.[0-9])/\1/}
346 _PYTHON_VERSION_MAXIMUM:= ${_PYTHON_VERSION_MAXIMUM_TMP:M[1-9].[0-9]}
347
348 # At this point we should have no argument left in ${_PYTHON_ARGS}
349 # except a version spec
350 _PYTHON_ARGS:= ${_PYTHON_ARGS:N[1-9].[0-9]-[1-9].[0-9]:N[1-9].[0-9]:N[1-9].[0-9]+:N-[1-9].[0-9]}
351 .if !empty(_PYTHON_ARGS)
352 IGNORE= uses unknown USES=python arguments: ${_PYTHON_ARGS}
353 .endif
354
355 .undef _PYTHON_VERSION_NONSUPPORTED
356 .if !empty(_PYTHON_VERSION_MINIMUM) && (${_PYTHON_VERSION} < ${_PYTHON_VERSION_MINIMUM})
357 _PYTHON_VERSION_NONSUPPORTED= ${_PYTHON_VERSION_MINIMUM} at least
358 .elif !empty(_PYTHON_VERSION_MAXIMUM) && (${_PYTHON_VERSION} > ${_PYTHON_VERSION_MAXIMUM})
359 _PYTHON_VERSION_NONSUPPORTED= ${_PYTHON_VERSION_MAXIMUM} at most
360 .endif
361
362 # If we have an unsupported version of Python, try another.
363 .if defined(_PYTHON_VERSION_NONSUPPORTED)
364 .undef _PYTHON_VERSION
365 .for ver in ${PYTHON2_DEFAULT} ${PYTHON3_DEFAULT} ${_PYTHON_VERSIONS}
366 __VER= ${ver}
367 .if !defined(_PYTHON_VERSION) && \
368 !(!empty(_PYTHON_VERSION_MINIMUM) && ( \
369 ${__VER} < ${_PYTHON_VERSION_MINIMUM})) && \
370 !(!empty(_PYTHON_VERSION_MAXIMUM) && ( \
371 ${__VER} > ${_PYTHON_VERSION_MAXIMUM}))
372 _PYTHON_VERSION= ${ver}
373 .endif
374 .endfor
375 .if !defined(_PYTHON_VERSION)
376 IGNORE= needs an unsupported version of Python
377 .endif
378 .endif # defined(_PYTHON_VERSION_NONSUPPORTED)
379
380 # Automatically generates FLAVORS if empty
381 .if empty(FLAVORS) && defined(_PYTHON_FEATURE_FLAVORS)
382 . undef _VALID_PYTHON_VERSIONS
383 . for ver in ${PYTHON_DEFAULT} ${PYTHON2_DEFAULT} ${PYTHON3_DEFAULT} ${_PYTHON_VERSIONS}
384 __VER= ${ver}
385 . if !(!empty(_PYTHON_VERSION_MINIMUM) && ( \
386 ${__VER} < ${_PYTHON_VERSION_MINIMUM})) && \
387 !(!empty(_PYTHON_VERSION_MAXIMUM) && ( \
388 ${__VER} > ${_PYTHON_VERSION_MAXIMUM}))
389 . if empty(_VALID_PYTHON_VERSIONS:M${ver})
390 _VALID_PYTHON_VERSIONS+= ${ver}
391 . endif
392 . endif
393 . endfor
394 # Get all possible flavors depending on version requirements
395 . if defined(_VALID_PYTHON_VERSIONS)
396 _ALL_PYTHON_FLAVORS= ${_VALID_PYTHON_VERSIONS:S/.//:S/^/py/}
397 . else
398 _ALL_PYTHON_FLAVORS= ${_PYTHON_VERSIONS:S/.//:S/^/py/}
399 . endif
400 # Decide how many flavors we want. By default, only generate the default
401 # versions.
402 . if defined(BUILD_ALL_PYTHON_FLAVORS) || defined(_PYTHON_FEATURE_ALLFLAVORS)
403 FLAVORS= ${_ALL_PYTHON_FLAVORS}
404 . else
405 . for _v in ${PYTHON_DEFAULT} ${PYTHON2_DEFAULT} ${PYTHON3_DEFAULT}
406 _f= py${_v:S/.//}
407 . if ${_ALL_PYTHON_FLAVORS:M${_f}} && !${FLAVORS:M${_f}}
408 .if !empty(FLAVORS)
409 FLAVORS:= ${FLAVORS} ${_f}
410 .else
411 FLAVORS:= ${_f}
412 .endif
413 . endif
414 . endfor
415 . endif
416 . if !empty(FLAVORS) && empty(FLAVOR)
417 FLAVOR= ${FLAVORS:[1]}
418 . endif
419 .endif
420
421 .if ${FLAVOR:Mpy[23][0-9]}
422 _PYTHON_VERSION= ${FLAVOR:S/py//:C/(.)/\1./}
423 .endif
424
425 .if !empty(FLAVOR) && ${_PYTHON_VERSION} != ${PYTHON_DEFAULT}
426 .if defined(_PYTHON_FEATURE_OPTSUFFIX)
427 DEV_WARNING+= "USE_PYTHON=optsuffix is deprecated, consider migrating to using unconditional PKGNAMESUFFIX or PKGNAMEPREFIX"
428 PKGNAMESUFFIX= ${PYTHON_PKGNAMESUFFIX}
429 .endif
430 .endif
431
432 # To avoid having dependencies with @ and empty flavor:
433 # _PYTHON_VERSION is either set by (first that matches):
434 # - If using Python flavors, from the current Python flavor
435 # - If using a version restriction (USES=python:3.6+), from the first
436 # acceptable default Python version.
437 # - From PYTHON_DEFAULT
438 PY_FLAVOR= py${_PYTHON_VERSION:S/.//}
439
440 PYTHON_VERSION= python${_PYTHON_VERSION}
441
442 # Got the correct python version, set some publicly accessible variables
443 PYTHON_VER= ${_PYTHON_VERSION}
444 PYTHON_SUFFIX= ${_PYTHON_VERSION:S/.//g}
445 PYTHON_MAJOR_VER= ${PYTHON_VER:R}
446 PYTHON_REL= # empty
447 PYTHON_ABIVER= # empty
448 PYTHON_PORTSDIR= ${_PYTHON_RELPORTDIR}${PYTHON_SUFFIX}
449
450 .if ${PYTHON_VER} >= 3.8
451 PYTHON_EXT_SUFFIX= .cpython-${PYTHON_SUFFIX}
452 .else
453 PYTHON_EXT_SUFFIX= # empty
454 .endif
455
456 # Protect partial checkouts from Mk/Scripts/functions.sh:export_ports_env().
457 .if !defined(_PORTS_ENV_CHECK) || exists(${PORTSDIR}/${PYTHON_PORTSDIR})
458 .include "${PORTSDIR}/${PYTHON_PORTSDIR}/Makefile.version"
459 .endif
460 # Create a 4 integer version string, prefixing 0 to the last token if
461 # it's a single character. Only use the the first 3 tokens of
462 # PORTVERSION to support pre-release versions (rc3, alpha4, etc) of
463 # any Python port (lang/pythonXY)
464 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}
465
466 # Might be overridden by calling ports
467 PYTHON_CMD?= ${_PYTHON_BASECMD}${_PYTHON_VERSION}
468 .if ${PYTHON_VER} != 2.7
469 .if exists(${PYTHON_CMD}-config)
470 PYTHON_ABIVER!= ${PYTHON_CMD}-config --abiflags
471 .elif ${PYTHON_REL} < 3800
472 # Default ABI flags for lang/python3[67] ports
473 PYTHON_ABIVER= m
474 .endif
475 .endif
476
477 .if ${PYTHON_MAJOR_VER} == 2
478 DEPRECATED?= Uses Python 2.7 which is EOLed upstream
479 EXPIRATION_DATE?= 2020-12-31
480 .endif
481
482 .if !defined(PYTHONBASE)
483 PYTHONBASE!= (${PYTHON_CMD} -c 'import sys; print(sys.prefix)' \
484 2> /dev/null || ${ECHO_CMD} ${LOCALBASE}) | ${TAIL} -1
485 .endif
486 _EXPORTED_VARS+= PYTHONBASE
487
488 PYTHON_INCLUDEDIR= ${PYTHONBASE}/include/python${_PYTHON_VERSION}${PYTHON_ABIVER}
489 PYTHON_LIBDIR= ${PYTHONBASE}/lib/python${_PYTHON_VERSION}
490 PYTHON_PLATFORM= ${OPSYS:tl}${OSREL:C/\.[0-9.]*//}
491 PYTHON_SITELIBDIR= ${PYTHON_LIBDIR}/site-packages
492 PYTHON_PKGNAMEPREFIX= py${PYTHON_SUFFIX}-
493 PYTHON_PKGNAMESUFFIX= -py${PYTHON_SUFFIX}
494
495 PYTHONPREFIX_INCLUDEDIR= ${PYTHON_INCLUDEDIR:S;${PYTHONBASE};${PREFIX};}
496 PYTHONPREFIX_LIBDIR= ${PYTHON_LIBDIR:S;${PYTHONBASE};${PREFIX};}
497 PYTHONPREFIX_SITELIBDIR= ${PYTHON_SITELIBDIR:S;${PYTHONBASE};${PREFIX};}
498
499 # Used for recording the installed files.
500 _PYTHONPKGLIST= ${WRKDIR}/.PLIST.pymodtmp
501
502 # Ports bound to a certain python version SHOULD
503 # - use the PYTHON_PKGNAMEPREFIX
504 # - use directories using the PYTHON_PKGNAMEPREFIX
505 # - install binaries using the required PYTHON_VER, with
506 # the default python version creating a symlink to the original binary
507 # name (for staging-aware ports).
508 #
509 # What makes a port 'bound' to a certain python version?
510 # - it installs data into PYTHON_SITELIBDIR, PYTHON_INCLUDEDIR, ...
511 # - it links against libpython*.so
512 # - it uses USE_PYTHON=distutils
513 #
514
515 .if defined(_PYTHON_FEATURE_CYTHON)
516 BUILD_DEPENDS+= cython-${PYTHON_VER}:lang/cython@${PY_FLAVOR}
517 .endif
518
519 .if defined(_PYTHON_FEATURE_CYTHON_RUN)
520 RUN_DEPENDS+= cython-${PYTHON_VER}:lang/cython@${PY_FLAVOR}
521 .endif
522
523 .if defined(_PYTHON_FEATURE_CONCURRENT)
524 .if !defined(_PYTHON_FEATURE_FLAVORS) && (${_PYTHON_VERSION_MINIMUM:M3*} || ${_PYTHON_VERSION_MAXIMUM:M2*})
525 DEV_WARNING+= "USE_PYTHON=concurrent when only one of Python 2 or 3 is supported AND not using flavors does not make any sense"
526 .endif
527 _USES_POST+= uniquefiles:dirs
528 .if defined(_PYTHON_FEATURE_FLAVORS) && ${FLAVOR} == ${FLAVORS:[1]}
529 UNIQUE_DEFAULT_LINKS= yes
530 .elif !defined(_PYTHON_FEATURE_FLAVORS) && ${_PYTHON_VERSION} == ${PYTHON_DEFAULT}
531 UNIQUE_DEFAULT_LINKS= yes
532 .else
533 UNIQUE_DEFAULT_LINKS= no
534 .endif
535 UNIQUE_PREFIX= ${PYTHON_PKGNAMEPREFIX}
536 UNIQUE_SUFFIX= -${PYTHON_VER}
537 UNIQUE_SUFFIX_TYPES+= SUFFIX_MAN
538 UNIQUE_SUFFIX_MAN_WITH_EXT= .[1-9ln]
539 UNIQUE_SUFFIX_MAN_EXTRA_EXT= .gz
540
541 .if defined(_PYTHON_FEATURE_AUTOPLIST)
542 _UNIQUE_FIND_SUFFIX_FILES= ${SED} -e 's|^${PREFIX}/||' ${_PYTHONPKGLIST} ${TMPPLIST}
543 .else
544 _UNIQUE_FIND_SUFFIX_FILES= ${SED} -e 's|^${PREFIX}/||' ${TMPPLIST} 2>/dev/null
545 .endif
546 UNIQUE_FIND_SUFFIX_FILES+= ${_UNIQUE_FIND_SUFFIX_FILES} | \
547 ${EGREP} -he '^bin/.*$$|^sbin/.*$$|^libexec/.*$$'
548 UNIQUE_FIND_SUFFIX_MAN_FILES+= ${_UNIQUE_FIND_SUFFIX_FILES} | \
549 ${EGREP} -he '^man/man[1-9ln]/.*$$|^share/man/man[1-9ln]/.*$$'
550 .endif # defined(_PYTHON_FEATURE_CONCURRENT)
551
552 _CURRENTPORT:= ${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}
553 .if defined(_PYTHON_FEATURE_DISTUTILS) && \
554 ${_CURRENTPORT} != ${PYTHON_PKGNAMEPREFIX}setuptools
555 BUILD_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}setuptools>0:devel/py-setuptools@${PY_FLAVOR}
556 RUN_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}setuptools>0:devel/py-setuptools@${PY_FLAVOR}
557 .endif
558
559 # distutils support
560 PYSETUP?= setup.py
561 PYDISTUTILS_SETUP?= -c \
562 "import sys; import setuptools; \
563 __file__='${PYSETUP}'; sys.argv[0]='${PYSETUP}'; \
564 exec(compile(open(__file__, 'rb').read().replace(b'\\r\\n', b'\\n'), __file__, 'exec'))"
565 PYDISTUTILS_CONFIGUREARGS?= # empty
566 PYDISTUTILS_BUILDARGS?= # empty
567 PYDISTUTILS_INSTALLARGS?= -c -O1 --prefix=${PREFIX}
568 .if defined(_PYTHON_FEATURE_DISTUTILS)
569 . if !defined(PYDISTUTILS_INSTALLNOSINGLE)
570 PYDISTUTILS_INSTALLARGS+= --single-version-externally-managed
571 . endif
572 PYDISTUTILS_INSTALLARGS+= --root=${STAGEDIR}
573 .endif
574 PYDISTUTILS_INSTALLARGS:= --record ${_PYTHONPKGLIST} \
575 ${PYDISTUTILS_INSTALLARGS}
576
577 PYDISTUTILS_PKGNAME?= ${PORTNAME}
578 PYDISTUTILS_PKGVERSION?=${PORTVERSION}
579 PYDISTUTILS_EGGINFO?= ${PYDISTUTILS_PKGNAME:C/[^A-Za-z0-9.]+/_/g}-${PYDISTUTILS_PKGVERSION:C/[^A-Za-z0-9.]+/_/g}-py${PYTHON_VER}.egg-info
580 PYDISTUTILS_EGGINFODIR?=${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}
581
582 .if !defined(_PYTHON_FEATURE_NOEGGINFO) && \
583 !defined(_PYTHON_FEATURE_AUTOPLIST) && \
584 defined(_PYTHON_FEATURE_DISTUTILS) && \
585 defined(PYTHON_REL)
586 _USES_stage+= 933:add-plist-egginfo
587 add-plist-egginfo:
588 . for egginfo in ${PYDISTUTILS_EGGINFO}
589 if [ -d "${PYDISTUTILS_EGGINFODIR}/${egginfo}" ]; then \
590 ${LS} ${PYDISTUTILS_EGGINFODIR}/${egginfo} | while read f; do \
591 ${ECHO_CMD} ${PYDISTUTILS_EGGINFODIR:S;^${STAGEDIR}${PREFIX}/;;}/${egginfo}/$${f} >> ${TMPPLIST}; \
592 done; \
593 fi;
594 . endfor
595 .endif
596
597 .if defined(_PYTHON_FEATURE_AUTOPLIST) && defined(_PYTHON_FEATURE_DISTUTILS)
598 _RELSITELIBDIR= ${PYTHONPREFIX_SITELIBDIR:S;${PREFIX}/;;}
599 _RELLIBDIR= ${PYTHONPREFIX_LIBDIR:S;${PREFIX}/;;}
600
601 _USES_stage+= 934:add-plist-pymod
602 add-plist-pymod:
603 @${SED} -e 's|^"\(.*\)"$$|\1|' \
604 -e 's|^${STAGEDIR}${PREFIX}/||' \
605 -e 's|^${PREFIX}/||' \
606 -e 's|^\(man/.*man[0-9]\)/\(.*\.[0-9]\)$$|\1/\2.gz|' \
607 -e 's|^\(share/man/.*man[0-9]\)/\(.*\.[0-9]\)$$|\1/\2.gz|' \
608 -e 's|[[:alnum:]|[:space:]]*/\.\./*||g; s|/\./|/|g' \
609 ${_PYTHONPKGLIST} | ${SORT} >> ${TMPPLIST}
610
611 .else
612 .if ${PYTHON_REL} >= 3200 && defined(_PYTHON_FEATURE_PY3KPLIST)
613 # When Python version is 3.2+ we rewrite all the filenames
614 # of TMPPLIST that end with .py[co], so that they conform
615 # to PEP 3147 (see https://www.python.org/dev/peps/pep-3147/)
616 PYMAGICTAG= ${PYTHON_CMD} -c 'import sys; print(sys.implementation.cache_tag)'
617 _USES_stage+= 935:add-plist-python
618 add-plist-python:
619 @${AWK} '\
620 /\.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} \
621 /^@dirrm / {d = substr($$0, 8); if (d in dirs) {print $$0 "/" pc}; print $$0; next} \
622 /^@dirrmtry / {d = substr($$0, 11); if (d in dirs) {print $$0 "/" pc}; print $$0; next} \
623 {print} \
624 ' \
625 pc="__pycache__" mt="$$(${PYMAGICTAG})" pyo="opt-1.pyc" \
626 ${TMPPLIST} > ${TMPPLIST}.pyc_tmp
627 @${MV} ${TMPPLIST}.pyc_tmp ${TMPPLIST}
628 .endif # ${PYTHON_REL} >= 3200 && defined(_PYTHON_FEATURE_PY3KPLIST)
629 .endif # defined(_PYTHON_FEATURE_AUTOPLIST) && defined(_PYTHON_FEATURE_DISTUTILS)
630
631 # Fix for programs that build python from a GNU auto* environment
632 CONFIGURE_ENV+= PYTHON="${PYTHON_CMD}"
633
634 # By default CMake picks up the highest available version of Python package.
635 # Enforce the version required by the port or the default.
636 CMAKE_ARGS+= -DPython_ADDITIONAL_VERSIONS=${PYTHON_VER}
637
638 # Python 3rd-party modules
639 PYGAME= ${PYTHON_PKGNAMEPREFIX}game>0:devel/py-game@${PY_FLAVOR}
640 PYNUMPY= ${PYTHON_PKGNAMEPREFIX}numpy>=1.16,1<1.20,1:math/py-numpy@${PY_FLAVOR}
641
642 # Common Python modules that can be needed but only for some versions of Python.
643 .if ${PYTHON_REL} < 3500
644 PY_PYGMENTS= ${PYTHON_PKGNAMEPREFIX}pygments-25>=2.5.1<3:textproc/py-pygments-25@${PY_FLAVOR}
645 .else
646 PY_PILLOW= ${PYTHON_PKGNAMEPREFIX}pillow>=7.0.0:graphics/py-pillow@${PY_FLAVOR}
647 PY_PYGMENTS= ${PYTHON_PKGNAMEPREFIX}pygments>=2.5.1<3:textproc/py-pygments@${PY_FLAVOR}
648 .endif
649
650 .if ${PYTHON_REL} < 3400
651 PY_ENUM34= ${PYTHON_PKGNAMEPREFIX}enum34>=1.1<2.0:devel/py-enum34@${PY_FLAVOR}
652 .else
653 PY_ENUM34=
654 .endif
655
656 .if ${PYTHON_VER} != ${PYTHON_DEFAULT}
657 PY_MERCURIAL= ${PYTHON_PKGNAMEPREFIX}mercurial>=5.5:devel/mercurial@${PY_FLAVOR}
658 .else
659 PY_MERCURIAL= mercurial>=5.5:devel/mercurial@${PY_FLAVOR}
660 .endif
661
662 CMAKE_ARGS+= -DBOOST_PYTHON_SUFFIX:STRING=${PYTHON_SUFFIX}
663 PY_BOOST_LIB= boost_python${PYTHON_SUFFIX}
664 PY_BOOST= lib${PY_BOOST_LIB}.so:devel/boost-python-libs@${PY_FLAVOR}
665
666 # dependencies
667 .for _stage in PATCH BUILD RUN TEST
668 . if defined(_PYTHON_${_stage}_DEP)
669 ${_stage}_DEPENDS+= ${PYTHON_CMD}:${PYTHON_PORTSDIR}
670 . endif
671 .endfor
672
673 # set $PREFIX as Python's one
674 .if defined(_PYTHON_FEATURE_PYTHONPREFIX)
675 PREFIX= ${PYTHONBASE}
676 .endif
677
678 # Substitutions for pkg-plist
679 # Use a short form of the PYTHONPREFIX_*DIR variables; we don't need the
680 # base directory in the plist file.
681 PLIST_SUB+= PYTHON_INCLUDEDIR=${PYTHONPREFIX_INCLUDEDIR:S;${PREFIX}/;;} \
682 PYTHON_LIBDIR=${PYTHONPREFIX_LIBDIR:S;${PREFIX}/;;} \
683 PYTHON_PLATFORM=${PYTHON_PLATFORM} \
684 PYTHON_SITELIBDIR=${PYTHONPREFIX_SITELIBDIR:S;${PREFIX}/;;} \
685 PYTHON_SUFFIX=${PYTHON_SUFFIX} \
686 PYTHON_EXT_SUFFIX=${PYTHON_EXT_SUFFIX} \
687 PYTHON_VER=${PYTHON_VER} \
688 PYTHON_VERSION=${PYTHON_VERSION}
689 .if ${PYTHON_REL} < 3000
690 PLIST_SUB+= PYTHON2="" PYTHON3="@comment "
691 .else
692 PLIST_SUB+= PYTHON2="@comment " PYTHON3=""
693 .endif
694
695 _USES_POST+= python
696 .endif # _INCLUDE_USES_PYTHON_MK
697
698 .if defined(_POSTMKINCLUDED) && !defined(_INCLUDE_USES_PYTHON_POST_MK)
699 _INCLUDE_USES_PYTHON_POST_MK= yes
700
701 # py-distutils support
702 PYDISTUTILS_CONFIGURE_TARGET?= config
703 PYDISTUTILS_BUILD_TARGET?= build
704 PYDISTUTILS_INSTALL_TARGET?= install
705
706 .if defined(_PYTHON_FEATURE_DISTUTILS)
707 LDSHARED?= ${CC} -shared
708 MAKE_ENV+= LDSHARED="${LDSHARED}" PYTHONDONTWRITEBYTECODE= PYTHONOPTIMIZE=
709
710 .if !target(do-configure) && !defined(HAS_CONFIGURE) && !defined(GNU_CONFIGURE)
711 do-configure:
712 @(cd ${BUILD_WRKSRC}; ${SETENV} ${MAKE_ENV} ${PYTHON_CMD} ${PYDISTUTILS_SETUP} ${PYDISTUTILS_CONFIGURE_TARGET} ${PYDISTUTILS_CONFIGUREARGS})
713 .endif
714
715 .if !target(do-build)
716 do-build:
717 @(cd ${BUILD_WRKSRC}; ${SETENV} ${MAKE_ENV} ${PYTHON_CMD} ${PYDISTUTILS_SETUP} ${PYDISTUTILS_BUILD_TARGET} ${PYDISTUTILS_BUILDARGS})
718 .endif
719
720 .if !target(do-install)
721 do-install:
722 @(cd ${INSTALL_WRKSRC}; ${SETENV} ${MAKE_ENV} ${PYTHON_CMD} ${PYDISTUTILS_SETUP} ${PYDISTUTILS_INSTALL_TARGET} ${PYDISTUTILS_INSTALLARGS})
723 .endif
724 .endif # defined(_PYTHON_FEATURE_DISTUTILS)
725 .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