Annotation of pkgsrc/lang/python/extension.mk, revision 1.66

1.66    ! riastrad    1: # $NetBSD: extension.mk,v 1.65 2023/10/29 17:07:15 wiz 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: .include "../../mk/bsd.prefs.mk"
                     15: 
1.1       jlam       16: PYSETUP?=              setup.py
1.25      wiz        17: PYSETUPBUILDTARGET?=   build
1.55      adam       18: PYSETUPBUILDARGS?=     # empty
1.52      adam       19: # Python 3.5+ supports parallel building
1.56      wiz        20: .  if defined(MAKE_JOBS) && ${_PYTHON_VERSION} != 27
1.55      adam       21: .    if !defined(MAKE_JOBS_SAFE) || empty(MAKE_JOBS_SAFE:M[nN][oO])
1.52      adam       22: PYSETUPBUILDARGS+=     -j${MAKE_JOBS}
1.55      adam       23: .    endif
1.52      adam       24: .  endif
1.66    ! riastrad   25: .  if ${USE_CROSS_COMPILE:tl} == "yes"
1.61      riastrad   26: PYSETUPBUILDARGS+=     --executable=${PYTHONBIN:Q}
                     27: .  endif
1.55      adam       28: PYSETUPARGS?=          # empty
                     29: PYSETUPINSTALLARGS?=   # empty
1.5       recht      30: PYSETUPOPTARGS?=       -c -O1
1.16      joerg      31: _PYSETUPINSTALLARGS=   ${PYSETUPINSTALLARGS} ${PYSETUPOPTARGS} ${_PYSETUPTOOLSINSTALLARGS}
1.15      joerg      32: _PYSETUPINSTALLARGS+=  --root=${DESTDIR:Q}
1.33      wiz        33: PY_PATCHPLIST?=                yes
1.32      tron       34: PYSETUPTESTTARGET?=    test
1.55      adam       35: PYSETUPTESTARGS?=      # empty
                     36: PYSETUPSUBDIR?=                # empty
1.1       jlam       37: 
                     38: do-build:
1.61      riastrad   39:        (cd ${WRKSRC}/${PYSETUPSUBDIR} && ${SETENV} ${MAKE_ENV} \
                     40:         ${TOOL_PYTHONBIN} ${PYSETUP} ${PYSETUPARGS} ${PYSETUPBUILDTARGET} \
                     41:         ${PYSETUPBUILDARGS})
1.1       jlam       42: 
                     43: do-install:
1.18      tnn        44:        (cd ${WRKSRC}/${PYSETUPSUBDIR} && ${SETENV} ${INSTALL_ENV} ${MAKE_ENV} \
1.61      riastrad   45:         ${TOOL_PYTHONBIN} ${PYSETUP} ${PYSETUPARGS} "install" \
                     46:         ${_PYSETUPINSTALLARGS})
1.55      adam       47: 
1.48      rillig     48: .  if !target(do-test) && !(defined(TEST_TARGET) && !empty(TEST_TARGET))
1.32      tron       49: do-test:
1.61      riastrad   50:        (cd ${WRKSRC}/${PYSETUPSUBDIR} && ${SETENV} ${TEST_ENV} \
                     51:         ${TOOL_PYTHONBIN} ${PYSETUP} ${PYSETUPARGS} ${PYSETUPTESTTARGET} \
                     52:         ${PYSETUPTESTARGS})
1.48      rillig     53: .  endif
1.32      tron       54: 
1.1       jlam       55: .endif
                     56: 
                     57: .if defined(PY_PATCHPLIST)
1.29      obache     58: PLIST_SUBST+=  PYINC=${PYINC} PYLIB=${PYLIB} PYSITELIB=${PYSITELIB}
1.49      wiz        59: PLIST_SUBST+=  PYVERSSUFFIX=${PYVERSSUFFIX}
1.1       jlam       60: .endif
1.30      obache     61: 
1.49      wiz        62: # mostly for ALTERNATIVES files
                     63: FILES_SUBST+=  PYVERSSUFFIX=${PYVERSSUFFIX}
                     64: 
1.59      wiz        65: # Python>=3.2 bytecode file location change
1.35      obache     66: # http://www.python.org/dev/peps/pep-3147/
1.36      wiz        67: .if empty(_PYTHON_VERSION:M2?)
1.48      rillig     68: PLIST_AWK+=            -f ${PKGSRCDIR}/lang/python/plist-python.awk
                     69: PLIST_AWK_ENV+=                PYVERS="${PYVERSSUFFIX:S/.//}"
1.57      leot       70: EARLY_PRINT_PLIST_AWK+=        /^[^@]/ && /[^\/]+\.py[co]$$/ {
                     71: EARLY_PRINT_PLIST_AWK+=        gsub(/__pycache__\//, "")
                     72: EARLY_PRINT_PLIST_AWK+=        gsub(/opt-1\.pyc$$/, "pyo")
                     73: EARLY_PRINT_PLIST_AWK+=        gsub(/\.cpython-${_PYTHON_VERSION}/, "")}
1.63      wiz        74: PRINT_PLIST_AWK+=      /bin\// { sub(/${PYVERSSUFFIX}/, "$${PYVERSSUFFIX}") }
                     75: PRINT_PLIST_AWK+=      /man\// { sub(/${PYVERSSUFFIX}/, "$${PYVERSSUFFIX}") }
1.64      wiz        76: PRINT_PLIST_AWK+=      /share\/doc\// { sub(/${PYVERSSUFFIX}/, "$${PYVERSSUFFIX}") }
1.30      obache     77: .endif
1.51      joerg      78: 
1.59      wiz        79: # For running tests before installation of the package,
                     80: # this is sometimes needed; or setting
                     81: # TEST_ENV+=   PYTHONPATH=${WRKSRC}/build/lib
                     82: 
1.51      joerg      83: DISTUTILS_BUILDDIR_IN_TEST_ENV?=       no
                     84: 
                     85: .if ${DISTUTILS_BUILDDIR_IN_TEST_ENV} == "yes"
1.61      riastrad   86: DISTUTILS_BUILDDIR_CMD=        cd ${WRKSRC} && ${TOOL_PYTHONBIN} ${.CURDIR}/../../lang/python/distutils-builddir.py
1.51      joerg      87: TEST_ENV+=     PYTHONPATH=${DISTUTILS_BUILDDIR_CMD:sh}
                     88: .endif

CVSweb <webmaster@jp.NetBSD.org>