반응형
핵심명령어
- Python setup.py bdist_wheel
- twine upload dist/xxx-xxxx-xxxx-xxx.whl
pip을 이용하여 파이썬에 필요한 라이브러리들을 다운받아 사용하는데 반대로 직접 라이브러리를 올려보는 방법을 조사해보았다.
패키기 모듈 설치
- setuptools
- wheel
- twine
1. 패키지 만들기
- Pypi 규격대로 패키지 만들어야한다.
- makePackage 라는 패키지 폴더를 하나만들고, module을 담아 놓을 모듈 폴더, setup.py를 만든다.
2. setup.py 구성
from setuptools import setup
setup(
name='module-apis', #module 이름
version='1.0.0.1',
description='',
long_description= '',
author='',
author_email='',
url='',
license='MIT',
py_modules=['pymodule'], #업로드할 module
python_requires='>=3', #파이썬 버전
install_requires=[""], #module 필요한 다른 module
packages=['modulTest'] #업로드할 module이 있는 폴더
)
3. 배포할 폴더 구성
moduleTest 폴더에 들어있는 구성은 아래와 같다.
- __init__.py 구성
__all__=['pypitest']
- pypitest.py
def add(self, a, b): return a+b
4. 패키지빌드
업드로할 패키지 폴더를 아래와 같은 명령어를 통해 빌드를 해준다.
빌드 성공 시 아래와 같은 moduleTest.egg-info 폴더와 dist 폴더에 파일이 생성된다.
5. 패키지 Pypi 배포
우리가 업로드 할 파일은 dist에 있는 파일이다
아래 명령어를 이용하여 패키지 배포!
명령어 입력 후 Pypi ID/PW 입력하면 끝
더 자세한 사항을 알고싶으면 아래 홈페이지 참고
Packaging Python Projects — Python Packaging User Guide
setup.cfg is the configuration file for setuptools. It tells setuptools about your package (such as the name and version) as well as which code files to include. Eventually much of this configuration may be able to move to pyproject.toml. Open setup.cfg an
packaging.python.org
반응형
'프로그래밍언어 > python' 카테고리의 다른 글
[파이썬]class 정리 (상속, 다중상속)+pass, super 사용법 (0) | 2021.02.05 |
---|---|
[파이썬] class 정리- 사용법 (0) | 2021.02.04 |
[파이썬] pickle 피클 사용법 (0) | 2021.02.03 |
[파이썬] 파일입출력(file IO) 읽고 쓰기 (0) | 2021.01.23 |
[파이썬] 출력옵션(정렬, 콤마, 소수점) (0) | 2021.01.19 |
댓글