Python module distribution
Modules in Python
Modules are everywhere
Introduction In order to share your newly created module, you need to prepare a distribution. This is the Python name given to the collection of files that together allow you to build, package, and distribute your module. The Python Package Index (or PyPI for short) provides a centralized repository for third-party Python modules on the Internet. When your module is ready, you’ll use PyPI to publish your module and make your code available for use by others. Once a distribution exists, you can install your module into your local copy of Python, as well as upload your module to PyPI to share with the world.
Step1: Creating a folder for your module. With the folder created, copy your ‘.py’ module file into the folder. Let’s call the folder “modist” Step 2: Create a file called “setup.py” in your new folder. This file contains metadata about your distribution. Edit this file by adding the following code:
Folder structure
Build a distribution file Step 3: Open a terminal window within your ‘mymoddist’ folder and type a single command: C:\python27\mymoddist\python setup.py sdist. Or setup.py sdist A collection of status messages appears on screen, confirming the creation of your distribution.
Output screen
Install your distribution into your local copy of Python. Staying in the terminal, type this command: sudo python3 setup.py install. python setup.py install. Another bunch of status messages appear on screen, confirming the installation of your distribution
Register with the PyPI website Begin by surfing over to the PyPI website at and
Upload your code to PyPI
With your registration details entered and saved, you are now ready to upload your distribution to PyPI. Another command line does the trick: