0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[Python]setup.pyで自作パッケージの配布

Last updated at Posted at 2022-04-26

はじめに

前回作成した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を作成したので御覧ください。

参考

https://docs.python.org/3/distutils/setupscript.html

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?