本文主要是介绍head first python 第一章-新代码更新pypi,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
目录
第一步:了解目录结构
第三部分:实操
第一步:了解目录结构
目录结构如下,需要自己构建12345文件。
文件1:.pypirc
[distutils]
index-servers =pypipypitest[pypi] #这里的[]内容需要和上面保持一致,并且后续的命令也需要注意写对
repository: https://upload.pypi.org/legacy/ #正式地址
username = __token__
password = pypi-xxxxxx[pypitest] #这里的[]内容需要和上面保持一致,并且后续的命令也需要注意写对
repository: https://test.pypi.org/legacy/ #测试地址
username = __token__
password = pypi-xxxxxx
ps:因为我上传测试地址时老报错,索性就不用了,直接用的正式地址上传。
文件2:LICENSE
MIT LicenseCopyright (c) 2022 pdudoPermission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
文件3:.py 自己写python代码 可以写一个简单的return,比如:
文件4:README.md(这个是markdown格式,可以从网上下一个)
# learning
文件5:setup.py
from setuptools import setup, find_packagessetup(name='AAAAAAAAAAAAA', #自己填version='0.0.4', #自己填description='随便写点', #自己填license='=License',install_requires=[],packages=[' AAAAAAAAAAAAA'], # 要打包的项目文件夹include_package_data=True, # 自动打包文件夹内所有数据author=' XXXXX', #自己填author_email='XXXXXX@qq.com', #自己填url='https://github.com/XXXX', #自己填
)
第二部分:命令行构建发布
#第一次上传用这个
python3 -m build
python3 -m twine upload --repository pypi dist/* --verbose #如果有修改版本内容 比如删除掉了某个版本,用如下命令
python3 -m twine upload --repository pypi --verbose --skip-existing dist/*
第三部分:实操
1、build:
2、twine:
如果有文件存在报错,使用命令如下:
3、找到自己项目上传地址:Search results · PyPI
Search results · PyPI
4、如何使用自己的库
import Mytestdemo #脚本名称a = Mytestdemo.add(2, 4) #脚本名称.函数
参考:https://www.cnblogs.com/NoneID/p/17513444.html
这篇关于head first python 第一章-新代码更新pypi的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!