Skip to content

Commit

Permalink
Fix pip setup and pin dependency versions
Browse files Browse the repository at this point in the history
This implies changes in the install scripts: they are moved inside
the ipmininet library so that they can be used by the `setup.py` file.
The documentation is also updated.
  • Loading branch information
jadinm committed Jul 31, 2019
1 parent 3a198bf commit 46a1bd6
Show file tree
Hide file tree
Showing 7 changed files with 216 additions and 107 deletions.
50 changes: 34 additions & 16 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,46 +46,64 @@ following command in the same directory as the two previous one:
.. _Vagrant: https://www.vagrantup.com/downloads.html
.. _Virtualbox: https://www.virtualbox.org/wiki/Downloads

Manual installation from sources
--------------------------------
Manual installation from PyPI
-----------------------------

To manually install IPMininet from source, first get the source code:
You can download and install IPMininet.
If you have pip above **18.1**, execute:

.. code-block:: bash
$ git clone https://github.com/cnp3/ipmininet.git
$ cd ipmininet
$ git checkout <version>
$ sudo pip install ipmininet
Then, install IPMininet, Mininet and all the daemons:
If you have an older version of pip, use:

.. code-block:: bash
$ sudo python util/install.py -iamf
$ sudo pip install --process-dependency-links ipmininet
Then, you can install all the daemons:

.. code-block:: bash
$ sudo python -m ipmininet.install -af
You can choose to install only a subset of the daemons
by changing the options on the installation script.
For the option documentations, use the ``-h`` option.

Manual installation from PyPI
-----------------------------
.. _documentation: http://mininet.org/download/

Install Mininet by following its `documentation`_.
Manual installation from sources
--------------------------------

Then, you can download and install IPMininet.
To manually install IPMininet from source, first get the source code:

.. code-block:: bash
$ sudo pip install ipmininet
$ git clone https://github.com/cnp3/ipmininet.git
$ cd ipmininet
$ git checkout <version>
Then, install IPMininet.
If you have pip above **18.1**, execute:

.. code-block:: bash
$ sudo pip install .
If you have an older version of pip, use:

.. code-block:: bash
$ sudo pip install --process-dependency-links .
Finally, you can install all the daemons:

.. code-block:: bash
$ sudo python util/install.py -af
$ sudo python -m ipmininet.install -af
You can choose to install only a subset of the daemons
by changing the options on the installation script.
For the option documentations, use the ``-h`` option.

.. _documentation: http://mininet.org/download/
Empty file added ipmininet/install/__init__.py
Empty file.
57 changes: 57 additions & 0 deletions ipmininet/install/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from ipmininet.utils import require_cmd
from .install import *


if __name__ == "__main__":

args = parse_args()
args.output_dir = os.path.normpath(os.path.abspath(args.output_dir))

require_cmd("pip2")
require_cmd("pip3")

check_pip_version("pip2")
check_pip_version("pip3")

if args.install_mininet:
install_mininet(args.output_dir)

if args.all or args.install_frrouting:
install_frrouting(args.output_dir)

if args.all or args.install_radvd:
dist.install("radvd")

if args.all or args.install_sshd:
dist.install("openssh-server")

# Install IPMininet

if args.install_ipmininet:
ipmininet_folder = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sh("pip2 -q install %s/" % ipmininet_folder)
sh("pip3 -q install %s/" % ipmininet_folder)

# Enable IPv6 (disabled by mininet installation)

if args.all or args.enable_ipv6:
enable_ipv6()

# Install test dependencies

dist.install("bridge-utils", "traceroute")
if dist.NAME == "Fedora":
dist.install("nc")
else:
dist.install("netcat-openbsd")

sh("pip2 -q install pytest")
sh("pip3 -q install pytest")

# Install OpenR

if args.install_openr:
if dist.NAME == "Ubuntu":
install_openr(args.output_dir)
else:
print("OpenR build currently only available on Ubuntu. Skipping installing OpenR.")
22 changes: 9 additions & 13 deletions util/build_vm.sh → ipmininet/install/build_vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -e

export LC_ALL=C

MN_VERSION="master"
MN_VERSION="2.3.0d6"
MN_INSTALL_SCRIPT_REMOTE="https://raw.githubusercontent.com/mininet/mininet/${MN_VERSION}/util/vm/install-mininet-vm.sh"
DEPS="python \
python-pip \
Expand All @@ -25,21 +25,17 @@ sudo sed -i -e 's/^\(127\.0\.1\.1\).*/\1\tmininet-vm/' /etc/hosts
# Install mininet
pushd $HOME
source <(curl -sL ${MN_INSTALL_SCRIPT_REMOTE})
sudo pip2 install mininet/
sudo pip3 install mininet/

# Update pip install
sudo pip3 install --upgrade pip
sudo pip2 install --upgrade pip
sudo apt remove -yq python-pip python3-pip

# Install ipmininet
git clone https://github.com/cnp3/ipmininet.git
pushd ipmininet
sudo python3 util/install.py -iaf
sudo pip2 install .
sudo pip3 install .
sudo python3 ipmininet/install/install.py -af
popd
popd

# Fix setuptools version issue
sudo pip2 install --upgrade pip
sudo apt-get remove -y python-pip
sudo pip2 install --upgrade setuptools

sudo pip3 install --upgrade pip
sudo apt-get remove -y python3-pip
sudo pip3 install --upgrade setuptools
112 changes: 43 additions & 69 deletions util/install.py → ipmininet/install/install.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import argparse
import os
import sys
import stat
import re
import stat
import subprocess
import sys

from utils import supported_distributions, identify_distribution, sh

MininetVersion = "master"
MinimumPipVersion = 19
MininetVersion = "2.3.0d6"
FRRoutingVersion = "7.1"
OpenrRelease = "rc-20190419-11514"

Expand Down Expand Up @@ -34,7 +36,25 @@ def parse_args():
return parser.parse_args()


def install_mininet():
def check_pip_version(pip):
p = sh("%s -V" % pip, stdout=subprocess.PIPE)
if p.wait() != 0:
print("Print cannot get the version of %s" % pip)
sys.exit(1)
content, _ = p.communicate()
try:
v = content.split(" ")[1]
major_version = int(v.split(".")[0])

if major_version < MinimumPipVersion:
print("%s version is too old: expecting at least %s - got %s" % (pip, MinimumPipVersion, v))
sys.exit(1)
except (ValueError, IndexError):
print("Cannot retrieve version number of %s" % pip)
sys.exit(1)


def install_mininet(output_dir, pip_install=True):
dist.install("git")

if dist.NAME == "Fedora":
Expand All @@ -45,15 +65,18 @@ def install_mininet():
else:
mininet_opts = "-a"

sh("git clone https://github.com/mininet/mininet.git", cwd=args.output_dir)
sh("git checkout %s" % MininetVersion, cwd=os.path.join(args.output_dir, "mininet"))
sh("git clone https://github.com/mininet/mininet.git", cwd=output_dir)
sh("git checkout %s" % MininetVersion, cwd=os.path.join(output_dir, "mininet"))
sh("mininet/util/install.sh %s -s ." % mininet_opts,
"pip2 -q install mininet/",
"pip3 -q install mininet/",
cwd=args.output_dir)
cwd=output_dir)

if pip_install:
sh("pip2 -q install mininet/",
"pip3 -q install mininet/",
cwd=output_dir)


def install_libyang():
def install_libyang(output_dir):

packages = []

Expand All @@ -78,10 +101,10 @@ def install_libyang():
sh("wget %s/%s" % (libyang_url, package),
"%s %s" % (cmd, package),
"rm %s" % package,
cwd=args.output_dir)
cwd=output_dir)


def install_frrouting():
def install_frrouting(output_dir):
dist.install("autoconf", "automake", "libtool", "make", "gcc", "groff",
"patch", "make", "bison", "flex", "gawk",
"python3-pytest")
Expand All @@ -95,15 +118,15 @@ def install_frrouting():
"perl-core", "python3-devel", "pam-devel", "systemd-devel",
"net-snmp-devel", "pkgconfig")

install_libyang()
install_libyang(output_dir)

frrouting_src = os.path.join(args.output_dir, "frr-%s" % FRRoutingVersion)
frrouting_src = os.path.join(output_dir, "frr-%s" % FRRoutingVersion)
frrouting_tar = frrouting_src + ".tar.gz"
sh("wget https://github.com/FRRouting/frr/releases/download/frr-{v}/frr-{v}.tar.gz".format(v=FRRoutingVersion),
"tar -zxvf '%s'" % frrouting_tar,
cwd=args.output_dir)
cwd=output_dir)

frrouting_install = os.path.join(args.output_dir, "frr")
frrouting_install = os.path.join(output_dir, "frr")
sh("./configure '--prefix=%s'" % frrouting_install,
"make",
"make install",
Expand Down Expand Up @@ -132,15 +155,15 @@ def install_frrouting():
break


def install_openr(openr_release=OpenrRelease,
def install_openr(output_dir, openr_release=OpenrRelease,
openr_remote="https://github.com/facebook/openr.git"):
dist.install("git")
openr_install = os.path.join(args.output_dir, "openr")
openr_install = os.path.join(output_dir, "openr")
openr_build = os.path.join(openr_install, "build")
openr_buildscript = os.path.join(openr_build, "build_openr_debian.sh")
debian_system_builder = "debian_system_builder/debian_system_builder.py"
sh("git clone %s" % openr_remote,
cwd=args.output_dir)
cwd=output_dir)
sh("git checkout %s" % openr_release,
cwd=openr_install)
# Generate build script
Expand Down Expand Up @@ -187,8 +210,7 @@ def enable_ipv6():
sh("sysctl -p")


args = parse_args()
args.output_dir = os.path.normpath(os.path.abspath(args.output_dir))
# Force root

if os.getuid() != 0:
print("This program must be run as root")
Expand All @@ -201,51 +223,3 @@ def enable_ipv6():
print("The installation script only supports %s" % ", ".join([d.NAME for d in supported_distributions()]))
sys.exit(1)
dist.update()

# Install dependencies

dist.install("python-pip", "python3-pip")

if args.install_mininet:
install_mininet()

if args.all or args.install_frrouting:
install_frrouting()

if args.all or args.install_radvd:
dist.install("radvd")

if args.all or args.install_sshd:
dist.install("openssh-server")

# Install IPMininet

if args.install_ipmininet:
ipmininet_folder = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sh("pip2 -q install %s/" % ipmininet_folder)
sh("pip3 -q install %s/" % ipmininet_folder)

# Enable IPv6 (disabled by mininet installation)

if args.all or args.enable_ipv6:
enable_ipv6()

# Install test dependencies

dist.install("bridge-utils", "traceroute")
if dist.NAME == "Fedora":
dist.install("nc")
else:
dist.install("netcat-openbsd")

sh("pip2 -q install pytest")
sh("pip3 -q install pytest")

# Install OpenR

if args.install_openr:
if dist.NAME == "Ubuntu":
install_openr()
else:
print("OpenR build currently only available on Ubuntu. Skipping installing OpenR.")
pass
File renamed without changes.
Loading

0 comments on commit 46a1bd6

Please sign in to comment.