Kyle Pericak

"It works in my environment."

Fri 06 September 2019

Upload a Python Package to PyPi

Posted by Kyle Pericak in development   

This post is linked to from the FOSS Python App Project

At a high level, the steps to upload a package to PyPi are as follows:

  1. Write the project code
  2. Create a release on GitHub and put it in the download_url of
  3. Write a file to build and describe the project
  4. Write a setup.cfg file pointing to the readme
  5. create a source distribution

Write the project code

I'm not going to cover how to build a python project in this post, but here's the very small and simple project I used when learning this procedure: GitHub: kylep/jsc2f.

Create a Release on GitHub

Log into your GitHub project and click on releases. If you can't find the link, you can also just append /releases to the end of the URL to get there.

Click "Create a new release". Enter your tag and branch, along with a release title and description.

Under the Assets section of the new release there's a (tar.gz) link to download the source code. If you right click it and copy the URL, that's used next in the file.

Write a file

Here's mine. Check GitHub to see if I've changed it. The download_url value comes from the GitHub release.

from setuptools import setup

# Without this you'll get no description on the pypi site
with open("", "r") as fh:
    long_description =

    packages=['jsc2f'], # Alternatively you can use find_packages()
    version='0.1', # match the github release you make later
    license='MIT', # match the LICENSE file in the project
    description='Saves a JSON fields SQLs cell to a file, or UPDATE it back',
    author='Kyle Pericak',
    author_email='[email protected]',
    url='', # either your own page or github
    keywords=['SQL', 'JSON', 'file'],
        'Development Status :: 3 - Alpha',
        'Intended Audience :: Information Technology',
        'Topic :: Database',
        'Programming Language :: Python :: 3',
        'License :: OSI Approved :: MIT License',
        'Natural Language :: English'

Picking a topic:

I used this classifier list

Write setup.cfg

This goes in the project root next to

vi setup.cfg

description-file =

Creating a source distribution

For this you use the python sdist tool and twine.

From the git project root:

pip install twine

# This will create dist/
python sdist

# Twine uploads the dist/ files to Pypi
twine upload --skip-existing dist/*
# Enter your username and password for PyPI

Javascript appears to be disabled. Comments can't load.