This is the initial commit for uD3TN. uD3TN is a fork of uPCN v0.8.0, which will be developed and maintained in a public Git repository. For questions concerning the history of and code provided with uPCN, please get in touch with us via: contact <at> d3tn <dot> com Signed-off-by: Felix Walter <felix.walter@d3tn.com>
1.9 KiB
Python 3 virtualenv Setup
Multiple functional tests as well as the integration test toolchain in the µPCN project are using Python scripts to speed up development compared to pure C test implementations. The scripts are located in the tools/ directory. The integration test toolchain can be found in the test/integration/ directory. Both leverage a Python 3 implementation of several DTN protocols and convergence layers, provided in the pyupcn/ directory.
A venv is used to isolate the
µPCN Python environment from the system. The Makefile target virtualenv
creates a default Python virtualenv including pip and
all required Python packages.
make virtualenv
The location of the virtualenv directory can be controlled with the VENV
parameter. The default directory is .venv/.
make VENV=path/to/venv virtualenv
After the virtualenv is created the activate script has to be sourced to add
the virtualenv Python interpreter to the PATH variable. Alternatively,
environment switcher like direnv (see below) or virtualenvwrapper can be
used.
source .venv/bin/activate
The tools/ directory is added to the virtualenv site-packages allowing the
import of packages residing in tools/ like the pyupcn package, e.g.
from pyupcn.bundle7 import serialize_bundle7
serialize_bundle7("dtn:GS1", "dtn:GS2", b"Hello world!")
Optional: direnv support
direnv is an environment switcher loading environtal
variables depending on the current directory. It can be used to automatically
create and load Python virtualenvs. This is an example .envrc file making use
of the Makefile virtualenv target.
layout_virtualenv() {
local venv=$1
if [ ! -d "${venv}" ]; then
make virtualenv
fi
source ${venv}/bin/activate
}
layout virtualenv .venv