How do I create a pip installable project?
I wish PasteScript
did the job because it seems straightforward but it simply didn't work for me. I got my code uploaded to the pip
repository with Peter Down's quick but well-explained tutorial.
Also, remember that if you are trying to have your code import
from the package, you have to put it in __init__.py
, which is sufficient for most projects.
You need to
- Write a setup.py file
- Run python setup.py sdist tar gzipped file.
- Run register or submit the project using the web form.
You can register using:
>> python setup.py register
An exmaple setup.py file is:
#!/usr/bin/env python
from distutils.core import setup
setup(name='Distutils',
version='1.0',
description='Python Distribution Utilities',
author='Greg Ward',
author_email='[email protected]',
url='http://www.python.org/sigs/distutils-sig/',
packages=['distutils', 'distutils.command'],
)
Users will then just have to upack the taz file and run install..
>> python setup.py install
Or, if you're feeling fancy (read: lazy)...
sudo easy_install PasteScript
paster create mynewpackage
- answer the questions!
cd mynewpackage
python setup.py sdist
python setup.py register
- answer the questions!
Seems like more steps, but the PasteScript package handles a lot of the dirty work. Do yourself a favor and install it, use it, and never look back ;)