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.1.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.1-py3-none-any.whl (2.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ktianc-0.3.1.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.1.tar.gz
Algorithm Hash digest
SHA256 072eb7f4e4fcbf8f8d17bb09ecd78647d15458e5d97487a59ac7a2ed1f586e17
MD5 52167607bceb0bfb7c4ba01a9fbc5eed
BLAKE2b-256 9ebb4402a88f8c0c20566f340ef5fa1689a448a1c094a584527f948b26d3295d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ktianc-0.3.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b343b51d6cfad807b852fe1d111e0e55af4e43cad99b99cee18e41ec91c66959
MD5 b3b9c3f76f9f2878415a3c6a9fc23f8f
BLAKE2b-256 cb0cb951d5daa8acc2edb3ad98923c236e896ef4c68b32d73a48a51bc3dd7d76

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