Python Packaging
Overview
Create python packages that can be distributed with pip from GitHub (and not PyPi).
Configuration
A setup config file, setup.py, in the repo root directory should contain a single call to setuptools.setup(), like so: [1]
from setuptools import setup
setup(name='my_package',
version='0.1',
description='My package description',
url='http://github.com/dbarchowsky/my-package',
author='Damien Barchowsky',
author_email='dbarchowsky@gmail.com',
license='MIT',
packages=['my_package'],
zip_safe=False)
After which the package can be installed locally with
$ pip install .
And once installed the package can be used like this:
>>> import my_package >>> my_package.some_routine()
Installation from GitHub
Links
- Is is possible to use pip to install a package from a private GitHub repository - StackOverflow
- Generating a new SSH key and adding it to the ssh-agent - GitHub Help
- Adding a new SSH key to your GitHub account - GitHub Help
Overview of process
- It's necessary to store a SSH key locally
- Then install the key on GitHub
- Install the package hosted on GitHub with
pip install git+ssh://git@github.com/username/my-repo.git
See also
- ↑ How To Package Your Python Code - Python Packaging Tutorial