๐ŸŒฑPoetry ์„ค์น˜ ๋ฐ ์‚ฌ์šฉ๊ธฐ

yeeun leeยท2020๋…„ 8์›” 19์ผ
2

Poetry๋ฅผ ๊ณต๋ถ€ํ•˜๊ธฐ ์œ„ํ•ด ๊ณต์‹ ๋ฌธ์„œ๋ฅผ (๋ฐœ)๋ฒˆ์—ญํ•ด๋ณด์•˜๋‹ค. Poetry๋Š” ์˜์กด์„ฑ ๊ด€๋ฆฌ ๋ฐ ํŒŒ์ด์ฌ ๋‚ด ํŒจํ‚ค์ง•์„ ์œ„ํ•œ ํˆด์ด๋‹ค. ํ”„๋กœ์ ํŠธ๊ฐ€ ์˜์กดํ•˜๊ณ  ์žˆ๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋“ค์„ ๊ด€๋ฆฌ(์„ค์น˜, ์—…๋ฐ์ดํŠธ ๋“ฑ)ํ•ด์ค€๋‹ค.


1. ์„ค์น˜

osx / linux / bashonwindows์€ ์•„๋ž˜ curl url์„ ํ„ฐ๋ฏธ๋„์— ์ž…๋ ฅํ•ด์„œ ์„ค์น˜ํ•˜๋ฉด ๋œ๋‹ค. Poetry bin ๋””๋ ‰ํ† ๋ฆฌ์— ์„ค์น˜๋˜๊ณ , ์œ ๋‹‰์Šค์—์„œ ์œ„์น˜๋Š” $HOME/.poetry/bin ์ด๋‹ค.

curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python

์„ค์น˜ ํ›„ shell์— ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ์„ค์ •ํ•ด์ฃผ๊ณ , shell์„ ๋‹ซ์•˜๋‹ค๊ฐ€ ์—ด๋ฉด poetry๋ฅผ ํ„ฐ๋ฏธ๋„์— ์ณค์„ ๋•Œ ์ฝ์„ ์ˆ˜ ์žˆ๊ฒŒ ๋œ๋‹ค.

vi .zshrc 

# ํŒŒ์ผ์— ์•„๋ž˜ command ์ถ”๊ฐ€
export PATH="$HOME/.poetry/bin:$PATH"

2. ์˜์กด์„ฑ์ด๋ž€?

์ •์˜

์ข‹์€ ๊ธ€์„ ์ฐธ๊ณ ํ–ˆ๋‹ค. ์˜ˆ์ „์—๋„ ๋ธ”๋กœ๊ทธ์— ์ •๋ฆฌํ–ˆ๋˜ ์ ์ด ์žˆ๋Š” ๊ฒƒ ๊ฐ™์€๋ฐ, ์˜์กด์„ฑ์€ ์ฝ”๋“œ์—์„œ ๋‘ ๋ชจ๋“ˆ๊ฐ„์˜ ์—ฐ๊ฒฐ์ด๋‹ค. ํ•˜๋‚˜์˜ ๋ชจ๋“ˆ์ด ๋ฐ”๋€Œ๋ฉด ์˜์กดํ•˜๊ณ  ์žˆ๋Š” ๋‹ค๋ฅธ ๋ชจ๋“ˆ๊นŒ์ง€ ๋ณ€๊ฒฝ์ด ์ด๋ฃจ์–ด์ ธ ์ˆ˜์ •์ด ํ•„์š”ํ•˜๊ฒŒ ๋œ๋‹ค.

์˜์กด์„ฑ ๊ด€๋ฆฌ๊ฐ€ ์ค‘์š”ํ•œ ์ด์œ  ์ค‘ ๋˜ ๋‹ค๋ฅธ ํ•˜๋‚˜๋ฅผ ๋งํฌ์˜ ๋น„์œ ์—์„œ ์ฐพ์•˜๋‹ค. ๋‚ด๊ฐ€ ๋งŒ์•ฝ ์˜คํ”ˆ์†Œ์Šค ํ”„๋กœ์ ํŠธ๋ฅผ ์ฐพ์•„์„œ ์ตœ๋‹จ๊ฒฝ๋กœ API, ์Œ์„ฑAPI ๋“ฑ์„ ์กฐํ•ฉํ•ด ๋„ค์ด๊ฒŒ์ด์…˜ ์•ฑ์„ ๋งŒ๋“ค์—ˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•˜์ž. ๋งŒ์•ฝ์— ๋‚ด๊ฐ€ ๋ชจ๋“ˆ์„ ์ง์ ‘ ํฌํ•จํ•˜๋ฉด ๋ฒ„๊ทธ๊ฐ€ ์žˆ์„ ๊ฐ€๋Šฅ์„ฑ, ํ˜น์€ ๊ตฌ๋ฒ„์ „์ผ ๊ฐ€๋Šฅ์„ฑ์„ ํ™•์ธํ•˜์ง€ ๋ชปํ•˜๊ณ  ๋ฐฐํฌํ•˜๊ฒŒ ๋  ์ˆ˜ ์žˆ๋‹ค.

๋‚ด๊ฐ€ ์ผ์ผ์ด ๋ชจ๋“ˆ์„ ์ถ”๊ฐ€ํ•˜๊ณ  ๊ด€๋ฆฌํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ, ์˜์กด์„ฑ ๊ด€๋ฆฌ์ž๊ฐ€ ๋‚ด๊ฐ€ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋Š” ๋ชจ๋“ˆ์„ ์ผ๊ด„์ ์œผ๋กœ ์ฒ˜๋ฆฌํ•ด์คŒ์œผ๋กœ์จ API๊ฐ€ ์ตœ์‹ ์ธ์ง€ ํ™•์ธํ•˜๊ณ  ๋ฒ„๊ทธ๊ฐ€ ์—†๋Š”์ง€ ๋“ฑ ๋ชจ๋“  ๊ฒƒ์ผ ๋ฐฉ์ง€ํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋œ๋‹ค.

- pip๊ณผ ์ฐจ์ด์ 

spoqa ๊ธฐ์ˆ  ๋ธ”๋กœ๊ทธ๋ฅผ ์ฐธ๊ณ ํ–ˆ๋‹ค. poetry์˜ ์žฅ์  ๋ฟ ์•„๋‹ˆ๋ผ ๋‹จ์ ๋„ ๋‹ด์€ ์‚ฌ์šฉ๊ธฐ์ธ๋ฐ, PyPI ์™ธ์˜ repository๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ ๋ฒ„๊ทธ ๋“ฑ ์ „๋ฐ˜์ ์œผ๋กœ ์ •๋ฆฌ๊ฐ€ ์ž˜ ๋˜์–ด์žˆ๋‹ค. ๋‚˜๋Š” custom repo๋ฅผ ์‚ฌ์šฉํ•˜์ง„ ์•Š์„ ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์— ์‚ดํฌ์‹œ ํŒจ์Šคํ–ˆ๋‹ค. (๋ธ”๋กœ๊ทธ ๋งํฌ)

์˜์กด์„ฑ ํ•ด๊ฒฐ

๋‚ด ํ”„๋กœ์ ํŠธ์— ํ•„์š”ํ•œ ํŒจํ‚ค์ง€1, ํŒจํ‚ค์ง€2๊ฐ€ ์žˆ๊ณ , ํŒจํ‚ค์ง€2๋Š” ํŒจํ‚ค์ง€1์ด 2.0๋ฒ„์ „ ์ด์ƒ์„ ์š”๊ตฌํ•œ๋‹ค๊ณ  ํ•˜์ž. pip์œผ๋กœ ์„ค์น˜ํ•˜๊ฒŒ ๋˜๋ฉด ๋‚ด๊ฐ€ ํŒจํ‚ค์ง€1์„ 1.0๋ฒ„์ „์œผ๋กœ ์„ค์น˜ํ•œ๋‹ค๊ณ  ํ•ด๋„ ์•„๋ฌด๋Ÿฐ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜์ง€ ์•Š๋Š”๋‹ค.

ํ•˜์ง€๋งŒ poetry๋Š” ๋ฒ„์ „ ๊ด€๋ จ ์ •๋ณด๋ฅผ ํ™•์ธํ•˜๊ณ  ํŠน์ • ๋ฒ„์ „ ์ด์ƒ์ด ์•„๋‹ ๊ฒฝ์šฐ์— ์•„์˜ˆ ์„ค์น˜๊ฐ€ ๋˜์ง€ ์•Š๋Š”๋‹ค.

์˜์กด์„ฑ ์ž ๊ธˆ

pip์€ lockํŒŒ์ผ์ด ์—†๊ณ , ์ง์ ‘ requirements.txt๋ฅผ ์ž‘์„ฑํ•ด์•ผ ํ•œ๋‹ค. ๋ฐ˜๋ฉด poetry๋Š” lock ํŒŒ์ผ๊ณผ pyproject.toml(requirements.txt ๊ฐ™์ด ์„ค์น˜ํ•œ ํŒจํ‚ค์ง€๋ฅผ ๋ฆฌ์ŠคํŒ…ํ•ด๋†“์€ ํŒŒ์ผ)์„ ์ž๋™์œผ๋กœ ์ƒ์„ฑ ๋ฐ ์—…๋ฐ์ดํŠธํ•ด์ค€๋‹ค.

๊ฐ€์ƒํ™˜๊ฒฝ

pip์€ ์ „์—ญ์— ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•˜๊ธฐ ๋•Œ๋ฌธ์—, ํ•ด๋‹น ์„ค์น˜ํˆด๋กœ๋Š” ๋‹ค๋ฅธ ํ™˜๊ฒฝ์—์„œ์˜ ๋ฒ„์ „ ๊ด€๋ฆฌ๊ฐ€ ๋ถˆ๊ฐ€ํ•˜๋‹ค. ๊ทธ๋ž˜์„œ ๋ฏธ๋‹ˆ์ฝ˜๋‹ค๋‚˜ virtualenv ๊ฐ™์€ ํˆด์ด ๋ถ€๊ฐ€์ ์œผ๋กœ ํ•„์š”ํ•˜๊ฒŒ ๋œ๋‹ค. ๋”ฐ๋กœ ๋†€๊ฒŒ๋  ๊ฐ€๋Šฅ์„ฑ์ด ํฌ๋‹ค. ๋ฐ˜๋ฉด poetry๋Š” ๊ฐ€์ƒํ™˜๊ฒฝ ์—ฌ๋ถ€๋ฅผ ํ™•์ธํ•˜๊ณ  ๊ธฐ์กด ํ™˜๊ฒฝ, ํ˜น์€ ์ƒˆ๋กœ ๋งŒ๋“ค์–ด ์„ค์น˜ํ•˜๋Š” ๋“ฑ ์ž๋™์œผ๋กœ ๊ด€๋ฆฌํ•ด์ค€๋‹ค.

3. Basic usage

project setup

์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜๋ฉด poetry๊ฐ€ tests ํŒŒ์ผ์„ ํฌํ•จํ•œ project ๋””๋ ‰ํ† ๋ฆฌ ๊ตฌ์กฐ๋ฅผ ์„ธํŒ…ํ•ด์ค€๋‹ค.

poetry new poetry-demo

poetry-demo
โ”œโ”€โ”€ pyproject.toml
โ”œโ”€โ”€ README.rst
โ”œโ”€โ”€ poetry_demo
โ”‚   โ””โ”€โ”€ __init__.py
โ””โ”€โ”€ tests
    โ”œโ”€โ”€ __init__.py
    โ””โ”€โ”€ test_poetry_demo.py
    

- pyproject.toml

์—ฌ๊ธฐ์„œ ๊ฐ€์žฅ ์ค‘์š”ํ•œ ํŒŒ์ผ์ด๋‹ค. ํ”„๋กœ์ ํŠธ์™€ ์˜์กด์„ฑ์„ ์กฐ์œจํ•ด์ฃผ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

ํŒŒ์ผ์€ ์•„๋ž˜์™€ ๊ฐ™์ด ์ƒ๊ฒผ๋‹ค. ๋งŒ์•ฝ ์˜์กด์„ฑ์„ ํ”„๋กœ์ ํŠธ์— ์ถ”๊ฐ€ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด, tool.poetry.dependencies์— ์ง€์ •ํ•ด์ฃผ๋ฉด ๋œ๋‹ค. ์•„๋ž˜ tool.poetry.dependencies์—์„œ ํŒจํ‚ค์ง€ ์ด๋ฆ„๊ณผ ๋ฒ„์ „ ์ œํ•œ์„ ๋งคํ•‘ํ•ด์ค€ ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

poetry๋Š” ์ด ์ •๋ณด๋ฅผ repositories์—์„œ ํŒจํ‚ค์ง€๋ฅผ ์ฐพ์„ ๋•Œ ์‚ฌ์šฉํ•˜๋Š”๋ฐ, tool.poetry.repositories(=ํŒจํ‚ค์ง€๋ฅผ ์ฐพ๋Š” ๊ณณ)๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ PyPI์ด๋‹ค. ์œ„์—์„œ ๋งํ–ˆ๋˜ spoqa ๊ธฐ์ˆ  ๋ธ”๋กœ๊ทธ ๋ฒ„๊ทธ ๋‚ด์šฉ๊ณผ ๊ด€๋ จ๋˜์–ด ์žˆ๋Š” ๋ถ€๋ถ„์ด๋‹ค.

name = "poetry-demo"
version = "0.1.0"
description = ""
authors = ["Sรฉbastien Eustace <sebastien@eustace.io>"]

[tool.poetry.dependencies]
python = "*"

[tool.poetry.dev-dependencies]
pytest = "^3.4"

pyproject.toml ํŒŒ์ผ์„ ๋ณ€๊ฒฝํ•  ํ•„์š” ์—†์ด ์•„๋ž˜ command๋ฅผ ํ†ตํ•ด ์ˆ˜์ •์ด ๊ฐ€๋Šฅํ•˜๋‹ค. requirements.txt๋Š” ๋‚ด๊ฐ€ ๊ณ„์† ์—…๋ฐ์ดํŠธ๋ฅผ ํ•ด์ค˜์•ผ ํ•˜๋Š” ๋ฐ˜๋ฉด, Poetry๋Š” ์•Œ์•„์„œ addํ•ด์ฃผ๋Š”๊ฒŒ ์žฅ์ ์ด๋‹ค.

poetry add pendulum

- poetry.lock

ํ”„๋กœ์ ํŠธ์— ์ •์˜๋œ ์˜์กด์„ฑ ํŒŒ์ผ๋“ค์„ ์„ค์น˜ํ•˜๊ธฐ ์œ„ํ•ด ์•„๋ž˜ command๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค. ์š” ํŒŒ์ผ์€ ๋ชจ๋‘๊ฐ€ ๊ฐ™์€ ์˜์กด์„ฑ ํ™˜๊ฒฝ์—์„œ ๊ฐœ๋ฐœํ•  ์ˆ˜ ์žˆ๋„๋ก ๋„์™€์ค€๋‹ค. install์„ ํ–ˆ์„ ๋•Œ ๋‘˜์ค‘ ํ•˜๋‚˜์˜ ์ƒํ™ฉ์ด ์ƒ๊ธธ ์ˆ˜ ์žˆ๋‹ค.

poetry install

installing without poetry.lock

poetry.lock ํŒŒ์ผ์ด ์—†๋Š” ์ƒํƒœ์—์„œ install command๋ฅผ ์‹คํ–‰ํ–ˆ์„ ๊ฒฝ์šฐ, poetry๋Š” pyprojet.toml์— ์žˆ๋Š” ํŒจํ‚ค์ง€๋“ค์˜ ๋ชจ๋“  ์˜์กด์„ฑ์„ ํ•ด๊ฒฐํ•˜๊ณ  ๊ฐ€์žฅ ์ตœ์‹  ๋ฒ„์ „์œผ๋กœ ๋‹ค์šด๋กœ๋“œ ํ•˜๊ฒŒ ๋œ๋‹ค.

์„ค์น˜๊ฐ€ ๋๋‚˜๋ฉด ํŒจํ‚ค์ง€์˜ ์ •ํ™•ํ•œ ๋ฒ„์ „์„ ๋ช…์‹œํ•ด ํŠน์ • ๋ฒ„์ „์— ํ”„๋กœ์ ํŠธ๋ฅผ lockingํ•œ๋‹ค. lock ํŒŒ์ผ์€ ํ”„๋กœ์ ํŠธ ๋ ˆํฌ์— commitํ•ด์•ผ ๋ชจ๋“  ๊ตฌ์„ฑ์›๋“ค์ด ๊ฐ™์€ ๋ฒ„์ „์˜ ์˜์กด์„ฑ์„ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋‹ค.

installing with poetry.lock

์ด๋ฏธ poetry.lock ํŒŒ์ผ์ด ์žˆ๋‹ค๋ฉด ์ด์ „์— ๋‚˜ ํ˜น์€ ํ”„๋กœ์ ํŠธ์˜ ๋‹ค๋ฅธ ๊ตฌ์„ฑ์›์ด install command๋ฅผ ํ•œ ์ด๋ ฅ์ด ์žˆ๋‹ค๋Š” ๋œป์ด๋‹ค.

์ด ๋•Œ ์ผ๊ด€์„ฑ์„ ์œ ์ง€ํ•˜๊ธฐ ์œ„ํ•ด install command๋ฅผ ํ•˜๋”๋ผ๋„ ์ตœ์‹  ๋ฒ„์ „์„ ๋‹ค์šด๋ฐ›๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ, ์ƒˆ๋กœ์šด ๋ฒ„์ „์ด Released๋๋”๋ผ๋„ lock ์„ค์ •์— ๋งž๋Š” ํŒŒ์ผ์„ ๋‹ค์šด๋ฐ›๊ฒŒ ๋œ๋‹ค. ์˜์กด์„ฑ์—์„œ ์˜ˆ์ƒ์น˜ ๋ชปํ•œ ๋ณ€ํ™”๊ฐ€ ์ƒ๊ธฐ์ง€ ์•Š๋„๋ก ๊ด€๋ฆฌํ•ด์ฃผ๋Š” ๊ฒƒ์ด๋‹ค.

๋งŒ์•ฝ ์ตœ์‹  ๋ฒ„์ „์œผ๋กœ ์—…๋ฐ์ดํŠธํ•˜๊ณ  ์‹ถ์œผ๋ฉด update command๋ฅผ ์จ์ฃผ๋ฉด ๋œ๋‹ค. ๊ทธ๋Ÿฌ๋ฉด pyproject.toml์„ ๊ธฐ๋ฐ˜์œผ๋กœ ์ตœ์‹  ๋งค์นญ ๋ฒ„์ „์„ lock file์— ์—…๋ฐ์ดํŠธ ํ•ด์ค€๋‹ค.

๋งŒ์•ฝ pyproject.toml๊ณผ poetry.lock์ด ์ผ์น˜ํ•˜์ง€ ์•Š์œผ๋ฉด poetry๊ฐ€ ๊ฒฝ๊ณ ๋ฅผ ๋ณด๋‚ธ๋‹ค.

4. Managing environments

poetry์˜ ํ•ต์‹ฌ์ ์ธ ๊ธฐ๋Šฅ ์ค‘ ํ•˜๋‚˜๊ฐ€ ๋ฐ”๋กœ ํ”„๋กœ์ ํŠธ ํ™˜๊ฒฝ ๋…๋ฆฝ์ด๋‹ค. ๋‹ค๋ฅธ ๋ง๋กœ ํŒŒ์ด์ฌ ์„ค์น˜๋ฅผ ์ „์—ญ์ ์œผ๋กœ ํ•˜์ง€ ์•Š๊ณ  ๋ถ„๋ฆฌํ•œ๋‹ค๋Š” ์˜๋ฏธ์ธ๋ฐ, ์ด๋ฅผ ์œ„ํ•ด์„œ๋Š” ํ˜„์žฌ ๊ฐ€์ƒ ํ™˜๊ฒฝ์ด ๋Œ์•„๊ฐ€๊ณ  ์žˆ๋Š”์ง€๋ฅผ ํ™•์ธํ•˜๋Š” ๊ฒƒ์ด ํ•„์š”ํ•˜๋‹ค. ๋งŒ์•ฝ ๊ฐ€์ƒํ™˜๊ฒฝ์ด ์žˆ์œผ๋ฉด ์ƒˆ๋กœ์šด ํ™˜๊ฒฝ์„ ๋งŒ๋“ค์ง€ ์•Š๊ณ  ๊ธฐ์กด ํ™˜๊ฒฝ์— ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•˜๊ณ , ๊ทธ๊ฒŒ ์•„๋‹ˆ๋ฉด ํ™˜๊ฒฝ์„ ๋งŒ๋“  ๋’ค ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•˜๊ฒŒ ๋œ๋‹ค.

๊ฐ€์ƒ ํ™˜๊ฒฝ์„ ๋งŒ๋“ค ๋•Œ ํŒŒ์ด์ฌ ๋ฒ„์ „์€ ๊ฐ€์žฅ ์ตœ๊ทผ์— ํ™œ์„ฑํ™”๋œ ํŒŒ์ด์ฌ ๋ฒ„์ „์„ ๊ธฐ์ค€์œผ๋กœ ํ•œ๋‹ค. ๋‚ด ํ”„๋กœ์ ํŠธ์— ๋งž๋Š” ํŒŒ์ด์ฌ ๊ฐ€์ƒํ™˜๊ฒฝ์„ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด์„œ๋Š” ํ”„๋กฌํ”„ํŠธ์— pyenv๋ฅผ ํ†ตํ•ด ๋ช…์‹œ์ ์œผ๋กœ ํ™œ์„ฑํ™”์‹œ์ผœ์ฃผ๋Š” ๊ฒƒ์ด ์ข‹๋‹ค.

๊ฐ€์ƒํ™˜๊ฒฝ ์ด๋™

๋ฏธ๋‹ˆ์ฝ˜๋‹ค๋ฅผ ์“ธ ๋•Œ๋Š” ๋‚ด๊ฐ€ ์–ด๋–ค ๋””๋ ‰ํ† ๋ฆฌ์— ์žˆ๋Š”์ง€์™€ ์ƒ๊ด€ ์—†์ด ๊ฐ€์ƒ ํ™˜๊ฒฝ ๋ฆฌ์ŠคํŠธ๋ฅผ ๋ถˆ๋Ÿฌ์˜ค๊ณ  ์—…๋ฐ์ดํŠธํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค. ๊ทธ๋Ÿฐ๋ฐ poetry๋Š” ๊ทธ๋ƒฅ ํ™ˆ๋””๋ ‰ํ† ๋ฆฌ์—์„œ ์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ์น˜๋ฉด ์—๋Ÿฌ๊ฐ€ ํ™•์ธ๋๋‹ค.

์ด ๋ฌธ์ œ๋Š” ๋‚ด๊ฐ€ shell์—์„œ ํ™˜๊ฒฝ ์„ค์ •์„ ์ž˜๋ชปํ•ด์„œ ์ƒ๊ธด๊ฑด์ง€, ์•„๋‹˜ poetry ์ž์ฒด๊ฐ€ ์ด๋Ÿฐ๊ฑด์ง€ ๋ชจ๋ฅด๊ฒ ๋‹ค. ๋ถ„๋ช… ๋ฏธ๋‹ˆ์ฝ˜๋‹ค๊ฐ™์ด ์“ธ ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™์€๋ฐ shell์—์„œ path ์„ค์ •ํ•˜๋Š”๊ฑฐ ์™ธ์— ๋‹ค๋ฅธ ์„ค์ •์ด ์žˆ๋Š”์ง€ ์ฐพ์•„๋ด์•ผ๊ฒ ๋‹ค.

poetry env info

[RuntimeError]
Poetry could not find a pyproject.toml file in /Users/yeni or its parents

์ผ๋‹จ pyproject.toml ํŒŒ์ผ์ด ์žˆ๋Š” ๋””๋ ‰ํ† ๋ฆฌ์—์„œ ๋™์ผํ•œ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ฐ€์ƒํ™˜๊ฒฝ ์ •๋ณด๋ฅผ ์ œ๊ณตํ•œ๋‹ค.

โฏ poetry env info

Virtualenv
Python:         3.7.6
Implementation: CPython
Path:           /Users/yeni/Library/Caches/pypoetry/virtualenvs/board-project-YxfDBa-d-py3.7
Valid:          True

System
Platform: darwin
OS:       posix
Python:   /Users/yeni/miniconda3

System์—์„œ ์™œ Python์ด ๋ฏธ๋‹ˆ์ฝ˜๋‹ค๊บผ๋ฅผ ์“ฐ๋Š”์ง€ ๊ถ๊ธˆํ–ˆ๋Š”๋ฐ, ๋‚ด๊ฐ€ shell base๋ฅผ ๋ฏธ๋‹ˆ์ฝ˜๋‹ค๋กœ ํ•ด๋†”์„œ ํŒŒ์ด์ฌ์„ ๋ฏธ๋‹ˆ์ฝ˜๋‹ค base environment์— ์žˆ๋Š” ์• ๋ฅผ ๊ฐ€์ ธ์˜จ ๊ฒƒ ๊ฐ™๋‹ค. ๊ฐ€์žฅ ์ตœ์‹ ์— ํ™œ์„ฑํ™”๋œ ํŒŒ์ด์ฌ์œผ๋กœ ๊ฐ€์ƒํ™˜๊ฒฝ์„ ๋งŒ๋“ ๋‹ค๊ณ  ํ–ˆ์œผ๋ฏ€๋กœ!

๊ฐ€์ƒํ™˜๊ฒฝ ํ™•์ธ

ํ”„๋กœ์ ํŠธ์™€ ์—ฐ๊ด€์žˆ๋Š” ๋ชจ๋“  ๊ฐ€์ƒํ™˜๊ฒฝ์„ ๋„์›Œ์ฃผ๋Š” command๋„ ์žˆ๋‹ค.

poetry env list

test-O3eWbxRl-py2.7
test-O3eWbxRl-py3.6
test-O3eWbxRl-py3.7 (Activated)

5. commands

๋ช…๋ น์–ด๊ฐ€ ๋งŽ๊ธด ํ•œ๋ฐ, ์ดˆ๋ณด์ž๋กœ์„œ ๋‚ด๊ฐ€ ์‚ฌ์šฉํ• ๋งŒํ•œ ๊ฒƒ๋“ค๋งŒ ์ •๋ฆฌํ•ด๋ดค๋‹ค.

new & init & install

์ฒ˜์Œ์— poetry๋ฅผ ์ ‘ํ•˜๊ฒŒ ๋˜๋ฉด ์‹œ์ž‘ํ•˜๊ณ  ์„ค์น˜ํ•˜๋Š” command๊ฐ€ ๋งŽ์•„ ๋‹นํ™ฉํ•˜๊ฒŒ ๋œ๋‹ค.

  • new: ํ”„๋กœ์ ํŠธ ๋””๋ ‰ํ† ๋ฆฌ ๊ตฌ์กฐ๋ฅผ ์ƒ์„ฑํ•ด์คŒ. ์—ฌ๊ธฐ์—๋Š” pyproject.toml ๋“ฑ์˜ ํŒŒ์ผ์ด ํฌํ•จ๋˜์–ด ์žˆ์Œ

  • init: pyproject.tomlํŒŒ์ผ์„ ๋งŒ๋“ค๊ฒŒ ํ•ด์ฃผ๋Š” ๋ช…๋ น์–ด. ํ”„๋กฌํ”„ํŠธ์—์„œ ์ƒํ˜ธ์ž‘์šฉ์„ ํ†ตํ•ด(๋ฌผ์–ด๋ณด๋Š” ๋‚ด์šฉ์„ ์‚ฌ์šฉ์ž๊ฐ€ ๊ธฐ์ž…) ๋งŒ๋“ค๊ฒŒ ๋œ๋‹ค.

  • install: pyproject.toml ํŒŒ์ผ์„ ์ฝ๊ณ  ์˜์กด์„ฑ์„ ํ•ด๊ฒฐํ•˜๋ฉด์„œ ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•ด์ค€๋‹ค.

- project_name.egg-info ํŒŒ์ผ

poetry install์ด ๋ฌด์—‡์ธ์ง€ ๋ชจ๋ฅด๋Š” ์ƒํƒœ์—์„œ ํ”„๋กœ์ ํŠธ๋ฅผ ๋งŒ๋“ค๊ณ , ํŒจํ‚ค์ง€๋ฅผ addํ•œ ๋‹ค์Œ์— poetry install ๋ช…๋ น์–ด๋ฅผ ์“ฐ๋‹ˆ๊นŒ egg-info ๋ผ๋Š” ํ™•์žฅ์ž์˜ ํŒŒ์ผ์ด ์ƒ๊ฒผ๋‹ค.

๊ฒ€์ƒ‰ํ•ด๋ณด๋‹ˆ ๋‚ด์šฉ์€ ์ž˜ ๋ชจ๋ฅด๊ฒ ์ง€๋งŒ PEP376์— ๋ช…์‹œ๋œ distutils์— ์˜ํ•ด ์ƒ๊ธด๊ฑฐ๋ผ๊ณ  ํ•œ๋‹ค. poetry 1.0.10 ๋ฒ„์ „ ์ดํ•˜๋Š” ๊ฐœ๋ฐœ ์ค‘์ธ ํ”„๋กœ์ ํŠธ์˜ ์„ค์น˜๋ฅผ ์ˆ˜์ •ํ•˜๊ธฐ ์œ„ํ•ด setuptools๋ผ๋Š” ๊ฒƒ์— ์˜์กดํ•˜๊ณ  ์žˆ์–ด์„œ? ๋ผ๊ณ  ํ•˜๋Š”๋ฐ... poetry๊ฐ€ ์ƒ๊ธฐ๊ธฐ ์ „๋ถ€ํ„ฐ egg-info์— ๋Œ€ํ•œ ์งˆ๋ฌธ์ด ์žˆ๋˜ ๊ฒƒ์„ ๋ณด๋ฉด ์ด๊ฑด poetry๊ฐ€ ์•„๋‹ˆ๋ผ python์—์„œ ํŒจํ‚ค์ง€๋ฅผ ๊ด€๋ฆฌํ•  ๋•Œ ๋งŒ๋“œ๋Š” ํŒŒ์ผ ๊ฐ™๋‹ค. poetry ๋ฒ„์ „ 1.1.0๋ถ€ํ„ฐ๋Š” setup.py ํŒŒ์ผ์„ ๋งŒ๋“ค์–ด์•ผ ํ•  ํ•„์š”์—์„œ ์™„์ „ํžˆ ๋ฒ—์–ด๋‚ฌ๊ธฐ ๋•Œ๋ฌธ์— ์ด๋Ÿฐ ํ–‰๋™๋“ค์ด ์ƒ๊ธฐ์ง€ ์•Š๋Š”๋‹ค๊ณ  ํ•œ๋‹ค. ์†”์งํžˆ ๋ฌด์Šจ ๋ง์ธ์ง€๋Š” ์ž˜ ๋ชจ๋ฅด๊ฒ ์ง€๋งŒ ์š”๋Ÿฐ ๋””๋ ‰ํ† ๋ฆฌ๋“ค์€ git์— ์˜ฌ๋ฆด ๋•Œ ignore ํŒŒ์ผ์— ํฌํ•จํ•ด์•ผ ํ•œ๋‹ค๋Š” ์ ๋งŒ ์ฐธ๊ณ ํ–ˆ๋‹ค.

- PEP?

Python Enhancement Proposal, ํŒŒ์ด์ฌ ์ปค๋ฎค๋‹ˆํ‹ฐ์—๊ฒŒ ์ œ๊ณต๋˜๋Š” ๋””์ž์ธ ๋ฌธ์„œ. ํŒŒ์ด์ฌ์˜ ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ์ด๋‚˜ ํ™˜๊ฒฝ์„ ์†Œ๊ฐœํ•  ๋•Œ ์“ฐ์ด๋Š” ๊ฒƒ์ด๋ผ๊ณ  ํ•œ๋‹ค. 1๋ฒˆ ๋ฌธ์„œ์— ๋‚˜์™€์žˆ๋‹ค.

add

pip install๊ณผ ๋™์ผํ•œ ๋ช…๋ น์–ด. potery add๋ฅผ ํ†ตํ•ด์„œ ์„ค์น˜์™€ ๋™์‹œ์— ์ž๋™์ ์œผ๋กœ pyproject.toml ํŒŒ์ผ์ด ์—…๋ฐ์ดํŠธ๋œ๋‹ค.

๋งŒ์•ฝ ์ด๋ฏธ ์กด์žฌํ•˜๋Š” ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•˜๋ ค๊ณ  ๋œจ๋ฉด ์˜ค๋ฅ˜ ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ด์ง€๋งŒ, ํŠน์ • ๋ฒ„์ „์„ ๋ช…์‹œํ•˜๋ฉด ๊ทธ ๋ฒ„์ „์— ๋งž๊ฒŒ ์—…๋ฐ์ดํŠธ๋ฅผ ํ•ด์ค€๋‹ค.

show

๊ฐ€๋Šฅํ•œ ๋ชจ๋“  ํŒจํ‚ค์ง€๋“ค์„ ๋ฆฌ์ŠคํŒ…ํ•ด์ค€๋‹ค. ๋งŒ์•ฝ ํŒจํ‚ค์ง€ ์ด๋ฆ„์œผ๋กœ command๋ฅผ ์น˜๋ฉด ํ•ด๋‹น ํŒจํ‚ค์ง€์— ๋Œ€ํ•ด ์„ค๋ช…๋„ ํ•ด์ค€๋‹ค. ์ด ์ ์ด pip์— ๋น„ํ•ด ์นœ์ ˆํ•œ๋“ฏ ๐Ÿค”

poetry show
poetry show pendulum

name        : pendulum
version     : 1.4.2
description : Python datetimes made easy

dependencies:
 - python-dateutil >=2.6.1
 - tzlocal >=1.4
 - pytzdata >=2017.2.2

remote index์— ์žˆ๋Š” ํŒจํ‚ค์ง€๋“ค์„ ์ฐพ์•„์ฃผ๋Š” ๋ช…๋ น์–ด. pendulum์„ ์„œ์น˜ํ•˜๋ฉด ๋” ๋งŽ์€ ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ๊ฐ€ ๋‚˜์˜ค์ง€๋งŒ ๋ธ”๋กœ๊น…์„ ์œ„ํ•ด ๋‘ ๊ฐœ๋งŒ ๊ฐ€์ ธ์™”๋‹ค.

โฏ poetry search pendulum

pendulum (2.1.2)
 Python datetimes made easy

pid-pendulum (0.0.13)
 A PID pendulum controller.

export

๋งŒ์•ฝ ๋‹ค๋ฅธ ํ˜•ํƒœ๋กœ ๋ณ€ํ™˜ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ž…๋ ฅํ•˜๋ฉด ๋œ๋‹ค. ๋‹ค๋ฅธ ํ˜•ํƒœ๋ผ๊ณ  ์„ค๋ช…๋˜์–ด ์žˆ๊ธด ํ•œ๋ฐ ์‚ฌ์‹ค์ƒ ํ˜„์žฌ ๊ธฐ์ค€์œผ๋กœ ์ง€์›ํ•˜๊ณ  ์žˆ๋Š” ํ˜•ํƒœ๋Š” requirements.txt ๋ฟ์ด๋ผ๊ณ  ํ•œ๋‹ค ๐Ÿ™„

poetry export -f requirements.txt > requirements.txt
profile
์ด์‚ฌ๊ฐ„ ๋ธ”๋กœ๊ทธ: yenilee.github.io

0๊ฐœ์˜ ๋Œ“๊ธ€