pyproject.toml 打包项目

pyproject.toml 是新一代的 python 项目打包工具。相比于 setup.py 能够提供更多关于项目本身的信息。

安装

1
2
3
4
5
6
tree
.
├── mydemo
│   ├── __init__.py
│   └── module.py
└── pyproject.toml

pyproject.toml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "mydemo"
authors = [
    {name = "Example Author", email = "author@example.com"}
]
description = "package description"
version = "0.0.1"
readme = "README.md"
requires-python = ">=3.7"
dependencies = [
    "requests > 2.26.0",
    "pandas"
]

mydemo

init.py

1
from .module import *

module

1
2
3
4
def myadd(a: int, b: int):
    "add two numbers"
    print(f"myadd {a=}, {b=}")
    return a + b

install

1
pip install .
william 支付宝支付宝
william 微信微信
0%