Modularization - minnie0531/fastapi-template GitHub Wiki
Python modulation ํ๋ ๋ฐฉ๋ฒ
wheel ํ์ผ ๋ง๋ค๊ธฐ
-
์ฌ์ฉํ๋ packages
pip install wheel pip install setuptools (๋์ฒด๋ก ๊ธฐ๋ณธ์ ์ผ๋ก ๊น๋ ค ์๋ ๊ฒ ๊ฐ์) pip install twine -
ํด๋๋ฅผ ๋ง๋ค๊ณ ๊ทธ ์์ ํ์๋ก ํ๋ ๋ก์ง์ ๊ตฌํํจ.
-
ํด๋์ ์์ ๋ ๋ฒจ์์ setup.py ์์ฑ
from setuptools import setup, find_packages
setup(name='aaa_custom', # ํจํค์ง ๋ช
version='1.0.0.0', #version
description='Test aaa module',
author='minnie',
author_email='[email protected]',
url='test.url.com',
license='MIT', # MIT์์ ์ ํ ํ์ค ๋ผ์ด์ผ์ค ๋ฐ๋ฅธ๋ค
py_modules=['aaa_helper'], # ํจํค์ง์ ํฌํจ๋๋ ๋ชจ๋
python_requires='>=3',
install_requires=['redis','pickle','os'], # ํจํค์ง ์ฌ์ฉ์ ์ํด ํ์ํ ์ถ๊ฐ ์ค์น ํจํค์ง
packages=['aaa_custom'] # ํจํค์ง๊ฐ ๋ค์ด์๋ ํด๋
)
- ๋ค์ command๋ก build (pip install wheel ํ์ธ) python setup.py bdist_wheel
- whlํ์ผ ์์ฑ ํ์ธ dist/testPackage-1.0.0.0-py3-none-any.whl
whlํ์ผ ์ ๋ก๋
- configuration ์ค์
# Private pypi ์ฌ์ฉ์ ~/.pypirc์ internal url์ ์ค์ ํด ์ค์ผ ํจ.
# ํน์ ๋ช
๋ น์ด์ ์ต์
์ผ๋ก internal url์ค์
[distutils]
index-servers =internal
[internal]
repository: [http://localhost:8080](http://localhost:8080/)
username:yourusername
password:yourpassword
- Upload wheel ํ์ผ
- Upload with twine twineย uploadย dist/testPackage-1.0.0.0-py3-none-any.whl
- Upload with setuptools python setup.py sdist upload -r internal