python发布_python如何发布模块

一、准备发布

1、创建一个nester.py 模块,创建nester 文件夹将nester.py模块复制到这个文件夹

"# Author:guangqing"

'''这是 "nester" 模块,提供了一个名为print_lol()的函数,这个函数的作用是打印列表,其中有可能包含(也有可能不包含嵌套列表的类别)嵌套列表'''

defprint_lol(the_list):'''这个函数取一个位置参数,名为 'the_list'这可以是任何python列表(也可以是包含嵌套列表的列表)。所指定的列表中的每个数据项会(递归的)输出到屏幕上,各个数据各占一行'''

for each_item inthe_list:ifisinstance(each_item,list):

print_lol(each_item)else:print(each_item)

2、在新文件夹中创建一个名为setup.py的文件;

from distutils.core importsetup

setup(

name='nester',

version='1.0.0',

py_modules=['nester'],

author='jiale',

author_email='18521093275@163.com',

url='http://www.headfirstlabs.com',

description='这是我的第一个发布安装文件')

二、准备发布

1、接下来我们打开cmd窗口,进入到上面建立的文件夹下面,然后执行python setup.py sdist命令,如下图所示(shift+右键,在此处打开powershell窗口)

PS D:\nester>python setup.py sdist

running sdist

running check

warning: sdist: manifest template'MANIFEST.in' does notexist (using default file list)

warning: sdist: standard filenotfound: should have one of README, README.txt, README.rst

writing manifest file'MANIFEST'creating nester-1.0.0

making hard linksin nester-1.0.0...

hard linking nester.py-> nester-1.0.0

hard linking setup.py-> nester-1.0.0

creating dist

Creating tar archive

removing'nester-1.0.0' (andeverything under it)

PS D:\nester>

2、将发布安装到你的python本地副本中。

PS D:\nester>python setup.py install

running install

running build

running build_py

creating build

creating build\lib

copying nester.py->build\lib

running install_lib

running install_egg_info

Removing D:\python\Lib\site-packages\nester-1.0.0-py3.7.egg-info

Writing D:\python\Lib\site-packages\nester-1.0.0-py3.7.egg-info

PS D:\nester>

1、在python 或IDLE shell中,键入dir(__builtins__)可以看到Python提供的内置方法列表;那些小写的单词都是BIF。要查看某个BIF做什么,比如说input(),可以在shell中键入help(input),就会得到这个BIF的功能描述;

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值