如何在Python 3中创建发行版以及如何安装和上传它? 我已经制作了两个文件夹Nester,并在其中制作了一个列表和设置。
列表代码
movies = [
"The Holy Grail", 1975, "Terry Jones & Terry Gilliam", 91,
["Graham Chapman",
["Michael Palin", "John Cleese", "Terry Gilliam", "Eric Idle", "Terry Jones"]
]
]
"""Hi!This is a file nester.py.this is my first comment """
def print_lol(the_list):
"""It is a function. we use it to not repeat the codes several times"""
for each_item in the_list:
if isinstance(each_item, list):
print_lol(each_item)
else :
print(each_item)
print_lol(movies)
设置代码
from distutils.core import setup
setup(
name = 'nester',
version = '1.0.0',
py_modules = ['nester'],
author = 'hfpython',
author_email = 'hfpython@headfirstlabs.com',
url = 'http://www.headfirstlabs.com',
description = 'A simple printer of nested lists',
)
如何在 Python 3 中创建发行版以及如何安装和上传它?
看看PyPA的 Python 打包用户指南中的教程"打包 Python 项目":
-
生成分发存档
-
上传分发存档
总之:
-
使用
python3 setup.py sdist bdist_wheel
创建项目的分发。 -
使用
python3 -m twine upload
将这些发行版发布到 Python 项目索引,例如 PyPI。