aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVasil Velichkov <vvvelichkov@gmail.com>2019-09-08 02:47:57 +0300
committerPiotr Krysik <ptrkrysik@gmail.com>2021-05-03 07:14:00 +0200
commit6eea94f7de77dac2e547cb629e61a82ec0a35bc4 (patch)
treea8ec224545ec1a6044642a40b2917c7c965c3f7c
parent783a1f7b5625c152d6a7b535def897a7833bebec (diff)
Fix grcc compilation with python3 by adding local subdirs to __path__
As the directory structure in the repository is different then the one after the package gets installed we need to add those subdirectories to the __path__ otherwise python3 is not able to load the modules using the relative import syntax and grcc compilation and some unit tests fail. Mofiy __path__ only when the CMAKE_BINARY_DIR environment variable is present. Revert "grgsm_livemon: Set cell_allocation to [0]" This reverts commit 013d4c258c6ad31c2581f0caa4eee3aa609fd9de. Change-Id: I223fd6181e8e36027039301186b671712a597ff8
-rw-r--r--apps/grgsm_livemon.grc2
-rw-r--r--apps/grgsm_livemon_headless.grc2
-rw-r--r--cmake/Modules/GrccCompile.cmake1
-rw-r--r--python/CMakeLists.txt3
-rw-r--r--python/__init__.py19
5 files changed, 24 insertions, 3 deletions
diff --git a/apps/grgsm_livemon.grc b/apps/grgsm_livemon.grc
index 941f816..e8bf4a5 100644
--- a/apps/grgsm_livemon.grc
+++ b/apps/grgsm_livemon.grc
@@ -360,7 +360,7 @@ blocks:
parameters:
affinity: ''
alias: ''
- cell_allocation: '[0]'
+ cell_allocation: '[arfcn.downlink2arfcn(fc)]'
comment: ''
maxoutbuf: '0'
minoutbuf: '0'
diff --git a/apps/grgsm_livemon_headless.grc b/apps/grgsm_livemon_headless.grc
index f4d5945..8e2e3fa 100644
--- a/apps/grgsm_livemon_headless.grc
+++ b/apps/grgsm_livemon_headless.grc
@@ -315,7 +315,7 @@ blocks:
parameters:
affinity: ''
alias: ''
- cell_allocation: '[0]'
+ cell_allocation: '[arfcn.downlink2arfcn(fc)]'
comment: ''
maxoutbuf: '0'
minoutbuf: '0'
diff --git a/cmake/Modules/GrccCompile.cmake b/cmake/Modules/GrccCompile.cmake
index 4589fd4..d2bc2d8 100644
--- a/cmake/Modules/GrccCompile.cmake
+++ b/cmake/Modules/GrccCompile.cmake
@@ -39,6 +39,7 @@ macro(GRCC_COMPILE file_name)
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${file_name}
COMMAND "${CMAKE_COMMAND}"
-E env PYTHONPATH="${PYTHONPATH}" GRC_BLOCKS_PATH=${CMAKE_SOURCE_DIR}/grc
+ CMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}
${GRCC} -o ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/${file_name}.grc
COMMAND "${CMAKE_COMMAND}" -E rename ${CMAKE_CURRENT_BINARY_DIR}/${file_name}.py ${CMAKE_CURRENT_BINARY_DIR}/${file_name}
diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index f0c984d..9cd7045 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -47,7 +47,8 @@ GR_PYTHON_INSTALL(
include(GrTest)
set(GR_TEST_TARGET_DEPS gr-gsm)
-set(GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR}/swig:${CMAKE_BINARY_DIR}/python/misc_utils:${CMAKE_BINARY_DIR}/python/receiver:${CMAKE_BINARY_DIR}/python/demapping:${CMAKE_BINARY_DIR}/python/transmitter)
+set(GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR}/swig:${CMAKE_BINARY_DIR}/python/misc_utils)
+set(GR_TEST_ENVIRONS "CMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}")
GR_ADD_TEST(qa_arfcn ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_arfcn.py)
GR_ADD_TEST(qa_decryption ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_decryption.py)
GR_ADD_TEST(qa_burst_printer ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_burst_printer.py)
diff --git a/python/__init__.py b/python/__init__.py
index ba5fc00..87a62d6 100644
--- a/python/__init__.py
+++ b/python/__init__.py
@@ -23,6 +23,25 @@ This is the GNU Radio GSM module. Place your Python package
description here (python/__init__.py).
'''
+import os
+
+if "CMAKE_BINARY_DIR" in os.environ:
+ dirname, filename = os.path.split(os.path.abspath(__file__))
+
+ # As the directory structure in the repository is different then the one after the package
+ # gets installed we need to add those subdirectories to the __path__ otherwise python3 is
+ # not able to load the modules using the relative import syntax and grcc compilation and
+ # some unit tests fail.
+ __path__ += [
+ # Load the local (not yet installed) grgsm_swig from the ../swig subdirectory.
+ os.path.join(os.environ.get("CMAKE_BINARY_DIR"), "swig"),
+
+ # Load the local (not yet installed) python modules from the local subdirectories
+ os.path.join(dirname, "misc_utils"),
+ os.path.join(dirname, "receiver"),
+ os.path.join(dirname, "demapping"),
+ os.path.join(dirname, "transmitter"),
+ os.path.join(dirname, "trx")]
# import swig generated symbols into the gsm namespace
from .grgsm_swig import *