Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
Tags
- Peephole Connection
- classification
- AI
- Inception V1
- iTerm2
- Generative
- Skip Connection
- Gated Skip Connection
- Linear
- jupyter
- sigmoid
- Residual Connection
- python
- Regression
- DL
- GoogLeNet
- version
- RNN
- ResNet
- Inception Module
- Bottleneck Layer
- Manager
- vim-plug
- cnn
- Optimizer
- DCGAN
- GCN
- Vanilla RNN
- virtualenv
- Skip Connectioin
Archives
- Today
- Total
IT Repository
Poetry 설치 및 세팅 본문
- 프로젝트별 가상환경 관리
- 가상환경의 디펜던시 관리 (npm, yarn 과 유사하게 lock 파일을 통해 디펜던시 관리함)
- 기존에 pyenv만 사용하다가 poetry를 테스트하면서 기록함
- 테스트 환경: docker ubuntu 컨테이너
java 계열: maven, gradle
js 계열: npm, yarn
다른 언어의 툴과는 달리 파이썬에서 제공하는 pip는 종속성 관리를 해주지 않는다
즉, A 패키지와 B 패키지의 설치에 필요한 디펜던시가 서로 경합하면 pip는 이를 신경쓰지 않는다
그리고 이는 나중에 해결하기 힘든 종속성 관련 에러를 야기하게 된다
가상환경을 구성하는 방법을 생각할 수 있겠지만, 이는 각 환경을 격리하는 것과는 별개로
설치시 pip로 인해 발생하는 문제이기에 원론적인 해결책이 되지 않는다
따라서, npm, yarn 처럼 lock 파일을 통해 종속성을 관리하는 poetry를 사용하기로 했다
- 기본 사용 (프로젝트마다 하나의 가상환경 사용)
# @vscode
{
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
}
# 1. Installation: Linux
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
export PATH="$HOME/.poetry/bin:$PATH"
# 1. Installation: Windows
(Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py -UseBasicParsing).Content | python
setx PATH "%USERPROFILE%\.poetry\bin;%PATH%"
# 2. Version
poetry --version # 1.1.12
# 3. Configure
# poetry config --local virtualenvs.in-project
# true: use only venv at current project (.venv)
# false: make each venv per python version at $(poetry config virtualenvs.path)
poetry config virtualenvs.in-project true
# 4. Start project: new
poetry new --name <PROJECT_NAME> --src <PROJECT_PATH>
# 5. Start project: init
mkdir <PROJECT_NAME>
cd <PROJECT_NAME>
poetry config --local virtualenvs.in-project true
poetry init
# 6. Modify repository (OPTIONAL)
# repo is a short alias for repositories
# ref. https://python-poetry.org/docs/repositories/
poetry config --local repositories.<REPOSITORY_NAME> <REPOSITORY_URL>
poetry config --unset --local repo.<REPOSITORY_NAME>
# 7. Set dependency
cd <PROJECT_PATH>
poetry add <PROD_DEPENDENCY>
poetry add -D <DEV_DEPENDENCY>
poetry remove <DEPENDENCY>
poetry install
poetry env info
# 8. Run with activation
# use `exit` to deactivate, when using `poetry shell`
# cause)
# `poetry shell` is to build up new session
# `source` is to activate venv in current session
source .venv/bin/activate # or poetry shell
(.venv) python --version # 3.8.12
(.venv) deactivate # or exit
# 8. Run with no activation
poetry run python --version # 3.8.12
- 멀티 가상환경 (단일 프로젝트에 다양한 파이썬 버전별 가상환경 사용)
# poetry config --local virtualenvs.in-project false
# 1. Install different python versions
pyenv install <PYTHON_VERSION>
ls -al $HOME/.pyenv/versions | grep <PYTHON_VERSION>
# 2. Use python version
# e.g. poetry env use $HOME/.pyenv/versions/3.7.4
poetry env use <PYTHON_VERSION_1>
poetry env use <PYTHON_VERSION_2>
poetry env list
# 3. Result
# Current python version is <PYTHON_VERSION_2> (last used)
**참고**
- pyproject.toml 설정 (https://python-poetry.org/docs/pyproject/)
- poetry.toml 설정 (https://python-poetry.org/docs/configuration/#available-settings)
'환경설정' 카테고리의 다른 글
Jenv 설치 및 세팅 (0) | 2022.01.23 |
---|---|
Pyenv 설치 및 세팅 (0) | 2022.01.23 |
MacOS iTerm2 설정하기 (0) | 2020.04.20 |
따라만 하면 되는 Jupyter Lab 설치 (4) | 2020.01.23 |
ipynb 파일을 티스토리에 알맞게 Convert 하기 (0) | 2020.01.05 |
Comments