开源项目 Poetry-Publish 使用教程

开源项目 Poetry-Publish 使用教程

poetry-publishAn action to build and publish python package to pypi (https://pypi.org/) using poetry (https://github.com/sdispater/poetry)项目地址:https://gitcode.com/gh_mirrors/po/poetry-publish

1. 项目的目录结构及介绍

poetry-publish/
├── README.md
├── poetry.lock
├── pyproject.toml
├── src/
│   └── poetry_publish/
│       ├── __init__.py
│       ├── publish.py
│       └── utils.py
└── tests/
    └── test_publish.py
  • README.md: 项目说明文档。
  • poetry.lock: Poetry 依赖锁定文件。
  • pyproject.toml: 项目配置文件,包含项目元数据和依赖信息。
  • src/: 源代码目录。
    • poetry_publish/: 项目主代码目录。
      • init.py: 包初始化文件。
      • publish.py: 发布功能实现文件。
      • utils.py: 工具函数文件。
  • tests/: 测试代码目录。
    • test_publish.py: 发布功能测试文件。

2. 项目的启动文件介绍

项目的启动文件是 src/poetry_publish/publish.py。该文件包含了项目的主要功能实现,包括包的构建和发布逻辑。

# src/poetry_publish/publish.py

import subprocess

def build_package():
    subprocess.run(["poetry", "build"])

def publish_package():
    subprocess.run(["poetry", "publish"])

if __name__ == "__main__":
    build_package()
    publish_package()

3. 项目的配置文件介绍

项目的配置文件是 pyproject.toml。该文件使用 TOML 格式,包含了项目的元数据和依赖信息。

[tool.poetry]
name = "poetry-publish"
version = "0.1.0"
description = "A simple tool to publish Python packages using Poetry."
authors = ["Your Name <you@example.com>"]

[tool.poetry.dependencies]
python = "^3.8"

[tool.poetry.dev-dependencies]
pytest = "^5.2"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
  • [tool.poetry]: 项目的基本信息,如名称、版本、描述和作者。
  • [tool.poetry.dependencies]: 项目运行时的依赖。
  • [tool.poetry.dev-dependencies]: 开发时的依赖,如测试框架。
  • [build-system]: 构建系统的要求和后端。

poetry-publishAn action to build and publish python package to pypi (https://pypi.org/) using poetry (https://github.com/sdispater/poetry)项目地址:https://gitcode.com/gh_mirrors/po/poetry-publish

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

农优影

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值