updates to poetry based installation
This commit is contained in:
parent
fb21909dad
commit
a236ea2455
4 changed files with 146 additions and 30 deletions
12
configure.ac
12
configure.ac
|
@ -167,18 +167,6 @@ if test "x$enable_daemon" = "xyes"; then
|
||||||
if test "x$ovs_of_path" = "xno" ; then
|
if test "x$ovs_of_path" = "xno" ; then
|
||||||
AC_MSG_WARN([Could not locate ovs-ofctl cannot use OVS mode])
|
AC_MSG_WARN([Could not locate ovs-ofctl cannot use OVS mode])
|
||||||
fi
|
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
|
fi
|
||||||
|
|
||||||
if [ test "x$enable_daemon" = "xyes" || test "x$enable_vnodedonly" = "xyes" ] ; then
|
if [ test "x$enable_daemon" = "xyes" || test "x$enable_vnodedonly" = "xyes" ] ; then
|
||||||
|
|
27
docs/install2.md
Normal file
27
docs/install2.md
Normal file
|
@ -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
|
||||||
|
```
|
30
install2.sh
Executable file
30
install2.sh
Executable file
|
@ -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
|
107
tasks.py
107
tasks.py
|
@ -1,52 +1,123 @@
|
||||||
|
import os
|
||||||
|
|
||||||
from invoke import task
|
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
|
@task
|
||||||
def daemon(c):
|
def daemon(c):
|
||||||
"""
|
"""
|
||||||
Runs core-daemon.
|
start core-daemon
|
||||||
"""
|
"""
|
||||||
with c.cd("daemon"):
|
python = get_python(c)
|
||||||
poetry = c.run("which poetry").stdout.strip()
|
with c.cd(DAEMON_DIR):
|
||||||
c.run(
|
c.run(
|
||||||
f"sudo {poetry} run scripts/core-daemon "
|
f"sudo {python} scripts/core-daemon "
|
||||||
"-f data/core.conf -l data/logging.conf"
|
"-f data/core.conf -l data/logging.conf",
|
||||||
|
pty=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def gui(c):
|
def gui(c):
|
||||||
"""
|
"""
|
||||||
Run core-pygui.
|
start core-pygui
|
||||||
"""
|
"""
|
||||||
with c.cd("daemon"):
|
with c.cd(DAEMON_DIR):
|
||||||
c.run("poetry run scripts/core-pygui")
|
c.run("poetry run scripts/core-pygui", pty=True)
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def test(c):
|
def test(c):
|
||||||
"""
|
"""
|
||||||
Run core tests.
|
run core tests
|
||||||
"""
|
"""
|
||||||
with c.cd("daemon"):
|
pytest = get_pytest(c)
|
||||||
poetry = c.run("which poetry").stdout.strip()
|
with c.cd(DAEMON_DIR):
|
||||||
c.run(f"sudo {poetry} run pytest -v --lf -x tests", pty=True)
|
c.run(f"sudo {pytest} -v --lf -x tests", pty=True)
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def test_mock(c):
|
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)
|
c.run("poetry run pytest -v --mock --lf -x tests", pty=True)
|
||||||
|
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def test_emane(c):
|
def test_emane(c):
|
||||||
"""
|
"""
|
||||||
Run core emane tests.
|
run core emane tests
|
||||||
"""
|
"""
|
||||||
with c.cd("daemon"):
|
pytest = get_pytest(c)
|
||||||
poetry = c.run("which poetry").stdout.strip()
|
with c.cd(DAEMON_DIR):
|
||||||
c.run(f"sudo {poetry} run pytest -v --lf -x tests/emane", pty=True)
|
c.run(f"{pytest} -v --lf -x tests/emane", pty=True)
|
||||||
|
|
Loading…
Reference in a new issue