pypi is one of python’s strength. A place hosting the largest collection of python 3rd party modules. Every user can upload his, yes, awesome !

How to proceed ?

Let us say you’ve got a module called printstrawberry in a file named printberry.py

The printstrawberry module prints the word strayberry the number of times you specify

def printstrawberry(x):
    for i in range int(x):
        print('strawberry')

remember : to import it you do :

import printberry
printberry.printstrawberry(3)

outputs

strawberry
strawberry
strawberry

now place the printberry.py im a folder

in the same folder add a setup.py file

in the setup.py put the followng :
from distutils.core import setup

setup(
    name='printberry',
    version='1.0.0',
    py_modules=['printstrawberry'],
    author='YOUR NAME',
    author_email='YOUR MAIL',
    url='HOMEPAGE URL',
    description='DESCRIPTION',
    )

now go to https://pypi.python.org/pypi and register an account

now cd into the folder holding the two files

type :

python setup.py sdist

then # this install the module into your py distribution

python setup.py install

then register, choose 1 then y

python setup.py register

then

python setup.py sdist upload

ok, finished

It is really, really, really good. For updates just reupload, change version and of course modify codes before

users worldwide can now

pip install printberry

you can view one i uploaded here:

https://pypi.python.org/pypi/printtest/1.0.0

 


In need of managing bookmarks online? Try the awesome Bookmark Ninja

Advertisements