パッケージを配布可能にする

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 files

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...