Steps to Publish Your Own Python Package to The Python Package Index (PyPI)

Swayanshu Shanti Pragnya
2 min readJan 18, 2022
Ref: https://pypi.org/project/Cls-Evaluation/0.0.1/

Generally, we import multiple libraries or functions to solve a specific problem. We can make it easier by combining all of those functions. It is already extremely simple to create and publish your own package thanks to Python.

In this article I will explain the following points:

· Steps to publish your own python package to PyPI.

· Solving a few common errors while publishing.

· Install and evaluate the results of your python package.

Let’s begin!

Make a directory for your package that contains the files listed below:

Here Cls_evaluation is my module name which contains a bunch of functions in the __init__.py file.

CHANGELOG.txt file: Write all the modifications in each release.

MANIFEST.in file: Mention the type of files

Example- .txt, .py

README.txt file: Summary of your package

LICENSE.txt: Add a copy of your license.

Check different classifiers in this link (https://pypi.org/classifiers/)

After creating all the files now let's publish by using Windows Powershell.

Solving a few common errors while publishing

  1. Twine error: Make sure to install Twine by using this command

pip install twine

2. SSL is not found error: Check this tutorial (https://www.youtube.com/watch?v=mN8SLBsvSCU)

3. Classifier error: Copy the classifier from this site (https://pypi.org/classifiers/)

Install and evaluate the results of your python package

Installation

Install the dependencies from setup.py.

pip install Cls-Evaluation==0.0.1

Simple Demo

from setuptools import setup, find_packages
import Cls_evaluation as cl
conf_matrix = cl.confusion_matrix([1,0,0,1,1,0],[0,1,0,1,1,1])
print("Accuracy", cl.acc(conf_matrix))
print("Precision",cl.precision(conf_matrix))
print("Recall",cl.recall(conf_matrix))
print("F1 score", cl.F1(conf_matrix))
print("FDR",cl.FDR(conf_matrix))
Accuracy 0.5
Precision 0.5
Recall 0.6666666666666666
F1 score 0.5714285714285714
FDR 0.5

I personally referred to this video tutorial (https://www.youtube.com/watch?v=zhpI6Yhz9_4), please do check.

References

[1] https://www.python.org/

[2] https://pypi.org/

[3] https://pypi.org/project/twine/

[4] https://code.visualstudio.com/download

[5] https://docs.microsoft.com/en-us/powershell/scripting/overview?view=powershell-7.2

[6] https://devblogs.microsoft.com/scripting/table-of-basic-powershell-commands/

[7] https://opensource.org/licenses/MIT

--

--

Swayanshu Shanti Pragnya

M.S in CS Data Science and Bio-medicine(DSB)|Independant Researcher | Philosopher | Artist https://www.linkedin.com/in/swayanshu/