赞
踩
pip install wheel -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install twine -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install --upgrade setuptools
D:\Git\pypi_demo_xdd>tree /f
│ LICENSE
│ README.md
│ setup.py
│
├─myadd-demo-622
│ my_add.py
│ test.py
│ __init__.py
import setuptools with open("README.md", "r") as fh: long_description = fh.read() setuptools.setup( name="myadd-demo-622", # 项目名称,不要使用下划线 version="2.0.0", # 版本 author="XDD", # 作者 author_email="xdd2026@qq.com", # 邮件 description="我的测试案例", # 一句话描述 long_description=long_description, # 详细描述 long_description_content_type="text/markdown", # 描述使用Markdown url="https://github.com/xdd1997/pypi_demo_xdd.git", # 项目地址 packages=setuptools.find_packages(), # Pypi左侧显示内容 classifiers=[ "Programming Language :: Python :: 3", # 使用Python3 "License :: OSI Approved :: Apache Software License", # 开源协议 "Operating System :: OS Independent", ], )
C:\Users\xdd
下,新建文件.pypirc
,文件内容为下,注意修改***为密码[distutils]
index-servers=pypi
[pypi]
repository = https://upload.pypi.org/legacy/
username = xdd1997
password = ***
# 检查setup.py是否有错误,如果没报错误,输出running check
python setup.py check
python setup.py sdist bdist_wheel
twine upload dist/*
pip install myadd-demo-622
import pypi_demo_xdd
https://github.com/xdd1997/pypi_demo_xdd
项目层次应该是这样的
D:\Git\pypi_demo_xdd>tree /f
│ LICENSE
│ README.md
│ setup.py
├─myadd-demo-622
│ my_add.py
│ __init__.py
导入方法是导入文件夹的名称
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。