Saturday, December 29, 2018

Installing Your Own Personal Python Module

That is, when you do

import myModule

Python shouldn't barf.

Put your .py file in a reasonable place (i.e., a directory named meaningfully :)

In the same directory, have a setup.py file that looks like

from setuptools import setup

setup (
    name='myModule',
    version='1.0',
    description='A useful personal module',
    author='me',
    author_email='me@memail.com',
    url='me.com',
    py_modules=['myModule'],
)

Then, run :

$ python setup.py sdist

You will see a warning that there is no README file.

Now, to install :

$ pip install /path/to/myModule-1.0.tar.gz

Easy enough?

No comments: