Python — PyPi共享你的代码

来源:互联网 发布:免费淘宝培训班义乌 编辑:程序博客网 时间:2024/06/05 20:49

1、注册帐号(https://pypi.python.org)

2、准备发布

(1)文件夹Demo1

(2)Demo1.py

(3)setup.py

#从python发布工具包导入“setup”函数from distutils.core import setup#将模块的元数据与setup函数的参数关联,这个文件中的参数要根据自己的元数据去写setup(    name = 'Demo1',    version = '1.0.0',    py_modules = ['Demo1'],    author = 'peerslee',    )

3、构建发布

(1)在该文件夹只喔咕打开终端窗口

python3 setup.py sdist

(2)将发布安装到自己的本地副本中

sudo python3 setup.py install


4、预览







5、上传代码

(1)python3 setup.py register

We need to know who you are, so please choose either:
 1. use your existing login,
 2. register as a new user,
 3. have the server generate a new password for you (and email it to you), or
 4. quit
Your selection [default 1]: 
1
Username: peerslee
Password: 
Registering Demo1 to https://pypi.python.org/pypi
Server response (200): OK
I can store your PyPI login so future submissions will be faster.
(the login will be stored in /home/peerslee/.pypirc)
Save your login (y/N)?y


(2)python3 setup.py sdist upload

writing manifest file 'MANIFEST'
creating Demo1-1.0.0
making hard links in Demo1-1.0.0...
hard linking Demo1.py -> Demo1-1.0.0
hard linking setup.py -> Demo1-1.0.0
Creating tar archive
removing 'Demo1-1.0.0' (and everything under it)
running upload
Submitting dist/Demo1-1.0.0.tar.gz to https://pypi.python.org/pypi
Server response (200): OK




0 0
原创粉丝点击