Download presentation
Presentation is loading. Please wait.
Published byAlyson Thompson Modified over 9 years ago
1
Python module distribution
2
Modules in Python
3
Modules are everywhere
4
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.
5
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:
6
Folder structure
7
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 lab1@lab1-ThinkCentre-M58plab1@lab1-ThinkCentre-M58p:~/modist$python setup.py sdist lab1@lab1-ThinkCentre-M58p A collection of status messages appears on screen, confirming the creation of your distribution.
8
Output screen
9
Install your distribution into your local copy of Python. Staying in the terminal, type this command: sudo python3 setup.py install. lab1@lab1-ThinkCentre-M58p:~/modist$ python setup.py install. Another bunch of status messages appear on screen, confirming the installation of your distribution
10
Register with the PyPI website Begin by surfing over to the PyPI website at http://pypi.python.org/ and
11
Upload your code to PyPI
12
With your registration details entered and saved, you are now ready to upload your distribution to PyPI. Another command line does the trick:
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.