# 既存プロジェクトを poetry 管理に変更
$ poetry init
This command will guide you through creating your pyproject.toml config.
Package name [mk_dmj]:
Version [0.1.0]:
Description []:
Author [Kazunori OYA <kazunori_oya@nsware.co.jp>, n to skip]:
License []:
Compatible Python versions [^3.11]:
Would you like to define your main dependencies interactively? (yes/no) [yes] no
Would you like to define your development dependencies interactively? (yes/no) [yes] no
Generated file
[tool.poetry]
name = "mk-dmj"
version = "0.1.0"
description = ""
authors = ["Kazunori OYA <kazunori_oya@nsware.co.jp>"]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.11"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Do you confirm generation? (yes/no) [yes]
# .venv をプロジェクト内に配置する
$ poetry config virtualenvs.in-project true
$ emacs pyproject.toml
[tool.poetry]
...
package-mode = false #<--- ここ追加。パッケージモードを無効にする
----
$ poetry config --list
cache-dir = "C:\\Users\\developer\\AppData\\Local\\pypoetry\\Cache"
experimental.system-git-client = false
installer.max-workers = null
installer.modern-installation = true
installer.no-binary = null
installer.parallel = true
keyring.enabled = true
solver.lazy-wheel = true
virtualenvs.create = true
virtualenvs.in-project = true
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.no-setuptools = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}\\virtualenvs" # C:\Users\developer\AppData\Local\pypoetry\Cache\virtualenvs
virtualenvs.prefer-active-python = false
virtualenvs.prompt = "{project_name}-py{python_version}"
warnings.export = true
# パッケージ追加
$ poetry add <パッケージ名...(requirements.txtの内容)>
# 開発パッケージ追加
$ poetry add --dev <パッケージ名...(静的解析用 jedi flake8 importmagic autopep8 yapf black)>
# 仮想環境の場所
$ poetry env list
.venv (Activated)
# 仮想環境の削除
$ poetry env remove .venv
# ここからはいつも通り仮想環境を有効にして動作させる
$ source .venv/Scripts/activate
$ python <pyスクリプト>