Annotation of pkgsrc/lang/python/extension.mk, revision 1.67
1.67 ! tnn 1: # $NetBSD: extension.mk,v 1.66 2025/01/07 19:35:08 riastradh Exp $
1.1 jlam 2:
3: .include "../../lang/python/pyversion.mk"
4:
1.27 gdt 5: # This mk fragment is included to handle packages that create
6: # extensions to python, which by definition are those that place files
7: # in ${PYSITELIB}. Extensions can be implemented via setuptools as
1.59 wiz 8: # eggs (see egg.mk), via wheels (see wheel.mk), or via more ad hoc
9: # methods.
1.65 wiz 10: #
11: # Do not included this file directly, use wheel.mk.
1.27 gdt 12:
1.60 nia 13: .if !empty(PYDISTUTILSPKG:M[yY][eE][sS])
1.15 joerg 14:
1.1 jlam 15: PYSETUP?= setup.py
1.25 wiz 16: PYSETUPBUILDTARGET?= build
1.55 adam 17: PYSETUPBUILDARGS?= # empty
1.52 adam 18: # Python 3.5+ supports parallel building
1.56 wiz 19: . if defined(MAKE_JOBS) && ${_PYTHON_VERSION} != 27
1.55 adam 20: . if !defined(MAKE_JOBS_SAFE) || empty(MAKE_JOBS_SAFE:M[nN][oO])
1.52 adam 21: PYSETUPBUILDARGS+= -j${MAKE_JOBS}
1.55 adam 22: . endif
1.52 adam 23: . endif
1.66 riastrad 24: . if ${USE_CROSS_COMPILE:tl} == "yes"
1.61 riastrad 25: PYSETUPBUILDARGS+= --executable=${PYTHONBIN:Q}
26: . endif
1.55 adam 27: PYSETUPARGS?= # empty
28: PYSETUPINSTALLARGS?= # empty
1.5 recht 29: PYSETUPOPTARGS?= -c -O1
1.16 joerg 30: _PYSETUPINSTALLARGS= ${PYSETUPINSTALLARGS} ${PYSETUPOPTARGS} ${_PYSETUPTOOLSINSTALLARGS}
1.15 joerg 31: _PYSETUPINSTALLARGS+= --root=${DESTDIR:Q}
1.33 wiz 32: PY_PATCHPLIST?= yes
1.32 tron 33: PYSETUPTESTTARGET?= test
1.55 adam 34: PYSETUPTESTARGS?= # empty
35: PYSETUPSUBDIR?= # empty
1.1 jlam 36:
37: do-build:
1.61 riastrad 38: (cd ${WRKSRC}/${PYSETUPSUBDIR} && ${SETENV} ${MAKE_ENV} \
39: ${TOOL_PYTHONBIN} ${PYSETUP} ${PYSETUPARGS} ${PYSETUPBUILDTARGET} \
40: ${PYSETUPBUILDARGS})
1.1 jlam 41:
42: do-install:
1.18 tnn 43: (cd ${WRKSRC}/${PYSETUPSUBDIR} && ${SETENV} ${INSTALL_ENV} ${MAKE_ENV} \
1.61 riastrad 44: ${TOOL_PYTHONBIN} ${PYSETUP} ${PYSETUPARGS} "install" \
45: ${_PYSETUPINSTALLARGS})
1.55 adam 46:
1.48 rillig 47: . if !target(do-test) && !(defined(TEST_TARGET) && !empty(TEST_TARGET))
1.32 tron 48: do-test:
1.61 riastrad 49: (cd ${WRKSRC}/${PYSETUPSUBDIR} && ${SETENV} ${TEST_ENV} \
50: ${TOOL_PYTHONBIN} ${PYSETUP} ${PYSETUPARGS} ${PYSETUPTESTTARGET} \
51: ${PYSETUPTESTARGS})
1.48 rillig 52: . endif
1.32 tron 53:
1.1 jlam 54: .endif
55:
56: .if defined(PY_PATCHPLIST)
1.29 obache 57: PLIST_SUBST+= PYINC=${PYINC} PYLIB=${PYLIB} PYSITELIB=${PYSITELIB}
1.49 wiz 58: PLIST_SUBST+= PYVERSSUFFIX=${PYVERSSUFFIX}
1.1 jlam 59: .endif
1.30 obache 60:
1.49 wiz 61: # mostly for ALTERNATIVES files
62: FILES_SUBST+= PYVERSSUFFIX=${PYVERSSUFFIX}
63:
1.59 wiz 64: # Python>=3.2 bytecode file location change
1.35 obache 65: # http://www.python.org/dev/peps/pep-3147/
1.36 wiz 66: .if empty(_PYTHON_VERSION:M2?)
1.48 rillig 67: PLIST_AWK+= -f ${PKGSRCDIR}/lang/python/plist-python.awk
68: PLIST_AWK_ENV+= PYVERS="${PYVERSSUFFIX:S/.//}"
1.57 leot 69: EARLY_PRINT_PLIST_AWK+= /^[^@]/ && /[^\/]+\.py[co]$$/ {
70: EARLY_PRINT_PLIST_AWK+= gsub(/__pycache__\//, "")
71: EARLY_PRINT_PLIST_AWK+= gsub(/opt-1\.pyc$$/, "pyo")
72: EARLY_PRINT_PLIST_AWK+= gsub(/\.cpython-${_PYTHON_VERSION}/, "")}
1.63 wiz 73: PRINT_PLIST_AWK+= /bin\// { sub(/${PYVERSSUFFIX}/, "$${PYVERSSUFFIX}") }
74: PRINT_PLIST_AWK+= /man\// { sub(/${PYVERSSUFFIX}/, "$${PYVERSSUFFIX}") }
1.64 wiz 75: PRINT_PLIST_AWK+= /share\/doc\// { sub(/${PYVERSSUFFIX}/, "$${PYVERSSUFFIX}") }
1.30 obache 76: .endif
1.51 joerg 77:
1.59 wiz 78: # For running tests before installation of the package,
79: # this is sometimes needed; or setting
80: # TEST_ENV+= PYTHONPATH=${WRKSRC}/build/lib
81:
1.51 joerg 82: DISTUTILS_BUILDDIR_IN_TEST_ENV?= no
83:
84: .if ${DISTUTILS_BUILDDIR_IN_TEST_ENV} == "yes"
1.61 riastrad 85: DISTUTILS_BUILDDIR_CMD= cd ${WRKSRC} && ${TOOL_PYTHONBIN} ${.CURDIR}/../../lang/python/distutils-builddir.py
1.51 joerg 86: TEST_ENV+= PYTHONPATH=${DISTUTILS_BUILDDIR_CMD:sh}
87: .endif
CVSweb <webmaster@jp.NetBSD.org>