パッケージを移植可能にする

Pythonで学ぶSoftware Engineeringの原則

Adam Spannbauer

Machine Learning Engineer at Eastman

移植性のための手順

setup.py ファイル

requirements.txt ファイル

Pythonで学ぶSoftware Engineeringの原則

移植可能なパッケージ構成

パッケージ構成

Pythonで学ぶSoftware Engineeringの原則

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で学ぶSoftware Engineeringの原則

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で学ぶSoftware Engineeringの原則

install_requires と 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 と requirements ファイル

Pythonで学ぶSoftware Engineeringの原則

自作パッケージを 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で学ぶSoftware Engineeringの原則

Let's Practice

Pythonで学ぶSoftware Engineeringの原則

Preparing Video For Download...