はじめに
前回作成したPythonプログラムからGmailを送信するプログラムをパッケージ化し、グローバルにimport
できるようにします。
githubにリポジトリを作成したのでよろしければ御覧ください。
パッケージ化
ディレクトリ内のトップレベルにsetup.py
を作成します。
from setuptools import setup
setup(
name='pymail',
version='1.0',
description='Python Gmail Sender',
author='shuyafukushima',
author_email='',
packages=['pymail'],
install_requires=[],
# install_requires=['wheel', 'bar', 'requests] 依存する外部ライブラリがあれば記述
)
setup.py
と同じ階層で pip install .
を実行
$ pip install .
これでPythonのPathが通っているところからならどこでもimport pymail
ができるようになりました。
下記でインストールされたことが確認できます。
$ pip list | grep pymail
README.mdを作成したので御覧ください。