gpt4 book ai didi

Python setuptools 在 setup.py 中使用 'scripts' 关键字

转载 作者:太空狗 更新时间:2023-10-29 22:24:46 34 4
gpt4 key购买 nike

我正在尝试使用 setuptools 了解 python 打包的工作原理.

setup() 函数的参数之一是 scripts 。该文档没有指定该参数的用途。任何帮助都会很棒!下面是一些示例代码,其中使用了脚本

from setuptools import setup, find_packages
setup(
name="HelloWorld",
version="0.1",
packages=find_packages(),
scripts=['say_hello.py'],

# Project uses reStructuredText, so ensure that the docutils get
# installed or upgraded on the target machine
install_requires=['docutils>=0.3'],

package_data={
# If any package contains *.txt or *.rst files, include them:
'': ['*.txt', '*.rst'],
# And include any *.msg files found in the 'hello' package, too:
'hello': ['*.msg'],
},

# metadata for upload to PyPI
author="Me",
author_email="me@example.com",
description="This is an Example Package",
license="PSF",
keywords="hello world example examples",
url="http://example.com/HelloWorld/", # project home page, if any

# could also include long_description, download_url, classifiers, etc.
)

最佳答案

它主要用于定义您将在包中使用的附加脚本。这是引用链接中的一个片段:

#!/usr/bin/env python
import funniest print funniest.joke()

然后我们可以像这样在 setup() 中声明脚本:

setup(
...
scripts=['bin/funniest-joke'],
...
)

When we install the package, setuptools will copy the script to our PATH and make it available for general use. This has advantage of being generalizeable to non-python scripts, as well: funniest-joke could be a shell script, or something completely different.

引用:http://python-packaging.readthedocs.io/en/latest/command-line-scripts.html#the-scripts-keyword-argument

关于Python setuptools 在 setup.py 中使用 'scripts' 关键字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45114076/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com