1
1
mirror of https://github.com/go-gitea/gitea synced 2024-06-25 04:35:48 +00:00
gitea/docs/content/usage/packages/pypi.zh-cn.md
John Olheiser bd4c7ce578
Docusaurus-ify (#26051)
This PR cleans up the docs in a way to make them simpler to ingest by
our [docs repo](https://gitea.com/gitea/gitea-docusaurus).

1. It includes all of the sed invocations our ingestion did, removing
the need to do it at build time.
2. It replaces the shortcode variable replacement method with
`@variable@` style, simply for easier sed invocations when required.
3. It removes unused files and moves the docs up a level as cleanup.

---------

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2023-07-26 04:53:13 +00:00

2.9 KiB
Raw Blame History

date title slug sidebar_position draft toc menu
2021-07-20T00:00:00+00:00 PyPI 软件包注册表 pypi 100 false false
sidebar
parent name sidebar_position identifier
packages PyPI 100 pypi

PyPI 软件包注册表

为您的用户或组织发布 PyPI 软件包。

要求

要使用 PyPI 软件包注册表,您需要使用 pip 工具来消费和使用 twine 工具来发布软件包。

配置软件包注册表

要注册软件包注册表,您需要编辑本地的 ~/.pypirc 文件。添加以下内容:

[distutils]
index-servers = gitea

[gitea]
repository = https://gitea.example.com/api/packages/{owner}/pypi
username = {username}
password = {password}
占位符 描述
owner 软件包的所有者
username 您的 Gitea 用户名
password 您的 Gitea 密码。如果您使用 2FA 或 OAuth请使用个人访问令牌替代密码

发布软件包

通过运行以下命令来发布软件包:

python3 -m twine upload --repository gitea /path/to/files/*

软件包文件的扩展名为 .tar.gz.whl

如果已存在具有相同名称和版本的软件包,则无法发布软件包。您必须先删除现有的软件包。

安装软件包

要从软件包注册表安装 PyPI 软件包,请执行以下命令:

pip install --index-url https://{username}:{password}@gitea.example.com/api/packages/{owner}/pypi/simple --no-deps {package_name}
参数 描述
username 您的 Gitea 用户名
password 您的 Gitea 密码或个人访问令牌
owner 软件包的所有者
package_name 软件包名称

例如:

pip install --index-url https://testuser:password123@gitea.example.com/api/packages/testuser/pypi/simple --no-deps test_package

您可以使用 --extra-index-url 替代 --index-url,但这样会使您容易受到依赖混淆攻击,因为 pip 会先检查官方 PyPi 仓库中的软件包,然后再检查指定的自定义仓库。请阅读 pip 文档以获取更多信息。

支持的命令

pip install
twine upload