Poetry超好用python依赖、包管理工具

news/2024/9/22 22:57:23 标签: python, 开发语言

介绍

Poetry 用一个pyproject.toml 代替 setup.py, requirements.txt, setup.cfg, MANIFEST.in and Pipfile文件。
用过vue的肯定看上去会无比熟悉,类似于package.json文件。

[tool.poetry]
name = "my-package"
version = "0.1.0"
description = "The description of the package"

license = "MIT"

authors = [
    "Sébastien Eustace <sebastien@eustace.io>"
]

repository = "https://github.com/python-poetry/poetry"
homepage = "https://python-poetry.org"

# README file(s) are used as the package description
readme = ["README.md", "LICENSE"]

# Keywords (translated to tags on the package index)
keywords = ["packaging", "poetry"]

[tool.poetry.dependencies]
# Compatible Python versions
python = ">=3.8"
# Standard dependency with semver constraints
aiohttp = "^3.8.1"
# Dependency with extras
requests = { version = "^2.28", extras = ["security"] }
# Version-specific dependencies with prereleases allowed
tomli = { version = "^2.0.1", python = "<3.11", allow-prereleases = true }
# Git dependencies
cleo = { git = "https://github.com/python-poetry/cleo.git", branch = "main" }
# Optional dependencies (installed by extras)
pendulum = { version = "^2.1.2", optional = true }

# Dependency groups are supported for organizing your dependencies
[tool.poetry.group.dev.dependencies]
pytest = "^7.1.2"
pytest-cov = "^3.0"

# ...and can be installed only when explicitly requested
[tool.poetry.group.docs]
optional = true
[tool.poetry.group.docs.dependencies]
Sphinx = "^5.1.1"

# Python-style entrypoints and scripts are easily expressed
[tool.poetry.scripts]
my-script = "my_package:main"

常用命令

初始化项目:poetry new poetry-demo

项目结构:
poetry-demo
├── pyproject.toml
├── README.md
├── poetry_demo
│   └── __init__.py
└── tests
    └── __init__.py

已有项目:poetry init 初始化pyproject.toml文件

安装依赖:

  • 方式一: poetry add pendulum,安装成功后[tool.poetry.group.dev.dependencies]下可以看到
  • 方式二: 修改[tool.poetry.group.dev.dependencies]文件内容,poetry update

查看包信息:poetry show

查看切换虚拟环境:peotry shell

查看环境信息:peotry env info

打包项目:peotry build,默认打包目录dist/**.gz, dist/**.whl

官方文档

https://python-poetry.org/docs/


http://www.niftyadmin.cn/n/5670939.html

相关文章

淘宝npm镜像源更新后,如何正常使用npm命令

文章目录 一. npm命令报错二. 更换淘宝最新npm镜像源三. npm命令使用 一. npm命令报错 使用npm install *****命令 报错 npm error code CERT_HAS_EXPIRED npm error errno CERT_HAS_EXPIRED npm error request to https://registry.npm.taobao.org/express failed, reason: …

Vue的指令v-model的原理

v-model的原理 原理&#xff1a;v-model本质上是一个语法糖。例如应用在输入框上&#xff0c;就是value属性和input事件的合写。 作用&#xff1a;提供数据的双向绑定 数据变&#xff0c;视图跟着变 :value视图变&#xff0c;数据跟这变 input 注意&#xff1a;$event用于在…

二分查找算法(3) _x的平方根

个人主页&#xff1a;C忠实粉丝 欢迎 点赞&#x1f44d; 收藏✨ 留言✉ 加关注&#x1f493;本文由 C忠实粉丝 原创 二分查找算法(3) _x的平方根 收录于专栏【经典算法练习】 本专栏旨在分享学习算法的一点学习笔记&#xff0c;欢迎大家在评论区交流讨论&#x1f48c; 目录 温馨…

【玉米田】

题目 代码 #include <bits/stdc.h> using namespace std; typedef long long LL;const int mod 1e8; const int M 1 << 12; LL f[13][M]; int g[13]; vector<int> state; vector<int> p[M]; int n, m; bool check(int x) {return !(x & x <&…

深度学习02-pytorch-05-张量的索引操作

在 PyTorch 中&#xff0c;张量的索引操作是非常灵活且强大的&#xff0c;允许你访问和修改张量中的特定元素或子集。与 NumPy 的数组操作类似&#xff0c;PyTorch 的张量支持多种索引方法&#xff0c;包括单纯的基础索引、高级索引和切片等。下面详细介绍 PyTorch 中常见的张量…

跨站请求伪造(CSRF)漏洞详解

免责申明 本文仅是用于学习检测自己搭建的DVWA靶场环境有关CSRF的原理和攻击实验,请勿用在非法途径上,若将其用于非法目的,所造成的一切后果由您自行承担,产生的一切风险和后果与笔者无关;本文开始前请认真详细学习《‌中华人民共和国网络安全法》‌及其所在国家地区相关法…

MATLAB给一段数据加宽频噪声的方法(随机噪声+带通滤波器)

文章目录 引言方法概述完整代码:结果分析结论参考文献引言 在信号处理领域,添加噪声是模拟实际环境中信号传输时常见的操作。宽频噪声可以用于测试系统的鲁棒性和信号处理算法的有效性。本文将介绍如何使用 M A T L A B MATLAB MATLAB给一段数据添加宽频噪声,具体方法是结合…

PointNet2(一)分类

发现PVN3D中使用到了pointnet2和 densfusion等网络&#xff0c;为了看懂pvn3d&#xff0c;因此得看看pointnet2&#xff0c;然而带cpp&#xff0c;cu文件的程序一时办事编译不成功&#xff0c;因此找到了一个 Pointnet_Pointnet2_pytorch-master&#xff0c;里面有pointnet和po…