Contribute Your Project to the World: Submit a Package to PyPI
The PyPI (Python Package Index) is a repository of software for the Python programming language. There are currently 45k packages. Anyone can upload a Python project on it. Since your project being successfully uploaded, everybody in the world can simply install it by pip or easy_install. It's significant to learn how to submit a project on PyPI.
Create the setup.py
Assume that you have a project named my_project, firstly you need to move it into an empty folder, then create a file named setup.py like this:
my_package/
my_project/
__init__.py
your_code.py
setup.py
README
Writing the Setup Script
import os
import sys
from setuptools import setup, find_packages
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
setup(
name = "the_project_name",
version = "0.0.1",
packages = find_packages(),
include_package_data = True,
entry_points = {
'console_scripts' : [
'my_command = my_project.main:main'
],
}, # The 'entry_points' creates a command line tool.
package_data = {
'crotal' : [ '*.data' ]
},
install_requires = ['Jinja2==2.7.1','markdown==2.3.1'], # The third-party librarys your project need.
author = "myname",
author_email = 'myemail@email.com',
url = "http://my-site.com",
description = 'Some words to describe the project.',
long_description = read('README'),
)
Package your project
Use the following command to package your project.
python setup.py bdist egg # create an "egg" distribution
python setup.py sdist # create a source distribution (tarball)
Once your project is successfully packaged, you are ready to submit it to PyPI.
Contribute it to PyPI
Firstly, you need to register an account if you don't have one. Then you need to do the following two steps:
- Register your package:
python setup.py register - Upload your project:
python setup.py sdist upload