I'm trying to distribute a shell script along with a Python package. Ideally, the shell script is installed when I run pip install my_package
. I read from this SO that, my expected behavior is exactly what the scripts
keyword of setuptools.setup
provides. E.g. the script my_script
will be installed with the following setup.py
script:
setup(
...
scripts=['my_script'],
...
)
However, I cannot use the above method for two reasons:
- the official doc did not mention this behavior. I don't know if I can continue to do this way.
- my whole project is built on
pyproject.toml
, withoutsetup.py
. Althoughpyproject.toml
has provided a[project.scripts]
table, as explained in the setuptools official doc, the scripts can only be python functions instead of shell scripts.
For completeness, in my case, the shell script reads git
status and sets environment variables, which will be read from within my python project. The shell script and my python project are bonded so tightly that I would rather not split them into two projects.
I have also tried to use a python function to execute the shell script, e.g.
[project.scripts]
my_script = 'my_project:my_func'
def my_func():
subprocess.run(...)
The problem with this solution is that every time I run my_script
, my_project
is loaded and the loading process is really slow.