Publishing your package

Developing Python Packages

James Fulton

Climate informatics researcher

PyPI

Python Package Index

  • pip installs packages from here
  • Anyone can upload packages
  • You should upload your package as soon as it might be useful
1 https://pypi.org/
Developing Python Packages

Distributions

  • Distribution package - a bundled version of your package which is ready to install.
  • Source distribution - a distribution package which is mostly your source code.
  • Wheel distribution - a distribution package which has been processed to make it faster to install.
Developing Python Packages

How to build distributions

python setup.py sdist bdist_wheel

  • sdist = source distribution
  • bdist_wheel = wheel distribution
mysklearn/
|-- mysklearn
|-- setup.py
|-- requirements.txt
|-- LICENSE
|-- README.md

|-- dist <---
| |-- mysklearn-0.1.0-py3-none-any.whl
| |-- mysklearn-0.1.0.tar.gz
|-- build |-- mysklearn.egg-info
Developing Python Packages

Getting your package out there

Upload your distributions to PyPI

twine upload dist/*

Upload your distributions to TestPyPI

twine upload -r testpypi dist/*
mysklearn/
|-- mysklearn
|-- setup.py
|-- requirements.txt
|-- LICENSE
|-- README.md
|-- dist
|   |-- mysklearn-0.1.0-py3-none-any.whl
|   |-- mysklearn-0.1.0.tar.gz
|-- build
|-- mysklearn.egg-info
Developing Python Packages

How other people can install your package

Install package from PyPI

pip install mysklearn

Install package from TestPyPI

pip install --index-url         https://test.pypi.org/simple 
            --extra-index-url   https://pypi.org/simple
            mysklearn
Developing Python Packages

Let's practice!

Developing Python Packages

Preparing Video For Download...