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

1.58    ! gutterid    1: # $NetBSD: extension.mk,v 1.57 2020/06/10 16:11:07 leot Exp $
1.1       jlam        2: 
                      3: .include "../../lang/python/pyversion.mk"
                      4: 
1.27      gdt         5: # Packages that are a non-egg distutils extension should set
                      6: # PYDISTUTILSPKG=YES and include this mk file.
                      7: 
                      8: # This mk fragment is included to handle packages that create
                      9: # extensions to python, which by definition are those that place files
                     10: # in ${PYSITELIB}.  Extensions can be implemented via setuptools as
                     11: # eggs (see egg.mk), via distutils (confusing, with an egg-info file,
1.58    ! gutterid   12: # even though they are not eggs), or via more ad hoc methods.
1.27      gdt        13: 
1.1       jlam       14: .if defined(PYDISTUTILSPKG)
1.15      joerg      15: .include "../../mk/bsd.prefs.mk"
                     16: 
1.1       jlam       17: PYSETUP?=              setup.py
1.25      wiz        18: PYSETUPBUILDTARGET?=   build
1.55      adam       19: PYSETUPBUILDARGS?=     # empty
1.52      adam       20: # Python 3.5+ supports parallel building
1.56      wiz        21: .  if defined(MAKE_JOBS) && ${_PYTHON_VERSION} != 27
1.55      adam       22: .    if !defined(MAKE_JOBS_SAFE) || empty(MAKE_JOBS_SAFE:M[nN][oO])
1.52      adam       23: PYSETUPBUILDARGS+=     -j${MAKE_JOBS}
1.55      adam       24: .    endif
1.52      adam       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.3       jdolecek   37:        (cd ${WRKSRC}/${PYSETUPSUBDIR} && ${SETENV} ${MAKE_ENV} ${PYTHONBIN} \
1.26      wiz        38:         ${PYSETUP} ${PYSETUPARGS} ${PYSETUPBUILDTARGET} ${PYSETUPBUILDARGS})
1.1       jlam       39: 
                     40: do-install:
1.18      tnn        41:        (cd ${WRKSRC}/${PYSETUPSUBDIR} && ${SETENV} ${INSTALL_ENV} ${MAKE_ENV} \
1.26      wiz        42:         ${PYTHONBIN} ${PYSETUP} ${PYSETUPARGS} "install" ${_PYSETUPINSTALLARGS})
1.55      adam       43: 
1.48      rillig     44: .  if !target(do-test) && !(defined(TEST_TARGET) && !empty(TEST_TARGET))
1.32      tron       45: do-test:
1.50      wiz        46:        (cd ${WRKSRC}/${PYSETUPSUBDIR} && ${SETENV} ${TEST_ENV} ${PYTHONBIN} \
1.32      tron       47:         ${PYSETUP} ${PYSETUPARGS} ${PYSETUPTESTTARGET} ${PYSETUPTESTARGS})
1.48      rillig     48: .  endif
1.32      tron       49: 
1.1       jlam       50: .endif
                     51: 
1.28      gdt        52: # PY_NO_EGG suppress the installation of the egg info file (and
1.27      gdt        53: # therefore its inclusion in the package).  Python practice is be to
                     54: # use these files to let 'require' verify that python distributions
1.28      gdt        55: # are present, and therefore the default value of PY_NO_EGG=yes causes
                     56: # pkgsrc not to conform to python norms.  The reason for this behavior
                     57: # appears to be that creating egg info files was new in Python 2.5.
1.19      abs        58: PY_NO_EGG?=            yes
                     59: .if !empty(PY_NO_EGG:M[yY][eE][sS])
1.55      adam       60: # see python*/patches/patch-Lib_distutils_command_install.py
1.19      abs        61: INSTALL_ENV+=          PKGSRC_PYTHON_NO_EGG=defined
                     62: .endif
                     63: 
1.1       jlam       64: .if defined(PY_PATCHPLIST)
1.29      obache     65: PLIST_SUBST+=  PYINC=${PYINC} PYLIB=${PYLIB} PYSITELIB=${PYSITELIB}
1.49      wiz        66: PLIST_SUBST+=  PYVERSSUFFIX=${PYVERSSUFFIX}
1.1       jlam       67: .endif
1.30      obache     68: 
1.49      wiz        69: # mostly for ALTERNATIVES files
                     70: FILES_SUBST+=  PYVERSSUFFIX=${PYVERSSUFFIX}
                     71: 
1.36      wiz        72: # prepare Python>=3.2 bytecode file location change
1.35      obache     73: # http://www.python.org/dev/peps/pep-3147/
1.36      wiz        74: .if empty(_PYTHON_VERSION:M2?)
1.48      rillig     75: PLIST_AWK+=            -f ${PKGSRCDIR}/lang/python/plist-python.awk
                     76: PLIST_AWK_ENV+=                PYVERS="${PYVERSSUFFIX:S/.//}"
1.57      leot       77: EARLY_PRINT_PLIST_AWK+=        /^[^@]/ && /[^\/]+\.py[co]$$/ {
                     78: EARLY_PRINT_PLIST_AWK+=        gsub(/__pycache__\//, "")
                     79: EARLY_PRINT_PLIST_AWK+=        gsub(/opt-1\.pyc$$/, "pyo")
                     80: EARLY_PRINT_PLIST_AWK+=        gsub(/\.cpython-${_PYTHON_VERSION}/, "")}
1.30      obache     81: .endif
1.51      joerg      82: 
                     83: DISTUTILS_BUILDDIR_IN_TEST_ENV?=       no
                     84: 
                     85: .if ${DISTUTILS_BUILDDIR_IN_TEST_ENV} == "yes"
                     86: DISTUTILS_BUILDDIR_CMD=        cd ${WRKSRC} && ${PYTHONBIN} ${.CURDIR}/../../lang/python/distutils-builddir.py
                     87: TEST_ENV+=     PYTHONPATH=${DISTUTILS_BUILDDIR_CMD:sh}
                     88: .endif

CVSweb <webmaster@jp.NetBSD.org>