hhstore / blog

My Tech Blog: about Mojo / Rust / Golang / Python / Kotlin / Flutter / VueJS / Blockchain etc.
https://github.com/hhstore/blog/issues
294 stars 24 forks source link

Python: PDM - Package Manager #415

Open hhstore opened 11 months ago

hhstore commented 11 months ago

📖 Abstract:

💯 Related:

hhstore commented 11 months ago

PDM: Python 包管理工具

Update: 2024-04:

PK 其他:(试用报告)

PS:

PDM 安装:


pip install pipx
pipx install pdm[all]
hhstore commented 11 months ago

PDM 功能:

添加包依赖:


pdm add requests   # add requests
pdm add requests==2.25.1   # add requests with version constraint
pdm add requests[socks]   # add requests with extra dependency
pdm add "flask>=1.0" flask-sqlalchemy   # add multiple dependencies with different specifiers

# 本地包: 
pdm add ./sub-package
pdm add ./first-1.0.0-py2.py3-none-any.whl

# 基于 URL:
# Install gzipped package from a plain URL
pdm add "https://github.com/numpy/numpy/releases/download/v1.20.0/numpy-1.20.0.tar.gz"
# Install wheel from a plain URL
pdm add "https://github.com/explosion/spacy-models/releases/download/en_core_web_trf-3.5.0/en_core_web_trf-3.5.0-py3-none-any.whl"

dev 分组:


pdm add -dG test pytest

# 开发分组:
# A relative path to the directory
pdm add -e ./sub-package --dev
# A file URL to a local directory
pdm add -e file:///path/to/sub-package --dev
# A VCS URL
pdm add -e git+https://github.com/pallets/click.git@main#egg=click --dev
[tool.pdm.dev-dependencies]
lint = [
    "flake8",
    "black"
]
test = ["pytest", "pytest-cov"]
doc = ["mkdocs"]
hhstore commented 11 months ago

PDM Script 功能: 🌟🌟🌟

[tool.pdm.scripts]
start = {cmd = [
    "flask",
    "run",
    # Important comment here about always using port 54321
    "-p", "54321"
]}
hhstore commented 11 months ago

PDM 创建项目:


pdm init --cookiecutter gh:cjolowicz/cookiecutter-hypermodern-python
# or
pdm init --copier gh:pawamoy/copier-pdm --UNSAFE
hhstore commented 11 months ago

1

hhstore commented 11 months ago

1

hhstore commented 10 months ago

1

hhstore commented 10 months ago

1