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

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

CVSweb <webmaster@jp.NetBSD.org>