Source : https://github.com/python-poetry/poetry
GitHub - python-poetry/poetry: Python packaging and dependency management made easy
Python packaging and dependency management made easy - GitHub - python-poetry/poetry: Python packaging and dependency management made easy
github.com
Home : https://python-poetry.org/docs/
Introduction | Documentation | Poetry - Python dependency management and packaging made easy
If you installed using the deprecated get-poetry.py script, you should use it to uninstall instead: curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3 - --uninstall
python-poetry.org
Poetry는 Python의 종속성 및 가상 환경 관리에 유용한 패키지
Poetry can be used to:
- Create new Python projects together with virtual environments
- Initialize existing projects with a virtual environment
- Manage project dependencies
- Package libraries
Poetry 설치 및 삭제
1. 설치
Poetry는 Python 가상 환경 생성을 처리하므로 가상 환경 자체 내부에 설치해서는 안됩니다. 사용자 사이트 패키지 또는 전역 사이트 패키지에 설치할 수 있지만 사용자 사이트 패키지가 권장된다.
cmd에서
$ pip install --user poetry # user site-packages에 설치
or
powershell에서
$ (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -
※ 사용자 환경 변수에 user site packages 등록 필요 : path 변수
2. 삭제
$ (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py - --uninstall
프로젝트 트리 구성
1. 프로젝트 폴더 새로 만들기 : my-project
$ poetry new <project-directory>
2. 기존 프로젝트에 적용
폴더 초기화 - pyproject.toml(프로젝트 환경 저장)만 추가
cd <pre-existing-project-directory>
poetry init
3. pyproject.toml : https://www.python.org/dev/ peps/pep-0518/
[tool.poetry]
name = "my-project" version = "0.1.0" description = ""
authors = ["Michał Jaworski <swistakm@gmail.com>"]
[tool.poetry.dependencies] python = "^3.9"
[tool.poetry.dev-dependencies] pytest = "^5.2"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
• [tool.poetry]: 배포 시 정보
• [tool.poetry.dependencies]: project dependencies. requirements.txt의 기능
• [tool.poetry.dev-dependencies]: 테스트 프레임워크, 생산성 도구와 같은 개발 단계에서 요구되는 종속성 목록
• [build-system]: Poetry 상세
가상환경에 Package 설치
1. Poetry 가상환경 활성화
$ cd <project-directory>
$ poetry shell
2. package 설치
$ poetry add <package-name>
3. package lock
$ poetry lock
'python package' 카테고리의 다른 글
openpyxl 사용법 (0) | 2022.11.02 |
---|---|
gTTs 사용법 (0) | 2022.11.02 |
google trans 사용법 (0) | 2022.11.02 |