setup.py files equivalence of data-files attribute in pyproject.toml

156 Views Asked by At

Does anyone know the equivalent syntax of data-files in pyptoject.toml. I know that it's deprecated but I wanted to do something quick and dirty without making too many changes to an existing repo.

I am aware that [tools.setuptools] works with script-files and data-files directives but I have been struggling to get data-files to work although I was successful with scriipt-files. I have tried and a few other combinations but setuptools always throws an absolute fit:

[tool.setuptools]
data-files = [
    { "etc":  [
         "etc/foo.json", 
         "etc/foo2.json"
       ]
    }
]
script-files = [
    "scripts/foo_scripts.py"
]

Note there is an etc directory in the base directory of the repo that I am working with.

1

There are 1 best solutions below

3
On BEST ANSWER

sinoroc's comment that pointed me to this link: https://github.com/pypa/setuptools/blob/d42e248710a0d7ea9920c92fe3515d4ec3298176/setuptools/tests/config/test_pyprojecttoml.py#L74 was the key to solving my issue. That link provides an example of how to translate the data-files attribute of setup.py and setuptools into something that can be used in pyproject.toml.

This is definitely not information that's widely disseminated.

[tool.setuptools.data-files]
"data" = ["_files/*.txt"]