패키지를 이식 가능하게 만들기

Python으로 배우는 소프트웨어 공학 원칙

Adam Spannbauer

Machine Learning Engineer at Eastman

이식성 확보 단계

setup.py 파일

requirements.txt 파일

Python으로 배우는 소프트웨어 공학 원칙

이식 가능한 패키지 구조

패키지 구조

Python으로 배우는 소프트웨어 공학 원칙

requirements.txt 내용

work_dir/requirements.txt에서 작업

# Needed packages/versions
matplotlib
numpy==1.15.4
pycodestyle>=2.4.0

terminal에서 작업

datacamp@server:~$ pip install -r requirements.txt
Python으로 배우는 소프트웨어 공학 원칙

setup.py 내용

from setuptools import setup

setup(name='my_package',
      version='0.0.1',
      description='An example package for DataCamp.',
      author='Adam Spannbauer',
      author_email='[email protected]',
      packages=['my_package'],
      install_requires=['matplotlib',
                        'numpy==1.15.4',
                        'pycodestyle>=2.4.0'])
Python으로 배우는 소프트웨어 공학 원칙

install_requires vs requirements.txt

work_dir/requirements.txt에서 작업

# Specify where to install requirements from
--index-url https://pypi.python.org/simple/

# Needed packages/versions
matplotlib
numpy==1.15.4
pycodestyle>=2.4.0

문서: install_requires vs requirements 파일

Python으로 배우는 소프트웨어 공학 원칙

패키지 pip 설치

datacamp@server:~/work_dir $ pip install .
Building wheels for collected packages: my-package
  Running setup.py bdist_wheel for my-package ... done
Successfully built my-package
Installing collected packages: my-package
Successfully installed my-package-0.0.1
Python으로 배우는 소프트웨어 공학 원칙

연습해 봅시다

Python으로 배우는 소프트웨어 공학 원칙

Preparing Video For Download...