From 51270ce4a2a4b775fc9c75c854c0147733494843 Mon Sep 17 00:00:00 2001 From: Brandon Heller Date: Tue, 15 Dec 2009 10:34:11 -0800 Subject: [PATCH] Use setuptools to install python files Now, to reference mininet files, use 'import mininet.mininet'. PYTHONPATH mods are no longer required for installation. --- INSTALL | 9 ++++++--- examples/cli.py | 2 +- examples/grid.py | 2 +- examples/linearbandwidth.py | 4 ++-- examples/multitest.py | 2 +- examples/nox.py | 2 +- examples/ripcordtest.py | 8 ++++---- examples/scratchnet.py | 2 +- examples/scratchnetuser.py | 2 +- examples/sshd.py | 2 +- examples/tree1024.py | 2 +- examples/treeping64.py | 2 +- examples/xterms.py | 2 +- cleanup => mininet/cleanup | 0 mininet.py => mininet/mininet.py | 0 setup.py | 27 +++++++++++++++++++++++++++ 16 files changed, 49 insertions(+), 19 deletions(-) rename cleanup => mininet/cleanup (100%) rename mininet.py => mininet/mininet.py (100%) create mode 100644 setup.py diff --git a/INSTALL b/INSTALL index 843f35e..7d180fc 100644 --- a/INSTALL +++ b/INSTALL @@ -3,9 +3,12 @@ Preliminary Mininet Installation/Configuration Notes - This is not (yet) a 'release'; things may be broken. -- Mininet is not currently 'installed.' If you want to install it, - so that you can 'import mininet', place mininet.py somewhere in your - python path. +- To install mininet, with root privileges: + + python setup.py install + + This places the mininet package in /usr/lib/python-2.5/site-packages/, + so that 'import mininet' will work. - A functional netns binary is required to run mininet, but currently you have to compile it and install it yourself from the included .c file: diff --git a/examples/cli.py b/examples/cli.py index 6d49934..393c15c 100755 --- a/examples/cli.py +++ b/examples/cli.py @@ -2,7 +2,7 @@ "Create a tree network and run the CLI on it." -from mininet import init, TreeNet, Cli +from mininet.mininet import init, TreeNet, Cli if __name__ == '__main__': init() diff --git a/examples/grid.py b/examples/grid.py index 3abeef7..c025772 100755 --- a/examples/grid.py +++ b/examples/grid.py @@ -2,7 +2,7 @@ "Instantiate a Grid network and use NOX as the controller." -from mininet import init, Controller, GridNet, Cli +from mininet.mininet import init, Controller, GridNet, Cli class NoxController( Controller ): def __init__( self, name, **kwargs ): diff --git a/examples/linearbandwidth.py b/examples/linearbandwidth.py index d073bab..0230b33 100755 --- a/examples/linearbandwidth.py +++ b/examples/linearbandwidth.py @@ -15,8 +15,8 @@ switches, so this test WILL NOT WORK unless you have recompiled your controller to support 100 switches (or more.) """ -from mininet import init, Network, defaultNames, Host, Switch -from mininet import createLink, flush, iperf, pingTestVerbose, Cli +from mininet.mininet import init, Network, defaultNames, Host, Switch +from mininet.mininet import createLink, flush, iperf, pingTestVerbose, Cli class LinearNet( Network ): def __init__( self, switchCount, **kwargs ): diff --git a/examples/multitest.py b/examples/multitest.py index bb9bac8..403b215 100755 --- a/examples/multitest.py +++ b/examples/multitest.py @@ -2,7 +2,7 @@ "Run multiple tests on a network." -from mininet import init, TreeNet, pingTestVerbose, iperfTest, Cli +from mininet.mininet import init, TreeNet, pingTestVerbose, iperfTest, Cli if __name__ == '__main__': init() diff --git a/examples/nox.py b/examples/nox.py index 8a9c024..95413be 100755 --- a/examples/nox.py +++ b/examples/nox.py @@ -2,7 +2,7 @@ "Instantiate a Tree network and use NOX as the controller." -from mininet import init, Controller, TreeNet, Cli +from mininet.mininet import init, Controller, TreeNet, Cli class NoxController( Controller ): def __init__( self, name, **kwargs ): diff --git a/examples/ripcordtest.py b/examples/ripcordtest.py index 1eac5de..3f18dba 100755 --- a/examples/ripcordtest.py +++ b/examples/ripcordtest.py @@ -5,14 +5,14 @@ import ripcord from ripcord.topo import FatTreeTopo -from mininet import init, Controller, Network, Host, nameGen, Cli -from mininet import createLink, flush +from mininet.mininet import init, Controller, Network, Host, nameGen, Cli +from mininet.mininet import createLink, flush class NoxController( Controller ): - def __init__( self, name, kernel=False **kwargs ): + def __init__( self, name, kernel=False, **kwargs ): Controller.__init__( self, name, kernel=kernel, controller='nox_core', - cargs='-v --libdir=/usr/local/lib -i ptcp: routing', + cargs='-v --libdir=/usr/local/lib -i ptcp:', cdir='/usr/local/bin', **kwargs) class FatTree( Network ): diff --git a/examples/scratchnet.py b/examples/scratchnet.py index 43b6316..9e9ccbd 100755 --- a/examples/scratchnet.py +++ b/examples/scratchnet.py @@ -6,7 +6,7 @@ This is more complicated than using the higher-level classes, but it exposes the configuration details and allows customization. """ -from mininet import init, Node, createLink +from mininet.mininet import init, Node, createLink def scratchNet( cname='controller', cargs='ptcp:'): # Create Network diff --git a/examples/scratchnetuser.py b/examples/scratchnetuser.py index f946041..a321cd5 100755 --- a/examples/scratchnetuser.py +++ b/examples/scratchnetuser.py @@ -8,7 +8,7 @@ but it exposes the configuration details and allows customization. This version uses the user datapath. """ -from mininet import init, Node, createLink +from mininet.mininet import init, Node, createLink def scratchNetUser( cname='controller', cargs='ptcp:'): # Create Network diff --git a/examples/sshd.py b/examples/sshd.py index af455f2..27c7f70 100755 --- a/examples/sshd.py +++ b/examples/sshd.py @@ -11,7 +11,7 @@ unchanged on mininet and hardware. """ import sys ; readline = sys.stdin.readline -from mininet import init, Node, createLink, TreeNet, Cli +from mininet.mininet import init, Node, createLink, TreeNet, Cli def nets( hosts ): "Return list of networks (/24) for hosts." diff --git a/examples/tree1024.py b/examples/tree1024.py index e7abd7e..1abdf94 100755 --- a/examples/tree1024.py +++ b/examples/tree1024.py @@ -7,7 +7,7 @@ to adjust them, e.g. by adding entries to /etc/sysctl.conf and running sysctl -p. """ -from mininet import init, TreeNet, Cli +from mininet.mininet import init, TreeNet, Cli if __name__ == '__main__': init() diff --git a/examples/treeping64.py b/examples/treeping64.py index 5405ef1..5dc8e29 100755 --- a/examples/treeping64.py +++ b/examples/treeping64.py @@ -2,7 +2,7 @@ "Create a 64-node tree network, and test connectivity using ping." -from mininet import init, TreeNet, pingTestVerbose +from mininet.mininet import init, TreeNet, pingTestVerbose def treePing64(): results = {} diff --git a/examples/xterms.py b/examples/xterms.py index 0b0483a..787d992 100755 --- a/examples/xterms.py +++ b/examples/xterms.py @@ -7,7 +7,7 @@ host. Requires xterm(1) and GNU screen(1). import os, re from subprocess import Popen -from mininet import init, TreeNet, quietRun +from mininet.mininet import init, TreeNet, quietRun def makeXterm( node, title ): "Run screen on a node, and hook up an xterm." diff --git a/cleanup b/mininet/cleanup similarity index 100% rename from cleanup rename to mininet/cleanup diff --git a/mininet.py b/mininet/mininet.py similarity index 100% rename from mininet.py rename to mininet/mininet.py diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..f8f0e63 --- /dev/null +++ b/setup.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python +'''Setuptools params''' + +from setuptools import setup, find_packages + +setup( + name='mininet', + version='0.0.0', + description='The OpenFlow-based data center network', + author='Bob Lantz', + author_email='rlantz@cs.stanford.edu', + packages=find_packages(exclude='test'), + long_description="""\ +Insert longer description here. + """, + classifiers=[ + "License :: OSI Approved :: GNU General Public License (GPL)", + "Programming Language :: Python", + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Topic :: Internet", + ], + keywords='networking protocol Internet OpenFlow', + license='GPL', + install_requires=[ + 'setuptools' + ])