From bf1801500e5011d2ae9a86a2426877737e57d06e Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Fri, 5 Feb 2021 10:34:24 +0000 Subject: [PATCH 1/5] adapt paths for include and lib dirs --- PyScModule.cpp | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PyScModule.cpp b/PyScModule.cpp index 08ed7e0..2ec2da7 100644 --- a/PyScModule.cpp +++ b/PyScModule.cpp @@ -6,7 +6,7 @@ #include "PyScModule.h" #define PY_SSIZE_T_CLEAN -#include +#include class TPyScriptThreadLocker { PyGILState_STATE m_state; diff --git a/setup.py b/setup.py index 025efca..5f272da 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ pysyscsc = Extension('pysyscsc', extra_compile_args = ['-std=c++11'], include_dirs = [sysc_home+'/include'], libraries = ['systemc'], - library_dirs = [sysc_home+'/lib'], + library_dirs = [sysc_home+'/lib64', sysc_home+'/lib'], sources = ['PyScModule.cpp'], depends = ['PyScModule.h']) From f3a0246a69ca0a1b4558f8f41df2428cedd067b5 Mon Sep 17 00:00:00 2001 From: Rocco Jonack Date: Tue, 9 Feb 2021 11:27:30 +0000 Subject: [PATCH 2/5] updated some instructions installation --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 126f814..36979ae 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,14 @@ A Python 3 package to use SystemC from Python ## How to setup the environment -The installation for PySysC is as follows (using bash shell): +The installation for PySysC is as follows (using bash shell). The process has +been tested under CentOS7 and Ubuntu 20.04. Make sure a newer version of gcc +is in your path (tested with gcc-6.3.0). Also the SystemC installation has to +be reference with the environment variable SYSTEMC_HOME. + +If you get an error complaining about +missing Python.h, you need to install Python development headers. See the +articel under https://blog.ducthinh.net/gcc-no-such-file-python-h. ``` # create virtual environment @@ -12,6 +19,7 @@ python3 -m venv pysysc-env # and enable it . pysysc-env/bin/activate # install needed packages +pip install --upgrade pip python3 -m pip install wheel # install cppyy, C++ std version needs to match the version used to build the SystemC library STDCXX=11 python3 -m pip install cppyy From d41d409dec24f1008d6edda2e5ff604f3470c66f Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sun, 14 Mar 2021 09:33:41 +0100 Subject: [PATCH 3/5] remove cci global broker instantiation --- pysysc/structural.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pysysc/structural.py b/pysysc/structural.py index a5bfb3f..49be921 100644 --- a/pysysc/structural.py +++ b/pysysc/structural.py @@ -94,10 +94,10 @@ class Simulation(object): } cpp.sc_core.sc_report_handler.set_verbosity_level(verb_lut[log_level]); cpp.sc_core.sc_report_handler.set_actions(cpp.sc_core.SC_ID_MORE_THAN_ONE_SIGNAL_DRIVER_, cpp.sc_core.SC_DO_NOTHING); - try: - cpp.scc.init_cci("GlobalBroker") - except Exception: - pass + #try: + # cpp.scc.init_cci("GlobalBroker") + #except Exception: + # pass @staticmethod def configure(name="", enable_vcd=False): From 0672081c611b78c5d51db2691a78c65aa1ad1df3 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sun, 14 Mar 2021 12:13:52 +0100 Subject: [PATCH 4/5] updating README and tests/examples --- README.md | 40 +++++++++++++++++++++++++++++++++++----- pysysc/sccppyy.py | 10 ++++++++++ tests/router_example.py | 2 +- tests/test_pysysc.py | 2 +- 4 files changed, 47 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 36979ae..f7dc2d1 100644 --- a/README.md +++ b/README.md @@ -16,22 +16,52 @@ articel under https://blog.ducthinh.net/gcc-no-such-file-python-h. ``` # create virtual environment python3 -m venv pysysc-env -# and enable it +# and avtivate it . pysysc-env/bin/activate # install needed packages -pip install --upgrade pip +python3 -m pip install --upgrade pip +# install wheel package python3 -m pip install wheel # install cppyy, C++ std version needs to match the version used to build the SystemC library STDCXX=11 python3 -m pip install cppyy # clone of PySysC git clone https://git.minres.com/SystemC/PySysC.git # install PySysC, for development PySysC use 'python3 -m pip install -e` -python3 -m pip install -e PySysC +SYSTEMC_HOME= python3 -m pip install -e PySysC ``` -## Testing (preliminary) +## Running the example -To use the tests you also need to clone and build the PySysC-SC repo as sibling of PySysC. It contains the the code and libraries being used in the test. +To run the example you also need to clone and build the PySysC-SC repo. It contains the the code and libraries being used in the example. This project uses Conan.io as package manager so it should be installed (see down below). +To deactivate conan and use a SystemC installation just comment out the line `setup_conan()` in CMakeLists.txt and set the environment variable SYSTEMC_HOME. + +### Run the router_eample.py + +``` +# get the PySysC-SC repo +git clone --recursive https://git.minres.com/SystemC/PySysC-SC.git +# build the project libraries as shared libs +cd PySysC-SC +mkdir -p build/Debug +cd build/Debug +cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=ON ../.. +make -j components +cd ../.. +# now we are ready to run the example +python3 router_eample.py + +``` + +### Installing conan + +``` +# install conan into our virtual environment pysysc-env +python3 -m pip install conan +# create the default profile +conan profile new default --detect +# add the repo for SystemC packages used in the project +conan remote add minres https://api.bintray.com/conan/minres/conan-repo +``` ## TODO diff --git a/pysysc/sccppyy.py b/pysysc/sccppyy.py index 0194a71..2dbe526 100644 --- a/pysysc/sccppyy.py +++ b/pysysc/sccppyy.py @@ -138,6 +138,16 @@ def _load_pythonization_lib(): if os.path.isfile(full_path): cppyy.include(full_path) return + # could not be found in sintall, maybe development environment + pkgDir = os.path.join(os.path.dirname( os.path.realpath(__file__)), '..') + for file in os.listdir(pkgDir): + if re.match(r'pysyscsc.*\.so', file): + cppyy.load_library(os.path.join(pkgDir, file)) + full_path = os.path.join(pkgDir, 'PyScModule.h') + if os.path.isfile(full_path): + cppyy.include(full_path) + return + def add_library(file, lib): diff --git a/tests/router_example.py b/tests/router_example.py index 921dd4e..aa0d12a 100644 --- a/tests/router_example.py +++ b/tests/router_example.py @@ -13,7 +13,7 @@ from cppyy import gbl as cpp proj_home='../../PySysC-SC' conan_res = scpy.read_config_from_conan(os.path.join(proj_home, 'conanfile.txt')) scpy.load_systemc() -scpy.add_include_path(os.path.join(proj_home, 'sc-components/incl')) +scpy.add_include_path(os.path.join(proj_home, 'scc/incl')) scpy.add_library('scc.h', os.path.join(proj_home, 'build/Debug/lib/libscc.so')) scpy.add_include_path(os.path.join(proj_home, 'components')) scpy.add_library('components.h', os.path.join(proj_home, 'build/Debug/lib/libcomponents.so')) diff --git a/tests/test_pysysc.py b/tests/test_pysysc.py index e5adc37..a358311 100644 --- a/tests/test_pysysc.py +++ b/tests/test_pysysc.py @@ -22,7 +22,7 @@ class Test(unittest.TestCase): conan_path=os.path.join(proj_home, 'conanfile.txt') conan_res = scpy.read_config_from_conan(conan_path) scpy.load_systemc() - scpy.add_include_path(os.path.join(proj_home, 'sc-components/incl')) + scpy.add_include_path(os.path.join(proj_home, 'scc/incl')) scpy.add_library('scc.h', os.path.join(proj_home, 'build/Debug/lib/libscc.so')) scpy.add_include_path(os.path.join(proj_home, 'components')) scpy.add_library('components.h', os.path.join(proj_home, 'build/Debug/lib/libcomponents.so')) From c035045bae5066034d71f6d7f09b8d23efdae146 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sun, 14 Mar 2021 12:16:08 +0100 Subject: [PATCH 5/5] small type fix in README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f7dc2d1..8941b02 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,11 @@ articel under https://blog.ducthinh.net/gcc-no-such-file-python-h. python3 -m venv pysysc-env # and avtivate it . pysysc-env/bin/activate -# install needed packages +# update pip to mekae sure we have the newest version python3 -m pip install --upgrade pip # install wheel package python3 -m pip install wheel -# install cppyy, C++ std version needs to match the version used to build the SystemC library +# install cppyy, C++ std version needs to match the version used when building the SystemC library STDCXX=11 python3 -m pip install cppyy # clone of PySysC git clone https://git.minres.com/SystemC/PySysC.git