[Python] Add py.typed as package data with setuptools in pyproject.toml

Discussão em 'Python' iniciado por Stack, Maio 21, 2025.

  1. Stack

    Stack Membro Participativo

    From what I read, to make sure that the typing information of your code is distributed alongside your code for linters to read, the py.typed file should be part of your distribution.

    I find answers for how to add these to setup.py but it is not clear to me 1. whether it should be included in pyproject.toml (using setuptools), 2. if so, how it should be added.

    Scouring their github repository, it seems that this is not added automatically so the question remains how I should add it to my pyproject.toml. I found this general discussion about package_data but it includes reference to include_package_data and a MANIFEST.in and it gets confusing from there what should go where.

    Tl;dr: how should I include py.typed in pyproject.toml when using setuptools?

    Continue reading...

Compartilhe esta Página