When dsdlc is running from source, it does not require pyuavcan anymore

This commit is contained in:
Pavel Kirienko 2015-06-10 20:10:40 +03:00
parent 91642adfe5
commit c3de88b89f
2 changed files with 14 additions and 0 deletions

3
.gitmodules vendored
View File

@ -1,3 +1,6 @@
[submodule "dsdl"]
path = dsdl
url = https://github.com/UAVCAN/dsdl
[submodule "libuavcan/dsdl_compiler/pyuavcan"]
path = libuavcan/dsdl_compiler/pyuavcan
url = https://github.com/UAVCAN/pyuavcan

View File

@ -9,6 +9,17 @@
from __future__ import division, absolute_import, print_function, unicode_literals
import os, sys, logging, argparse
# This trickery allows to use the compiler even if pyuavcan is not installed in the system.
# This is extremely important, as it makes the compiler (and therefore libuavcan in general)
# totally dependency-free, except for the Python interpreter itself.
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
LOCAL_PYUAVCAN_DIR = os.path.join(SCRIPT_DIR, 'pyuavcan')
RUNNING_FROM_SRC_DIR = os.path.isdir(LOCAL_PYUAVCAN_DIR)
if RUNNING_FROM_SRC_DIR:
print('Running from the source directory')
sys.path.insert(0, SCRIPT_DIR)
sys.path.insert(0, LOCAL_PYUAVCAN_DIR)
def configure_logging(verbosity):
fmt = '%(message)s'
level = { 0: logging.WARNING, 1: logging.INFO, 2: logging.DEBUG }.get(verbosity or 0, logging.DEBUG)