CMI Python Users Meeting, 16/11/2015
Packaging in General
- Packaging is important for
- code organisation
Packaging in Python
- Packaging is different for each programming language
- This talk is only about Python
- Terminology doesn't translate particularly well between languages (or even between versions of languages), so be careful!
It's a mess.
But it's important.
This is what people download
These are what you find on PyPI, e.g. scikit-learn
How code is organised
csv is a module.
A 'higher level' module.
sklearn is a package.
from sklearn import preprocessing
These are the raw source code.
In Python, every script is a module.
So how do you make these?
Scripts are easy!
Just write them.
Modules are easy!
Modules are just scripts - anything in the global scope of the script is importable.
Packages are easy!
Its a directory (folder for the heathens) full of Python scripts (or modules) with...
A little more involved - see Python Foundations Packaging Guide
You need to write a setup.py file, and use setuptools.
Create a module with imports
Create a package which allows exports
Create a distribution
By Rich Lewis