我在所有模块中都使用了通用shell脚本。
所有模块都安装一个名为common
的公共点。
脚本是这样的
common
utils
scripts
build
generic_build.sh
我看到有一种方法可以通过使用setup.py
或scripts
参数添加到console_scripts
来安装python脚本。但是sh
文件似乎被忽略了。这意味着它们不会在已安装的软件包中结束。
任何想法?
答案 0 :(得分:1)
Shell脚本可以通过将它们添加到scripts
列表中而捆绑在分发中,就像它们是python脚本一样。例如:
# bash_scripts/spam.sh
#!/usr/bin/env bash
echo Running "$0"
用于打包spam.sh
的简单设置脚本:
# setup.py
from setuptools import setup
setup(
name='spam',
scripts=['bash_scripts/spam.sh']
)
构建源文件和二进制文件列表包括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
安装后,检查包含的shell脚本:
$ 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
答案 1 :(得分:0)
这取决于您配置setup.py文件的方式。 尝试将其添加为资源或其他类型的依赖项
data_files=[('.',['INFO.txt']),
('additionalstuff',['additionalstuff/moredata.txt'])]