Skip to content
This repository has been archived by the owner on Sep 4, 2022. It is now read-only.

mnp: Mininet Packaging Tools Docs

heryandi edited this page Sep 16, 2013 · 43 revisions

Introduction

mnp, available here, is a command-line tool developed during Google Summer of Code 2013 with these purposes:

  • Help Mininet users download a Mininet modules from a sharing website, including the dependencies with as few commands as possible.
  • Help Mininet developers package, upload, and share their Mininet modules on a sharing website.

The sharing website, based on djangopypi2, is also developed on Google Summer of Code 2013 and documented in a separate page.

Mininet Packaging Format

Mininet packaging format is just a plain old Python packaging format based on setuptools and distutils.

mnp Commands

  • download: Download specified packages
  • upload: Package and upload the package from the current directory
  • list: List all available packages
  • search: Search for packages
  • docs: Retrieve the documentation of a package
  • info: Print the essential information (author, version, summary etc.) of a package

Other Features

  • GitHub Authentication support for upload command

Implementation

The commands supported by mnp are implemented internally by reusing existing tools as much as possible.

Commands

download

Implemented by calling pip from the command line.

upload

Implemented by calling setup.py from the command line which in turn calls setuptools.

list, search, docs, info

Implemented by making an XML-RPC request to the sharing website.

Others

GitHub Authentication support for upload command

Implementing the support for GitHub authentication is the most technically challenging part of the development of mnp.

After trying out several approaches, I arrived at the conclusion that the most elegant way to implement GitHub authentication is by implementing additional commands to setup.py by creating additional cmdclass.

By reading through the source code of both setuptools and distutils for both register and upload commands, I managed to find the proper methods to override in order to read in users' specified GitHub username from .pypirc. If the GitHub password is not specified in .pypirc, then the user will be asked for it when the command is executed.

Implementing it this way, however, means that users who wanted to use GitHub account to submit their packages must always import and specify the cmdclass-es in their setup.py files. This is very inconvenient as the setup.py files are quite complex enough as it is, so I decided to monkey-patch the setup.py to patch the setup() function to automatically include the cmdclass-es written to support GitHub authentication. This monkey-patch mechanism can be easily activated simply by writing import mnp.patch at the top of the setup.py files.

Unit Testing

References

PyPI XML-RPC

Clone this wiki locally