Wei Zhang's Blog

08 Apr 2022

Steps to publish and install python packages

This post records some useful commands for publishing and installing a Python package.

Publishing a Python package to PyPi

  1. Build locally

      python setup.py sdist bdist_wheel
    

    The files are built under directory ./dist

  2. Check

    twine check dist/*
    
  3. Publish to Test PyPI

    twine upload --repository-url https://test.pypi.org/legacy/ dist/*
    

    to see if everything looks fine.

  4. Final publish to PyPI

    twine upload dist/*
    

Installation

  1. Install using pip

    pip install molann==1.0.2
    
  2. Build and install from source code

    python setup.py sdist
    pip install dist/*.tar.gz --user
    

Useful tutorials

The following tutorials contain many useful information.

  1. Packaging Python Projects.
  2. Python Packaging User Guide.
  3. An excellent tutorial is here.
  4. The Sheer Joy of Packaging.

Tags