개요

python으로 직접 패키지를 만들일이 있어 방법을 찾아 본 뒤 정리해둔다.

그중에서도 poetry로 하는 방법을 찾아 정리해둔다.

poetry 설치

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

poetry 새 프로젝트 만들기

poetry new ventus

project toml

[tool.poetry]
name = "ventus"
version = "0.1.0"
description = "SLI Cloud Framework"
authors = ["Kwangsik Lee <lks21c.lee@samsung.com>"]

[tool.poetry.dependencies]
python = "^3.6"
boto3 = "^1.21.42"
fire = "^0.4.0"

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

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

virtual env 활성화

poetry shell

의존성 설치

$ poetry install

Package operations: 17 installs, 0 updates, 0 removals

  • Installing six (1.16.0)
  • Installing jmespath (0.10.0)
  • Installing python-dateutil (2.8.2)
  • Installing urllib3 (1.26.9)
  • Installing botocore (1.24.42)
  • Installing pyparsing (3.0.7)
  • Installing attrs (21.4.0)
  • Installing more-itertools (8.12.0)
  • Installing packaging (21.3)
  • Installing pluggy (0.13.1)
  • Installing py (1.11.0)
  • Installing s3transfer (0.5.2)
  • Installing termcolor (1.1.0)
  • Installing wcwidth (0.2.5)
  • Installing boto3 (1.21.42)
  • Installing fire (0.4.0)
  • Installing pytest (5.4.3)

Installing the current project: ventus (0.1.0)

wheel 패키지 만들기

$ poetry build

Building ventus (0.1.0)
  - Building sdist
  - Built ventus-0.1.0.tar.gz
  - Building wheel
  - Built ventus-0.1.0-py3-none-any.whl

참고정보

  • https://www.youtube.com/watch?v=Xf8K3v8_JwQ