Skip to main content

ktianc first package

Project description

这是我的第一个 pypi 程序

使用前先安装 poetry:

pip install poetry

poetry 命令使用

初始化项目:

这个命令会引导你通过一系列问题来创建 pyproject.toml 文件,该文件是 Poetry 用来管理项目配置和依赖的

poetry init

添加生产环境依赖:

Poetry 会自动处理依赖解析并更新到 pyproject.toml 和 poetry.lock 文件

poetry add fastapi

执行该命令后会直接安装该依赖

添加开发、测试环境依赖:这会将依赖添加到 pyproject.toml 文件的 [tool.poetry.dev-dependencies] 部分

poetry add pytest --dev

安装所有依赖:安装开发依赖和生产依赖。这确保了开发环境具备执行测试和其他开发任务所需的一切。

poetry install 

仅安装生产环境依赖:

poetry install --no-dev

更新依赖:更新项目依赖至其最新版本

poetry update

删除生产环境依赖

poetry remove fastapi

删除开发环境依赖

poetry remove pytest --dev

poetry 项目发布到 pypi

打包:这将在 dist/ 目录下生成 .whl 和 .tar.gz 文件

poetry build

发布:将包发布到 PyPI

发布前需要提前在 pypi 创建账号,并且获取到 token

获取到后执行设置pypi token:

poetry config pypi-token.pypi your_token

发布包

poetry publish

这个命令会要求你输入 PyPI 的用户名和密码。为了避免每次发布都输入密码,你可以使用 API 令牌,并将其存储在 pypirc 文件或环境变量中。

poetry 项目发布到 gitee

打包:这将在 dist/ 目录下生成 .whl 和 .tar.gz 文件

poetry build
  1. 首先需要在 Gitee 创建一个仓库

  2. 创建完成后,将代码推送到 Gitee 中

  3. 创建标签

  4. 创建发行版本,创建时添加 build 生成出的 dist/版本.whl

    image-20240402141353393

  5. 创建完成后表示发布成功

使用 poetry 安装发布在 gitee 中的包

poetry add "my-package@git+https://gitee.com/<username>/<repository>#<branch_or_tag>"

这里的命令分解如下:

  • my-package 是包名。
  • git+https://gitee.com/<username>/<repository> 指定了Git仓库的URL。
  • <branch_or_tag> 是你想要安装的分支或标签名。

实例:

poetry add "ktianc@git+https://gitee.com/ktianc/ktianc#v0.3.0"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ktianc-0.3.0.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ktianc-0.3.0-py3-none-any.whl (2.7 kB view details)

Uploaded Python 3

File details

Details for the file ktianc-0.3.0.tar.gz.

File metadata

  • Download URL: ktianc-0.3.0.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.11 Windows/10

File hashes

Hashes for ktianc-0.3.0.tar.gz
Algorithm Hash digest
SHA256 387caed5ad47c5197242195782321cde9a2a9ae446f168de90d718335a0037ba
MD5 da36b7392381d0fd3f3427eb32781911
BLAKE2b-256 f7020bd4da9b5cae9d9da117184c54f045a3804ded6be82cb42057828ca40f3a

See more details on using hashes here.

File details

Details for the file ktianc-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: ktianc-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 2.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.11 Windows/10

File hashes

Hashes for ktianc-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 274f4184a021ddd5795020de354414cee970cc72b3b22d23cd015c5946c02624
MD5 7e0b6d80941782cc3ebb93ce3b4e7fe7
BLAKE2b-256 9c03ed1cf5be4c2f084790bdda7098c2e94c919ead1ecce70759147fc376d656

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page