在我的Node.JS项目中,我将项目元数据保存到package.json中:依赖项、版本号、作者、描述等等。这样任何人都可以克隆我的项目并运行npm来创建一个几乎相同的本地环境。
对于Python来说有这样的事情吗?某种标准文件,可以保存项目元数据,包括版本号和PIP依赖项?
发布于 2015-01-22 06:33:56
Python是一个模块,用于在setuptools工具项目的主目录中编写一个名为setup.py的脚本。为了分发目的,您可以使用您的setup.py来制作Python虫卵。9000's链接更详细地介绍了如何制作鸡蛋。
第一个链接包含关于如何编写完美的setup.py的详细文档,但下面是为我不久前编写的一个Python项目修改的完整示例。
from setuptools import setup
def readme():
"""
This is a function I wrote to read my README file and return it.
"""
with open('README.rst') as f:
return f.read()
setup(name='stackexample',
version='0.1',
description='An answer to a question on StackOverflow',
long_description=readme(), # Get that README.rst
classifiers=[
'Development Status :: 3 - Alpha',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.0'
],
keywords='questions answers programming',
url='http://stackexchange.com/',
author_email='bob@example.com',
license='MIT',
entry_points = {
'console_scripts' :
['stackex=stackexample.command_line:main']
},
packages=['stackexample'],
install_requires=[
"requests",
"something_on_pip",
],
test_suite='nose.collector',
test_requires=['nose', 'nose-cover3'], # Requirements for the test suite
include_package_data=True,
zip_safe=False)还可以使用requirements.txt文件列出依赖项。这篇博客文章非常详细地介绍了requirements.txt与setup.py的区别。
https://softwareengineering.stackexchange.com/questions/270791
复制相似问题