<p>ptrkrysik <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/gr-gsm/+/24075">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  ptrkrysik: Looks good to me, approved; Verified

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Fix grcc compilation with python3 by adding local subdirs to __path__<br><br>As the directory structure in the repository is different then the one<br>after the package gets installed we need to add those subdirectories to<br>the __path__ otherwise python3 is not able to load the modules using the<br>relative import syntax and grcc compilation and some unit tests fail.<br><br>Mofiy __path__ only when the CMAKE_BINARY_DIR environment variable is<br>present.<br><br>Revert "grgsm_livemon: Set cell_allocation to [0]"<br><br>This reverts commit 013d4c258c6ad31c2581f0caa4eee3aa609fd9de.<br><br>Change-Id: I223fd6181e8e36027039301186b671712a597ff8<br>---<br>M apps/grgsm_livemon.grc<br>M apps/grgsm_livemon_headless.grc<br>M cmake/Modules/GrccCompile.cmake<br>M python/CMakeLists.txt<br>M python/__init__.py<br>5 files changed, 24 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/grgsm_livemon.grc b/apps/grgsm_livemon.grc</span><br><span>index 941f816..e8bf4a5 100644</span><br><span>--- a/apps/grgsm_livemon.grc</span><br><span>+++ b/apps/grgsm_livemon.grc</span><br><span>@@ -360,7 +360,7 @@</span><br><span>   parameters:</span><br><span>     affinity: ''</span><br><span>     alias: ''</span><br><span style="color: hsl(0, 100%, 40%);">-    cell_allocation: '[0]'</span><br><span style="color: hsl(120, 100%, 40%);">+    cell_allocation: '[arfcn.downlink2arfcn(fc)]'</span><br><span>     comment: ''</span><br><span>     maxoutbuf: '0'</span><br><span>     minoutbuf: '0'</span><br><span>diff --git a/apps/grgsm_livemon_headless.grc b/apps/grgsm_livemon_headless.grc</span><br><span>index f4d5945..8e2e3fa 100644</span><br><span>--- a/apps/grgsm_livemon_headless.grc</span><br><span>+++ b/apps/grgsm_livemon_headless.grc</span><br><span>@@ -315,7 +315,7 @@</span><br><span>   parameters:</span><br><span>     affinity: ''</span><br><span>     alias: ''</span><br><span style="color: hsl(0, 100%, 40%);">-    cell_allocation: '[0]'</span><br><span style="color: hsl(120, 100%, 40%);">+    cell_allocation: '[arfcn.downlink2arfcn(fc)]'</span><br><span>     comment: ''</span><br><span>     maxoutbuf: '0'</span><br><span>     minoutbuf: '0'</span><br><span>diff --git a/cmake/Modules/GrccCompile.cmake b/cmake/Modules/GrccCompile.cmake</span><br><span>index 4589fd4..d2bc2d8 100644</span><br><span>--- a/cmake/Modules/GrccCompile.cmake</span><br><span>+++ b/cmake/Modules/GrccCompile.cmake</span><br><span>@@ -39,6 +39,7 @@</span><br><span>         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${file_name}</span><br><span>         COMMAND "${CMAKE_COMMAND}"</span><br><span>         -E env PYTHONPATH="${PYTHONPATH}" GRC_BLOCKS_PATH=${CMAKE_SOURCE_DIR}/grc</span><br><span style="color: hsl(120, 100%, 40%);">+        CMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}</span><br><span>         ${GRCC} -o ${CMAKE_CURRENT_BINARY_DIR}</span><br><span>         ${CMAKE_CURRENT_SOURCE_DIR}/${file_name}.grc</span><br><span>         COMMAND "${CMAKE_COMMAND}" -E rename ${CMAKE_CURRENT_BINARY_DIR}/${file_name}.py ${CMAKE_CURRENT_BINARY_DIR}/${file_name}</span><br><span>diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt</span><br><span>index f0c984d..9cd7045 100644</span><br><span>--- a/python/CMakeLists.txt</span><br><span>+++ b/python/CMakeLists.txt</span><br><span>@@ -47,7 +47,8 @@</span><br><span> include(GrTest)</span><br><span> </span><br><span> set(GR_TEST_TARGET_DEPS gr-gsm)</span><br><span style="color: hsl(0, 100%, 40%);">-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)</span><br><span style="color: hsl(120, 100%, 40%);">+set(GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR}/swig:${CMAKE_BINARY_DIR}/python/misc_utils)</span><br><span style="color: hsl(120, 100%, 40%);">+set(GR_TEST_ENVIRONS "CMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}")</span><br><span> GR_ADD_TEST(qa_arfcn ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_arfcn.py)</span><br><span> GR_ADD_TEST(qa_decryption ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_decryption.py)</span><br><span> GR_ADD_TEST(qa_burst_printer ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_burst_printer.py)</span><br><span>diff --git a/python/__init__.py b/python/__init__.py</span><br><span>index ba5fc00..87a62d6 100644</span><br><span>--- a/python/__init__.py</span><br><span>+++ b/python/__init__.py</span><br><span>@@ -23,6 +23,25 @@</span><br><span> description here (python/__init__.py).</span><br><span> '''</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+import os</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+if "CMAKE_BINARY_DIR" in os.environ:</span><br><span style="color: hsl(120, 100%, 40%);">+    dirname, filename = os.path.split(os.path.abspath(__file__))</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    # As the directory structure in the repository is different then the one after the package</span><br><span style="color: hsl(120, 100%, 40%);">+    # gets installed we need to add those subdirectories to the __path__ otherwise python3 is</span><br><span style="color: hsl(120, 100%, 40%);">+    # not able to load the modules using the relative import syntax and grcc compilation and</span><br><span style="color: hsl(120, 100%, 40%);">+    # some unit tests fail.</span><br><span style="color: hsl(120, 100%, 40%);">+    __path__ += [</span><br><span style="color: hsl(120, 100%, 40%);">+        # Load the local (not yet installed) grgsm_swig from the ../swig subdirectory.</span><br><span style="color: hsl(120, 100%, 40%);">+        os.path.join(os.environ.get("CMAKE_BINARY_DIR"), "swig"),</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        # Load the local (not yet installed) python modules from the local subdirectories</span><br><span style="color: hsl(120, 100%, 40%);">+        os.path.join(dirname, "misc_utils"),</span><br><span style="color: hsl(120, 100%, 40%);">+        os.path.join(dirname, "receiver"),</span><br><span style="color: hsl(120, 100%, 40%);">+        os.path.join(dirname, "demapping"),</span><br><span style="color: hsl(120, 100%, 40%);">+        os.path.join(dirname, "transmitter"),</span><br><span style="color: hsl(120, 100%, 40%);">+        os.path.join(dirname, "trx")]</span><br><span> </span><br><span> # import swig generated symbols into the gsm namespace</span><br><span> from .grgsm_swig import *</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/gr-gsm/+/24075">change 24075</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/gr-gsm/+/24075"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: gr-gsm </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I223fd6181e8e36027039301186b671712a597ff8 </div>
<div style="display:none"> Gerrit-Change-Number: 24075 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: ptrkrysik <ptrkrysik@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: ptrkrysik <ptrkrysik@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: vvvelichkov <vvvelichkov@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>