Quantum Packaging Proposal
Notes:
All current work is at: https://github.com/CiscoSystems/quantum
Test packages are also on PyPi. Try them with:
virtualenv ~/.quantum-venv && pip install quantum -E ~/.quantum-venv #Install the sample-plugin pip install quantum-sample-plugin -E ~/.quantum-venv
Requirements:
- The ability to install Quantum easily from a pre-built package
- The availability of packages on multiple platforms
- The ability to install separate chunks of the Quantum independently, such as installing the API client, but not the server
the ability to install directly from PyPi without any previous setup (execute "sudo pip install quantum" on a fresh server to get going)
Based on those requirements, my proposal is to use Python's setuptools (http://pypi.python.org/pypi/setuptools) to manage building packages. This has many benefits:
- Supported and largely used by the Python community
- Allows for easy creation of RPM and Python Egg packages
- Allows us to separate out logical components into their own projects, and have them installed under a single namespace
- Built in support for installing scripts and configuration files
Project Format:
To use setuptools for Quantum, we first need to break it out into its individual projects, each with its own build script. I see 4 good candidates for main Quantum packages:
- quantum-server - Contains the server, plugin management code, etc
- quantum-client - Contains the API client lib, and CLI
- quantum-common - Contains the elements common to all packages; e.g. common/exceptions.py, serialization functions, etc
- quantum-sample-plugin - Contains the sample plugins for Quantum to use
- quantum-*-plugin - All Quantum plugins will be published this way (e.g. quantum-cisco-plugin)
The git repo looks something like this:
quantum/
setup.py
client/
setup.py
lib/
__init__.py
quantum/
__init__.py
client.py
common/
setup.py
lib/
__init__.py
quantum/
__init__.py
common/
__init__.py
exceptions.py
serializer.py
utils.py
server/
setup.py
lib/
__init__.py
quantum/
__init__.py
server.py
plugins/
sample-plugin/
setup.py
lib/
__init__.py
cisco-plugin/
setup.py
lib/
__init__.py
Application:
I have built and added a setup.py file for the root of the repo. It has a few different commands to use so that you don't have to do them on each package individually.
sudo python setup.py install
-- Installs quantum-common, quantum-client, quantum-server, and quantum-sample-plugin server-wide
python setup.py install --venv
-- The same as above, but creates and installs into ~/.quantum-venv. Requires no root permissions.
python setup.py install --user
-- The same as above, but installs into ~/.local. Requires no root permissions, but also less usable (unless you add it to you add to
your PATH)
python setup.py uninstall
-- Uninstalls quantum-common, quantum-client, quantum-server, and quantum-sample-plugin
python setup.py build rpm
-- Builds RPM packages. Requires rpmbuild (or rpm on Debian).
python setup.py build deb (Experimental)
-- Builds Deb packages. It first builds RPMs, then uses alien to convert them. Requires rpm and alien.
Development:
Setuptools allows you to install your software in "Development" mode where you don't need to re-install after each change. I haven't used it, but here is a link to its documentation: http://packages.python.org/distribute/setuptools.html#development-mode
I have setup the server and test scripts to find the module paths correctly, so you can directly use them without needing to install at all.
You can start server with:
bin/quantum-server
And run tests with:
python run_tests.py
CLI support is coming soon.