diff --git a/configure.ac b/configure.ac index ae2d0c8d..02102760 100644 --- a/configure.ac +++ b/configure.ac @@ -167,18 +167,6 @@ if test "x$enable_daemon" = "xyes"; then if test "x$ovs_of_path" = "xno" ; then AC_MSG_WARN([Could not locate ovs-ofctl cannot use OVS mode]) fi - - CFLAGS_save=$CFLAGS - CPPFLAGS_save=$CPPFLAGS - if test "x$PYTHON_INCLUDE_DIR" = "x"; then - PYTHON_INCLUDE_DIR=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_inc())"` - fi - CFLAGS="-I$PYTHON_INCLUDE_DIR" - CPPFLAGS="-I$PYTHON_INCLUDE_DIR" - AC_CHECK_HEADERS([Python.h], [], - AC_MSG_ERROR([Python bindings require Python development headers (try installing your 'python-devel' or 'python-dev' package)])) - CFLAGS=$CFLAGS_save - CPPFLAGS=$CPPFLAGS_save fi if [ test "x$enable_daemon" = "xyes" || test "x$enable_vnodedonly" = "xyes" ] ; then diff --git a/docs/install2.md b/docs/install2.md new file mode 100644 index 00000000..b8f7c099 --- /dev/null +++ b/docs/install2.md @@ -0,0 +1,27 @@ +# Commands Used Ubuntu + +```shell +# get pip +sudo apt install python3-pip python3-venv + +# install pipx +python3 -m pip install --user pipx +python3 -m pipx ensurepath + +# install invoke +pipx install invoke + +# install core +inv install + +# run daemon +inv daemon + +# run gui +inv gui +``` + +Commands Used CentOS + +```shell +``` diff --git a/install2.sh b/install2.sh new file mode 100755 index 00000000..a8366670 --- /dev/null +++ b/install2.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# exit on error +set -e + +# detect os/ver for install type +os="" +if [[ -f /etc/os-release ]]; then + . /etc/os-release + os=${ID} +fi + +echo "installing CORE for ${os}" +case ${os} in +"ubuntu") + sudo apt install -y python3-pip + + ;; +"centos") + sudo yum install -y python3-pip + ;; +*) + echo "unknown OS ID ${os} cannot install" + ;; +esac + +python3 -m pip install --user pipx +python3 -m pipx ensurepath +python3 -m pipx install invoke +inv install diff --git a/tasks.py b/tasks.py index b19e8925..37b2e10c 100644 --- a/tasks.py +++ b/tasks.py @@ -1,52 +1,123 @@ +import os + from invoke import task +UBUNTU = "ubuntu" +CENTOS = "centos" +DAEMON_DIR = "daemon" +VCMD_DIR = "netns" +GUI_DIR = "gui" + + +def get_python(c): + with c.cd(DAEMON_DIR): + venv = c.run("poetry env info -p", hide=True).stdout.strip() + return os.path.join(venv, "bin", "python") + + +def get_pytest(c): + with c.cd(DAEMON_DIR): + venv = c.run("poetry env info -p", hide=True).stdout.strip() + return os.path.join(venv, "bin", "pytest") + + +def get_os(): + d = {} + with open("/etc/os-release", "r") as f: + for line in f.readlines(): + line = line.strip() + key, value = line.split("=") + d[key] = value + return d["ID"] + + +@task +def install(c): + """ + install core + """ + # get os + os_name = get_os() + # install system dependencies + print("installing system dependencies...") + if os_name == UBUNTU: + c.run( + "sudo apt install -y automake pkg-config gcc libev-dev ebtables iproute2 " + "ethtool tk python3-tk", hide=True + ) + else: + raise Exception(f"unsupported os: {os_name}") + # install grpcio-tools for building proto files + print("installing grpcio-tools...") + c.run("python3 -m pip install --user grpcio-tools", hide=True) + # build core + print("building core...") + c.run("./bootstrap.sh", hide=True) + c.run("./configure", hide=True) + c.run("make -j", hide=True) + # install vcmd + print("installing vcmd...") + with c.cd(VCMD_DIR): + c.run("sudo make install", hide=True) + # install vcmd + print("installing gui...") + with c.cd(GUI_DIR): + c.run("sudo make install", hide=True) + # install poetry environment + print("installing poetry...") + c.run("pipx install poetry", hide=True) + with c.cd(DAEMON_DIR): + print("installing core environment using poetry...") + c.run("poetry install", hide=True) + @task def daemon(c): """ - Runs core-daemon. + start core-daemon """ - with c.cd("daemon"): - poetry = c.run("which poetry").stdout.strip() + python = get_python(c) + with c.cd(DAEMON_DIR): c.run( - f"sudo {poetry} run scripts/core-daemon " - "-f data/core.conf -l data/logging.conf" + f"sudo {python} scripts/core-daemon " + "-f data/core.conf -l data/logging.conf", + pty=True ) @task def gui(c): """ - Run core-pygui. + start core-pygui """ - with c.cd("daemon"): - c.run("poetry run scripts/core-pygui") + with c.cd(DAEMON_DIR): + c.run("poetry run scripts/core-pygui", pty=True) @task def test(c): """ - Run core tests. + run core tests """ - with c.cd("daemon"): - poetry = c.run("which poetry").stdout.strip() - c.run(f"sudo {poetry} run pytest -v --lf -x tests", pty=True) + pytest = get_pytest(c) + with c.cd(DAEMON_DIR): + c.run(f"sudo {pytest} -v --lf -x tests", pty=True) @task def test_mock(c): """ - Run core tests using mock to avoid running as sudo. + run core tests using mock to avoid running as sudo """ - with c.cd("daemon"): + with c.cd(DAEMON_DIR): c.run("poetry run pytest -v --mock --lf -x tests", pty=True) @task def test_emane(c): """ - Run core emane tests. + run core emane tests """ - with c.cd("daemon"): - poetry = c.run("which poetry").stdout.strip() - c.run(f"sudo {poetry} run pytest -v --lf -x tests/emane", pty=True) + pytest = get_pytest(c) + with c.cd(DAEMON_DIR): + c.run(f"{pytest} -v --lf -x tests/emane", pty=True)