I have a generic shell script used in all of the modules.
All of the modules install a common pip called common
.
The script is something like this
common
utils
scripts
build
generic_build.sh
I've saw there is a way to install python script by adding to setup.py
using the scripts
or the console_scripts
arguments. but sh
files seems to be ignored. meaning they don't end up in the installed package.
Any ideas?
Shell scripts can be bundled in a distribution by adding them to the scripts
list as if they were python scripts. Example:
# bash_scripts/spam.sh
#!/usr/bin/env bash
echo Running "$0"
A simple setup script for packaging the spam.sh
:
# setup.py
from setuptools import setup
setup(
name='spam',
scripts=['bash_scripts/spam.sh']
)
Building both source and binary dists includes the spam.sh
:
$ python setup.py bdist_wheel | grep spam.sh
copying bash_scripts/spam.sh -> build/scripts-3.6
copying build/scripts-3.6/spam.sh -> build/bdist.linux-aarch64/wheel/spam-0.0.0.data/scripts
changing mode of build/bdist.linux-aarch64/wheel/spam-0.0.0.data/scripts/spam.sh to 755
adding 'spam-0.0.0.data/scripts/spam.sh'
$ python setup.py sdist | grep spam.sh
copying bash_scripts/spam.sh -> spam-0.0.0/bash_scripts
After installation, check the shell script is included:
$ pip install dist/spam-0.0.0.tar.gz
...
$ pip show -f spam
Name: spam
Version: 0.0.0
Summary: UNKNOWN
Home-page: UNKNOWN
Author: UNKNOWN
Author-email: UNKNOWN
License: UNKNOWN
Location: /data/gentoo64/home/u0_a82/.local/lib64/python3.6/site-packages
Requires:
Files:
../../../bin/spam.sh
spam-0.0.0.dist-info/DESCRIPTION.rst
spam-0.0.0.dist-info/INSTALLER
spam-0.0.0.dist-info/METADATA
spam-0.0.0.dist-info/RECORD
spam-0.0.0.dist-info/WHEEL
spam-0.0.0.dist-info/metadata.json
spam-0.0.0.dist-info/top_level.txt
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