python module distribution. modules in python modules are everywhere
TRANSCRIPT
![Page 1: Python module distribution. Modules in Python Modules are everywhere](https://reader035.vdocuments.site/reader035/viewer/2022062222/5697bf771a28abf838c81206/html5/thumbnails/1.jpg)
Python module Python module distributiondistribution
![Page 2: Python module distribution. Modules in Python Modules are everywhere](https://reader035.vdocuments.site/reader035/viewer/2022062222/5697bf771a28abf838c81206/html5/thumbnails/2.jpg)
Modules in PythonModules in Python
![Page 3: Python module distribution. Modules in Python Modules are everywhere](https://reader035.vdocuments.site/reader035/viewer/2022062222/5697bf771a28abf838c81206/html5/thumbnails/3.jpg)
Modules are everywhereModules are everywhere
![Page 4: Python module distribution. Modules in Python Modules are everywhere](https://reader035.vdocuments.site/reader035/viewer/2022062222/5697bf771a28abf838c81206/html5/thumbnails/4.jpg)
IntroductionIntroduction In order to share your newly created module, you need In order to share your newly created module, you need
to prepare a distribution. This is the Python name given to prepare a distribution. This is the Python name given to the collection of files that together allow you to build, to the collection of files that together allow you to build, package, and distribute your module.package, and distribute your module.
The The Python Package Index (or Python Package Index (or PyPI for short) PyPI for short) provides a centralized repository for third-party Python provides a centralized repository for third-party Python modules on the Internet. When your module modules on the Internet. When your module is readyis ready, , you’ll use PyPI to publish your module and make your you’ll use PyPI to publish your module and make your code available for use by others. code available for use by others.
Once a distribution exists, you can install your module Once a distribution exists, you can install your module into your local copy of Python, as well as upload your into your local copy of Python, as well as upload your module to PyPI to share with the world. module to PyPI to share with the world.
![Page 5: Python module distribution. Modules in Python Modules are everywhere](https://reader035.vdocuments.site/reader035/viewer/2022062222/5697bf771a28abf838c81206/html5/thumbnails/5.jpg)
Step1: Creating a folder for your module.Step1: Creating a folder for your module. With the folder created, copy your ‘.py’ module file into the folder. Let’s With the folder created, copy your ‘.py’ module file into the folder. Let’s
call the folder “modist”call the folder “modist”
Step 2: Create a file called “setup.py” in your new folder.Step 2: Create a file called “setup.py” in your new folder. This file contains metadata about your distribution. Edit this file by adding This file contains metadata about your distribution. Edit this file by adding
the following code:the following code:
![Page 6: Python module distribution. Modules in Python Modules are everywhere](https://reader035.vdocuments.site/reader035/viewer/2022062222/5697bf771a28abf838c81206/html5/thumbnails/6.jpg)
Folder structureFolder structure
![Page 7: Python module distribution. Modules in Python Modules are everywhere](https://reader035.vdocuments.site/reader035/viewer/2022062222/5697bf771a28abf838c81206/html5/thumbnails/7.jpg)
Build a distribution fileBuild a distribution file
Step 3: Open a terminalStep 3: Open a terminal window within your ‘mymoddist’ folder and type a single window within your ‘mymoddist’ folder and type a single
command: command:
C:\python27\mymoddist\python setup.py sdist.C:\python27\mymoddist\python setup.py sdist.
OrOr
lab1@lab1-ThinkCentre-M58p:~/modist$python setup.py :~/modist$python setup.py sdistsdist
A collection of status messages appears on screen, A collection of status messages appears on screen, confirming the creation of your distribution.confirming the creation of your distribution.
![Page 8: Python module distribution. Modules in Python Modules are everywhere](https://reader035.vdocuments.site/reader035/viewer/2022062222/5697bf771a28abf838c81206/html5/thumbnails/8.jpg)
Output screen Output screen
![Page 9: Python module distribution. Modules in Python Modules are everywhere](https://reader035.vdocuments.site/reader035/viewer/2022062222/5697bf771a28abf838c81206/html5/thumbnails/9.jpg)
Install your distribution into Install your distribution into your local copy of Python.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
![Page 10: Python module distribution. Modules in Python Modules are everywhere](https://reader035.vdocuments.site/reader035/viewer/2022062222/5697bf771a28abf838c81206/html5/thumbnails/10.jpg)
Register with the PyPI website
Begin by surfing over to the PyPI website at http://pypi.python.org/ and
![Page 11: Python module distribution. Modules in Python Modules are everywhere](https://reader035.vdocuments.site/reader035/viewer/2022062222/5697bf771a28abf838c81206/html5/thumbnails/11.jpg)
Upload your code to PyPI
![Page 12: Python module distribution. Modules in Python Modules are everywhere](https://reader035.vdocuments.site/reader035/viewer/2022062222/5697bf771a28abf838c81206/html5/thumbnails/12.jpg)
With your registration details entered and saved, you are now ready to upload your distribution to PyPI. Another command line does the trick: