Annotation of pkgsrc/lang/python/wheel.mk, revision 1.24

1.24    ! wiz         1: # $NetBSD: wheel.mk,v 1.23 2026/04/01 20:35:38 wiz Exp $
1.1       nros        2: #
1.10      wiz         3: # Build and install Python wheels
1.1       nros        4: #
1.15      gdt         5: # PEP-518 defines how packages specify their build system
                      6: # requirements, via the build section in pyproject.toml.  The default
                      7: # in the PEP (used when the build section is not present) is
                      8: # setuptools and wheel, but setuptools as of 70.1 has enough wheel
                      9: # functionality that wheel is not required.  Some packages use
1.16      gutterid   10: # different build systems, e.g., flit.
1.15      gdt        11: #
                     12: # wheel.mk does not look for and parse pyproject.toml, and does not
                     13: # support variables to declare the needed tools.  Therefore, packages
                     14: # including wheel.mk must TOOL_DEPENDS on the needed build tools.
1.18      gdt        15: # A typical package will need one of the following, perhaps with the
                     16: # minimum version adjusted:
1.15      gdt        17: #   TOOL_DEPENDS+=  ${PYPKGPREFIX}-setuptools>=70.1:../../devel/py-setuptools
1.20      gdt        18: #   TOOL_DEPENDS+=  ${PYPKGPREFIX}-poetry-core>=2:../../devel/py-poetry-core
1.18      gdt        19: #   TOOL_DEPENDS+=  ${PYPKGPREFIX}-poetry>=0.12:../../devel/py-poetry
1.22      gdt        20: #
                     21: # wheel.mk does not implement USE_PKG_RESOURCES (which is deprecated);
                     22: # packages that need that should DEPENDS (not just BUILD_DEPENDS) on
                     23: # setuptools.
1.15      gdt        24: 
1.1       nros       25: # Variables:
1.10      wiz        26: #
1.23      wiz        27: # PY_RENAME_BINARIES:  List of binaries (in ${PREFIX}/bin) that should
                     28: #                      be renamed to have a '-${PYVERSSUFFIX}'
                     29: #                      suffix. This allows parallel installation of a
                     30: #                      package for different Python versions.
                     31: #
1.16      gutterid   32: # WHEELFILE:           Path to the wheelfile to be installed.
                     33: #                      Only needs to be set if do-build is redefined.
1.1       nros       34: #
1.11      wiz        35: # USE_PYTEST:          If set to yes, depend on py-test and use it for testing.
1.21      gdt        36: #                      (This is strongly the standard approach; often upstreams
                     37: #                      will not even document it.)
1.11      wiz        38: #                      Default: yes
                     39: #
1.16      gutterid   40: # WHEEL_ARGS:          Additional arguments to pass during build of the wheel.
                     41: #
                     42: # WHEEL_NAME:          Name that appears in paths to installed package metadata.
                     43: #                      Can be set if DISTNAME is not the same as the project
                     44: #                      name defined in pyproject.toml.
1.1       nros       45: 
1.10      wiz        46: PY_PATCHPLIST?=        yes
1.14      adam       47: PYSETUPSUBDIR?=        # empty
1.1       nros       48: 
1.14      adam       49: WHEELFILE?=    ${WRKSRC}/${PYSETUPSUBDIR}/dist/*.whl
1.10      wiz        50: WHEEL_NAME?=   ${DISTNAME:C/-([^0-9])/_\1/g}
                     51: _WHEEL_INFODIR=        ${WHEEL_NAME}.dist-info
                     52: PLIST_SUBST+=  WHEEL_INFODIR=${_WHEEL_INFODIR}
1.12      thor       53: WHEEL_ARGS?=   # empty
1.1       nros       54: 
1.10      wiz        55: PRINT_PLIST_AWK+=      { gsub(/${_WHEEL_INFODIR:S,.,\.,g}/, "$${WHEEL_INFODIR}") }
1.1       nros       56: 
1.23      wiz        57: PY_RENAME_BINARIES?=   # empty
                     58: 
1.17      riastrad   59: .include "../../mk/bsd.fast.prefs.mk"
                     60: 
1.10      wiz        61: .if !target(do-build)
1.1       nros       62: TOOL_DEPENDS+= ${PYPKGPREFIX}-build>=0:../../devel/py-build
                     63: do-build:
1.14      adam       64:        ${RUN} cd ${WRKSRC}/${PYSETUPSUBDIR} && \
                     65:        ${SETENV} ${MAKE_ENV} ${TOOL_PYTHONBIN} \
                     66:                -m build --wheel --skip-dependency-check --no-isolation ${WHEEL_ARGS}
1.1       nros       67: .endif
                     68: 
1.10      wiz        69: .if !target(do-install)
1.17      riastrad   70: .  if ${USE_CROSS_COMPILE:tl} == "yes"
                     71: TOOL_DEPENDS+= ${PYPKGPREFIX}-installer>=0.7.0nb2:../../misc/py-installer
                     72: PYINSTALL_EXEC=        --executable ${PYTHONBIN:Q}
                     73: .  else
                     74: TOOL_DEPENDS+= ${PYPKGPREFIX}-installer>=0.7.0nb1:../../misc/py-installer
                     75: PYINSTALL_EXEC=        # empty
                     76: .  endif
1.10      wiz        77: do-install:
1.14      adam       78:        ${RUN} cd ${WRKSRC}/${PYSETUPSUBDIR} && \
                     79:        ${SETENV} ${INSTALL_ENV} ${TOOL_PYTHONBIN} \
1.17      riastrad   80:                -m installer \
                     81:                --destdir ${DESTDIR:Q} \
                     82:                --prefix ${PREFIX:Q} \
                     83:                ${PYINSTALL_EXEC} \
                     84:                ${WHEELFILE}
1.23      wiz        85: .for f in ${PY_RENAME_BINARIES}
1.24    ! wiz        86:        cd ${DESTDIR}/${PREFIX}/bin && ${MV} ${f} ${f}-${PYVERSSUFFIX} || ${TRUE}
1.23      wiz        87: .endfor
1.1       nros       88: .endif
                     89: 
1.11      wiz        90: USE_PYTEST?=   yes
                     91: .if !target(do-test) && ${USE_PYTEST:Myes}
                     92: TEST_DEPENDS+= ${PYPKGPREFIX}-test-[0-9]*:../../devel/py-test
                     93: do-test:
1.14      adam       94:        ${RUN} cd ${WRKSRC}/${PYSETUPSUBDIR} && \
                     95:        ${SETENV} ${TEST_ENV} pytest-${PYVERSSUFFIX}
1.11      wiz        96: .endif
                     97: 
1.10      wiz        98: .include "../../lang/python/extension.mk"
1.19      he         99: .if ${PYTHON_VERSION} >= 313
                    100: .include "../../mk/atomic64.mk"
                    101: .endif

CVSweb <webmaster@jp.NetBSD.org>