gpt4 book ai didi

python 3.2 : How to setup versioning for a project

转载 作者:太空狗 更新时间:2023-10-30 02:48:44 24 4
gpt4 key购买 nike

好吧,虽然我是 Python 的新手,但我一直在四处寻找,我看到了几个不同的选择,所以我有点困惑。这是我要找的:

我有一个包含多个 .py 文件的项目。我有我的文件和我创建的库的 lib 目录。我的问题是,如何将项目设置为具有版本?看到很多文章说我把版本放在setup.py里。 setup.py 去哪里了?该 setup.py 文件中还需要什么?我只是将 setup.py 导入我的 python 文件吗?我如何检查它是否有效?我如何检查每个 .py 文件的版本以确保它正确导入?

最佳答案

阅读hitchhiker's guide to packaging学习开发 Python 项目的良好实践

The setup.py file is at the heart of a Python project. It describes all of the metadata about your project. There a quite a few fields you can add to a project to give it a rich set of metadata describing the project. However, there are only three required fields: name, version, and packages. The name field must be unique if you wish to publish your package on the Python Package Index (PyPI). The version field keeps track of different releases of the project. The packages field describes where you’ve put the Python source code within your project.

Our initial setup.py will also include information about the license and will re-use the README.txt file for the long_description field. This will look like:

from distutils.core import setup

setup(
name='TowelStuff',
version='0.1dev',
packages=['towelstuff',],
license='Creative Commons Attribution-Noncommercial-Share Alike license',
long_description=open('README.txt').read(),
)

关于 python 3.2 : How to setup versioning for a project,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11830896/

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