Here, we are going to learn the steps to publishing a basic python package.

When I decided to publish a Python package for the first time, I had difficulties finding resources for the beginner. So, here it is- the basics to publishing a Python Package in PyPi and getting your work out there.

Why Develop a Python Package?

By developing and publishing a python package, you will enable others to use (and cite!) your work. Packages can help facilitate collaboration with others doing similar work and get you publicity on your work! Even internally, using a Python Package can help standardize your workflow. So what are you waiting for? Get that code up on PyPi and start collaborating and standardizing your workflow.

Basic Assumptions

This is what I expect you to do prior to the start of the tutorial:

1. Install pip if you don’t already have it.

2. Get a PyPi account if you don’t already have one (I recommend using a non-university, professional email for this)

3. Have some function-based (should already be formatted as functions) code that you want to publish as a PyPi package

4. Have a GitHub and have a basic understanding of git

Deciding on a License

First things first, decide on a license for your package. Here is a helpful resource for deciding on the best license for you!

Naming your Package

Pick a unique name that is memorable and relates to what the package does. Keep in mind that Python packages should have short, all lowercase names and that the use of underscores is discouraged. You can search on pypi.org to see if your name is unique. You should always check and make sure your desired python package name is not going to override anything (for example, ‘list’ already has a meaning in Python- you would not want to name your package “list”).

Check here for names to avoid.

Documenting your Code

This is an important section, and you will probably spend most of your time here! Think of all the ways others may want to use your code and make sure your functions are either a) generalize-able (preferred) or b) very well documented so others can use your code easily.

Document each function using the following comment at the beginning of each function:

	    """
	        Brief description of what this function does. 
	        Args:
	          argument1 (argument type, ie string): description of argument
	          argument2 (argument type, ie string): description of argument
	        Returns:
	            return1 (argument type, ie string): description of return
	    """

#software-development #python-packages #beginner-coding #pypi #python #programming

A Beginner’s Guide to Publishing Packages on the Python Package Index
1.10 GEEK