Poetry (opens in a new tab)
安装
Mac、Linux 安装
-
推荐:
curl -sSL https://install.python-poetry.org | python3 -
- root 配置所有用户可用:
export POETRY_HOME=/usr/local
- root 配置所有用户可用:
-
通过 pip:
pip install poetry
Windows 安装
注意事项, windows 安装后,让添加的 path 路径是不正确的。 需要日志里面,根据获取真实的路径
Actual environment location may have moved due to redirects, links or junctions.
Requested location: "C:\Users\muyu\AppData\Roaming\pypoetry\venv\Scripts\python.exe"
Actual location: "C:\Users\muyu\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\Roaming\pypoetry\venv\Scripts\python.exe"
所以真实的路径为:
C:\Users\muyu\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\Roaming\pypoetry\venv\Scripts
技巧
- 安装包:
- 包名
poetry add httpx
- url:
poetry add https://xxxx.com/xxx.whl
- 本地目录:
poetry add -e ../xxx
- 安装指定源:
poetry add ship --source pypiserver
- 包名
- 执行命令:
poetry run xxx
- 进入虚拟环境:
poetry shell
项目配置
- 初始化项目:
poetry init
poetry 配置
- 查看配置:
poetry config --list
发布包
- 添加发布源:
poetry config --local repositories.pypiserver http://100.64.0.9:8080
- 打包:
poetry build
- 发布:
poetry publish -r pypiserver --username admin --password admin