패키지 배포하기

Python 패키지 개발하기

James Fulton

Climate informatics researcher

PyPI

Python 패키지 인덱스

  • pip은 여기서 패키지를 설치합니다
  • 누구나 패키지를 업로드할 수 있습니다
  • 유용해질 때 바로 업로드하는 것이 좋습니다
1 https://pypi.org/
Python 패키지 개발하기

배포판

  • 배포 패키지: 설치 가능한 형태로 묶은 패키지
  • 소스 배포판: 주로 소스 코드로 이루어진 배포 패키지
  • 휠 배포판: 더 빠른 설치를 위해 처리된 배포 패키지
Python 패키지 개발하기

배포판 빌드 방법

python setup.py sdist bdist_wheel

  • sdist = 소스 배포판
  • bdist_wheel = 휠 배포판
mysklearn/
|-- mysklearn
|-- setup.py
|-- requirements.txt
|-- LICENSE
|-- README.md

|-- dist <---
| |-- mysklearn-0.1.0-py3-none-any.whl
| |-- mysklearn-0.1.0.tar.gz
|-- build |-- mysklearn.egg-info
Python 패키지 개발하기

패키지 배포하기

배포판을 PyPI에 업로드

twine upload dist/*

배포판을 TestPyPI에 업로드

twine upload -r testpypi dist/*
mysklearn/
|-- mysklearn
|-- setup.py
|-- requirements.txt
|-- LICENSE
|-- README.md
|-- dist
|   |-- mysklearn-0.1.0-py3-none-any.whl
|   |-- mysklearn-0.1.0.tar.gz
|-- build
|-- mysklearn.egg-info
Python 패키지 개발하기

다른 사람이 패키지를 설치하는 방법

PyPI에서 설치

pip install mysklearn

TestPyPI에서 설치

pip install --index-url         https://test.pypi.org/simple 
            --extra-index-url   https://pypi.org/simple
            mysklearn
Python 패키지 개발하기

연습해 봅시다!

Python 패키지 개발하기

Preparing Video For Download...