head first python 第一章-新代码更新pypi

目录

第一步:了解目录结构

第三部分:实操


第一步:了解目录结构

        目录结构如下,需要自己构建12345文件。

文件1:.pypirc 

[distutils]
index-servers =
  pypi
  pypitest

[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 License

Copyright (c) 2022 pdudo

Permission 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_packages

setup(
    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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值