.venv/lib/python3.9/site-packages/ 등으로 버전별 패키지를 관리하는게 썩 맘에 들지 않았다.
python 진영에서도 공식은 아니지만 비슷한 pipenv, poetry 가 있다.
pipenv 는 속도와 성능도 그렇고 좀 지난 오픈소스고 최근에는 poetry poetry.lock 으로 정확한 버전 고정을 하는 기능과 성능등에서 앞선다.
poetry 는 setup.py, requirements.txt, setup.cfg, MANIFEST.in, Pipfile 기능을 pyproject.toml 하나로 관리한다.
# pip 설치
pip install poetry
# brew 로 설치
brew install poetry
# 쉘별 tab 자동환경 활성화 방법
# 현재 프로젝트의 의존성(패키지) 설치
poetry install
# 패키지 추가
poetry add 패키지명
# 패키지 제거
poetry remove 패키지명
# 패키지 정보
poetry show
# lock 파일 생성
poetry lock
#####
# pyproject.toml 작성시 poetry 방식(Poetry backend)
[tool.poetry]
name = "ysoftman_lemon"
version = "0.1.0"
description = "test package"
authors = ["ysoftman <ysoftman@gmail.com>"]
license = "MIT"
readme = "README.md"
[tool.poetry.dependencies]
python = ">=3.12"
[tool.poetry.scripts]
# ysoftman_lemon 으로 실행하기 위해서
# PyPI/Poetry wheel에서는 스크립트 이름에 하이픈(-) 금지
ysoftman_lemon = "ysoftman_lemon.main:main"
# tool.poetry.packages must be array
[[tool.poetry.packages]]
include = "ysoftman_lemon"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
#####
# pyproject.toml 작성시 PEP621 project 방식(setuptools backend)
[project]
name = "ysoftman-lemon"
version = "0.1.0"
description = "test package"
license = { text = "MIT" }
authors = [{ name = "ysoftman", email = "ysoftman@gmail.com" }]
readme = "README.md"
requires-python = ">=3.12"
dependencies = []
[project.urls]
repository = "https://github.com/ysoftman/ysoftman-lemon"
homepage = "https://github.com/ysoftman/ysoftman-lemon"
[project.scripts]
my_package_cli = "lemon.main:main"
[build-system]
requires = ["setuptools>=61.0", "wheel"]
build-backend = "setuptools.build_meta"
comments:
댓글 쓰기