poetry
설치
curl -sSL https://install.python-poetry.org | python3 -
.zshrc
export PATH=$HOME/.local/bin:$PATH
poetry self update
curl -sSL https://install.python-poetry.org | python3 - --uninstall
Virtualenv
poetry config virtualenvs.in-project true
위 설정을 사용하면 프로젝트 안에 .venv
디렉토리에 가상환경이 생성됩니다.
생성
poetry init
poetry env use <pythonPath>
danger
asdf
, pyenv
등을 사용할 때, python env use <pythonPath>
를 사용하지 않으면 python 버전 설정이 정상적으로 되지 않는 경우가 있습니다.
poetry env info
poetry shell
삭제
poetry env list
poetry env remove <env>
Dependency
poetry add <package|git|path>
--dev
: 개발용 패키지인 경우 이 옵션을 사용합니다.(--group=dev
)--group=<group>
:<group>
의존성에 추가합니다.<git>
:<vcs_type>+<scheme>://<location>/<user_or_organization>/<repository>[<options>]
<vcs_type>
:git
<scheme>
:http
,https
,ssh
<options>
@<tag|rev|branch>
#subdirectory=<path>
--source=<source>
:<source>
에 있는 패키지를 설치합니다.
poetry update <package>
poetry remove <package>
Source(Repository)
poetry add <source> <url> [<flags>]
<flags>
--default
: 추가될 소스를 기본 소스로 설정하고 PyPI를 비활성화 합니다
Group
pyproject.toml
[tool.poetry.group.<group>]
optional = <boolean>
[tool.poetry.group.<group>.dependencies]
<package> = <version>
URL
pyproject.toml
torch = [
{url = "https://download.pytorch.org/whl/cpu/torch-1.13.1%2Bcpu-cp310-cp310-linux_x86_64.whl", markers = "sys_platform == 'linux'"},
]
Sync
poetry.lock
poetry install [<flags>]
<flags>
--no-root
: 개발 중인 패키지를 editable 상태로 설치하는 것을 제외하고 설치합니다.--remove-untracked
: lock 파일에 더 이상 존재 하지 않는 것은 삭제합니다.--with=<group>[,<group>]
:<group>
에 있는 의존성을 설치합니다.--without=<group>[,<group>]
:<group>
에 있는 의존성을 설치하지 않습니다.--only=<group>[,<group>]
:<group>
에 있는 의존성만 설치합니다.
requirements.txt
poetry export -f requirements.txt --output requirements.txt --without-hashes
python3 -m pip install -r requirements.txt