To make your code more visible, and easy for others to install and use, you can upload it to PyPI (The Python Package Index). PyPI is a repository of software for the Python programming language. It helps people to find and install software developed and shared by the Python community.

If you have some python code that you would like to make available to others the first step is to make sure it is in a publicly viewable repository at a site like GitHub or BitBucket.

The documentation for creating a PyPI package is the ultimate authority on packaging python code for distribution via PyPI. However, in many simple cases much of the information is superfluous and possibly confusing. If you have a single python source file (or perhaps a handful of source files) you can follow this clear and simple explanation of the minimum requirement for publishing your code on PyPI.

As an example, some python code to calculate rank histograms by CoE researcher Oliver Angélil was made into a PyPI package. The GitHub repository for rank-histogram shows the relatively simple directory structure required to create the PyPI package for rank-histogram. All that was required was to create an empty file called __init__.py and a setup.py file:
from setuptools import setup
 
setup(
    name='rank-histogram',
    description='Python function that takes model data, obs data, and a boolean mask to generate a rank histogram.',
    version='0.2',
    url='https://github.com/oliverangelil/rankhistogram',
    install_requires=['numpy','scipy'],
    author='Oliver Marc Angelil',
    author_email='molofishy@gmail.com',
    py_modules=['ranky'],
    license='MIT',
    keywords='rank histogram climate ensemble Hamil'
)

The instructions use the python program twine which is available in the CMS conda distribution.

Other resources