I outlined the project yesterday, because I knew I wouldn’t have much time today to work on it.
I was right.
Yesterday I created a minimal python package, today I want to be able to install this package with pip
.
The repo for this little project is found .
Creating the necessary setup file
According to the python-package, pip
uses the “setup.py” config file for installation. This file is located outside the package and contains the instructions to pip for installation.
# Content of setup.py
from setuptools import setup
setup(name='mypackage',
version='0.1',
author='Celia Siu',
author_email='fake-email@example.com',
url='http://github.com/csiu/sample-python-package',
description='Sample python package',
long_description='',
license='MIT',
zip_safe=False)
Installation with pip
Once the setup file is created and located in the right place, running pip in the “sample-python-package” project directory will install the package for use on our system.
My file structure now looks like this:
-- sample-python-package/
|-- mypackage/
| |-- __init__.py
| |-- test1.py
|-- setup.py
And the result of pip install .
is:
Processing /Users/csiu/repo/sample-python-package
Requirement already satisfied (use --upgrade to upgrade): mypackage==0.1 from file:///Users/csiu/repo/sample-python-package in /Users/csiu/software/anaconda/anaconda2-4.0.0/lib/python2.7/site-packages
Building wheels for collected packages: mypackage
Running setup.py bdist_wheel for mypackage ... done
Stored in directory: /Users/csiu/Library/Caches/pip/wheels/d5/c9/8b/9e90448482702fc6c561373478bc0bffa0815d9d077217ae68
Successfully built mypackage
In the last line we see the package has been “Successfully built”.
Future work
Now that I have a minimal python package with pip installation working, I want to:
- Enable continuous integration with Travis