新建一个project

注册一个账号
项目配置如下:
[build-system]
requires = ["hatchling==1.26.3"]
build-backend = "hatchling.build"
[project]
name = "daniel_eos"
version = "1.0"
authors = [
{ name="Daniel Chen", email="cdmstrong123@gmail.com"},
]
description = "daniel_eos is a package for eos to yidongyun "
readme = "README.md"
license = { file="LICENSE" }
requires-python = ">=3.9"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
dependencies = [
"aiohttp",
"requests",
"boto3==1.35.92",
"pydantic",
]
[project.urls]
"Homepage" = "https://github.com/NickYi1990/juans"
[tool.setuptools.packages.find]
where = ["daniel_eos"] # 查找src目录下的包
导入包
然后在__init__.py 下
from .upload import upload_file
打包
从新打包的话,使用删除命令:
rm -rf build dist *.egg-info
python -m build
twine check dist/*
可能会出现
twine check dist/*
Checking dist/daniel_eos-1.0-py3-none-any.whl: InvalidDistribution: Metadata is missing required fields: Name, Version.
Make sure the distribution includes the files where those fields are specified, and is using a supported Metadata-Version: 1.0, 1.1, 1.2, 2.0, 2.1, 2.2.

这里主要是因为版本的问题,twine 升级到最新版就可以,要用pip 安装,不要用apt-get 安装
发布
绑定 token

获取密钥:
1、在 PyPI 的 2FA 设置页面,选择 “Authenticator app” 后,会看到一个16 或 32 字符的密钥(只包含 A-Z 和 2-7)
2、执行python -c “import pyotp; print(pyotp.TOTP(‘你的正确密钥’).now())”,出现6位数,输入到verify
3、回到设置页:

发布成功:

541

被折叠的 条评论
为什么被折叠?



