Is there a way to include shell scripts in a Python package with pyproject?

Question:

Previously with setup.py you could just add

setuptools.setup(
...
    scripts=[ "scripts/myscript.sh" ]
)

and the shell script was just copied to the path of the environment. But with the new pyproject scpecification, this seems to not be possible any more. According to the Python specification of entry points and the setuptools specification, only python functions that will be wrapped later, are allowed. Does anyone know a simple way of doing this like in setup.py? Or at least simpler than just doing a python function that calls the shell script with subprocess, which is what I think I will do if there’s no simpler way.

Asked By: ZJaume

||

Answers:

Probably using the script-files field of the [tool.setuptools] section should work:

[tool.setuptools]
script-files = ["scripts/myscript.sh"]

It was not standardized in PEP 621, so it belongs in a setuptools-specific section.

Setuptools marks it as deprecated, but personally I would assume that it is safe to use for the next couple of years at least. It seems like such scripts are standardized in the wheel file format, so it is a bit strange that they are not in pyproject.toml‘s [project] section. Maybe it will be added later, but that is just speculation.

Reference:

Answered By: sinoroc