What is the best way to include a 'helper' shell script in setup.py that is used by a python module? I don't want to include is as a script since it is not run on it's own.
Also, data_files just copies things in the the install path (not the module install path) so that does not really seem like the best route.
I guess the question is: is there a way of including non-python (non-C) scripts/binaries in a python distutils package in a generic way?
Include it in MANIFEST.in, something like this:
include mycode/myscript.sh
Here's an example Python package that uses helper scripts:
https://github.com/pminkov/kubeutils
Take a look at this file, it runs shell scripts: https://github.com/pminkov/kubeutils/blob/master/kubeutils/kutils.py
I don't think there is a way to package a shell script.
For one of my projects I specifically needed a shell script to pass as an argument over subprocess to another tool that will only except a shell script, not a python script.
So I finally hacked around it by having python write myscript.sh out on the the fly.
It looks like this:
bash_script_name = cwd + "/myscript.sh"
bash_script_file_obj = open(bash_script_name, 'w')
bash_script_file_obj.write(text_of_myscript)
bash_script_file_obj.close()
os.chmod(bash_script_name, 0755)
subprocess.call([another_tool, bash_script_name])
os.remove(bash_script_name)
It's not very elegant, but it worked. If you have the choice of writing the script in Python, I would definitely go with that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With