python poetry包管理工具
2024年3月1日小于 1 分钟约 196 字
poetry安装
pipx install poetry --verbose
poetry config repositories.pypi https://mirrors.aliyun.com/pypi/simple/
poetry config virtualenvs.in-project true # 配置虚拟环境在项目文件夹内创建
poetry config --list
# $env:PIP_INDEX_URL="https://mirrors.aliyun.com/pypi/simple/"
创建一个django项目
poetry new demo-django --force
cd demo-django
poetry add django
poetry add gunicorn
poetry run django-admin startproject conf .
poetry run python manage.py startapp users
poetry run python manage.py runserver
# 删除虚拟环境重新创建
poetry env remove python
poetry env info
poetry install
# 如果已经有项目文件夹,创建poetry配置
cd demo-django
poetry init
pipx install poetry-add-requirements.txt
poeareq # 从requirements.txt导入
# 进入虚拟环境
poetry shell
生产环境部署
poetry export --without-hashes -f requirements.txt > requirements.txt
pip install -r requirements.txt
gunicorn --workers 4 --bind 0.0.0.0:8000 conf.wsgi:application