Can I specify package data in pyproject.toml
Question:
I use setuptools
. In setup.cfg
, I can define
[options.package_data]
myModule =
'*.csv'
to make sure that data will be installed for my users.
Can I achive the same with pyproject.toml
instead?
Answers:
if I understand your concern, you are using setuptools
as a building and distributing system and you want to move some configs from setup.[py,cfg]
namely package_data
to pyproject.toml
, if so you have to use an other tool to build and distribute your package e.g poetry
as stated in @Romibuzi’s answer because it’s not possible unless the setuptools’ team plan a new major release to include a full support of pyproject.toml
and then no need for extra/standalone config setup.cfg
file.
some references:
- https://setuptools.pypa.io/en/latest/userguide/quickstart.html#basic-use
- https://discuss.python.org/t/where-to-get-started-with-pyproject-toml/4906/4
Update
as per v61.0.0, setuptools brings a partial support (still in beta version) for this feature.
refer to @LudvigH’s answer. (thank you btw)
Starting in setuptools version 61.0.0 there is beta support for this feature. See the documentation https://setuptools.pypa.io/en/stable/userguide/datafiles.html
The syntax is
[tool.setuptools.package-data]
myModule = ["*.csv"]
If you’re using Hatchling, per the docs, you can also do this via:
[tool.hatch.build]
include = [
"myModule/**/*.csv",
"**/*.py",
]
exclude = [
"tests/**",
]
I use setuptools
. In setup.cfg
, I can define
[options.package_data]
myModule =
'*.csv'
to make sure that data will be installed for my users.
Can I achive the same with pyproject.toml
instead?
if I understand your concern, you are using setuptools
as a building and distributing system and you want to move some configs from setup.[py,cfg]
namely package_data
to pyproject.toml
, if so you have to use an other tool to build and distribute your package e.g poetry
as stated in @Romibuzi’s answer because it’s not possible unless the setuptools’ team plan a new major release to include a full support of pyproject.toml
and then no need for extra/standalone config setup.cfg
file.
some references:
- https://setuptools.pypa.io/en/latest/userguide/quickstart.html#basic-use
- https://discuss.python.org/t/where-to-get-started-with-pyproject-toml/4906/4
Update
as per v61.0.0, setuptools brings a partial support (still in beta version) for this feature.
refer to @LudvigH’s answer. (thank you btw)
Starting in setuptools version 61.0.0 there is beta support for this feature. See the documentation https://setuptools.pypa.io/en/stable/userguide/datafiles.html
The syntax is
[tool.setuptools.package-data]
myModule = ["*.csv"]
If you’re using Hatchling, per the docs, you can also do this via:
[tool.hatch.build]
include = [
"myModule/**/*.csv",
"**/*.py",
]
exclude = [
"tests/**",
]