pythonsetuptoolspython-packagingnuitka

Include py.typed file in wheel produced with nuitka


I'm trying to build a wheel for a pyproject.toml based project using nuitka as described here. I'd like to include a py.typed file in the final wheel. My repo structure looks like this

pyproject.toml
my_package/
    __init__.py
    my_file.py
    py.typed

I'm using the [build-system] section in pyproject.toml to specify that the wheel should be built with nuitka.

[build-system]
requires = ["setuptools>=42", "wheel", "nuitka", "toml"]
build-backend = "nuitka.distutils.Build"

Under the nuitka configuration section, I've tried various combinations of include-package-data and include-data-files. The below appears to be most similar to the recommended setuptools pattern for including py.typed files.

[nuitka]
disable-ccache = true
include-package-data = "my_package=py.typed"

However, none of the settings I've tried result in a py.typed file being included in the final wheel. How can I include this file?


Solution

  • After some discussion with the maintainer of Nuitka on github, this was easier than expected. Nuitka defers to setuptools for the actual construction of the wheel so including a section like this will include the py.typed file in the resulting wheel.

    [tool.setuptools.package-data]
    my_package = ['py.typed']