summaryrefslogtreecommitdiffstats
path: root/recipes-connectivity/kuksa-val/kuksa-dbc-feeder/0001-dbc2val-add-installation-mechanism.patch
blob: 1e84eeb7e93f3a8355d024f727a9e1b93b0c998e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
From 603b5a584bd2b348befc9bab8f1ea0a7974f9d77 Mon Sep 17 00:00:00 2001
From: Scott Murray <scott.murray@konsulko.com>
Date: Wed, 11 May 2022 15:31:25 -0400
Subject: [PATCH] dbc2val: add installation mechanism

Add setup.py and setup.cfg to allow installing the dbc2val module
and dbcfeeder.py in a way suitable for packaging.  Some of the
imports in the scripts have been tweaked to enable running against
an installed copy of dbc2val.

Signed-off-by: Scott Murray <scott.murray@konsulko.com>

---
 kuksa_feeders/dbc2val/__init__.py      |  0
 kuksa_feeders/dbc2val/dbc2vssmapper.py | 12 ++++-----
 kuksa_feeders/dbc2val/dbcfeeder.py     |  6 ++---
 kuksa_feeders/setup.cfg                | 31 ++++++++++++++++++++++
 kuksa_feeders/setup.py                 | 36 ++++++++++++++++++++++++++
 5 files changed, 75 insertions(+), 10 deletions(-)
 create mode 100644 kuksa_feeders/dbc2val/__init__.py
 create mode 100644 kuksa_feeders/setup.cfg
 create mode 100644 kuksa_feeders/setup.py

diff --git a/kuksa_feeders/dbc2val/__init__.py b/kuksa_feeders/dbc2val/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/kuksa_feeders/dbc2val/dbc2vssmapper.py b/kuksa_feeders/dbc2val/dbc2vssmapper.py
index a43d1bd..1718154 100644
--- a/kuksa_feeders/dbc2val/dbc2vssmapper.py
+++ b/kuksa_feeders/dbc2val/dbc2vssmapper.py
@@ -11,8 +11,8 @@
 ########################################################################
 
 import yaml 
-import transforms.mapping
-import transforms.math
+from dbc2val.transforms import mapping
+from dbc2val.transforms import math
 
 
 class mapper:
@@ -22,9 +22,9 @@ class mapper:
             self.mapping = yaml.full_load(file)
 
         self.transforms={}
-        self.transforms['fullmapping']=transforms.mapping.mapping(discard_non_matching_items=True)
-        self.transforms['partialmapping']=transforms.mapping.mapping(discard_non_matching_items=False)
-        self.transforms['math']=transforms.math.math()
+        self.transforms['fullmapping']=mapping.mapping(discard_non_matching_items=True)
+        self.transforms['partialmapping']=mapping.mapping(discard_non_matching_items=False)
+        self.transforms['math']=math.math()
 
 
 
@@ -62,4 +62,4 @@ class mapper:
 
     def __getitem__(self, item):
         return self.mapping[item]
-    
\ No newline at end of file
+    
diff --git a/kuksa_feeders/dbc2val/dbcfeeder.py b/kuksa_feeders/dbc2val/dbcfeeder.py
index 71939c6..56c316a 100755
--- a/kuksa_feeders/dbc2val/dbcfeeder.py
+++ b/kuksa_feeders/dbc2val/dbcfeeder.py
@@ -16,10 +16,7 @@ import configparser
 import queue
 import json
 
-import dbc2vssmapper
-import dbcreader
-import j1939reader
-import elm2canbridge
+from dbc2val import dbc2vssmapper, dbcreader, j1939reader, elm2canbridge
 
 scriptDir= os.path.dirname(os.path.realpath(__file__))
 sys.path.append(os.path.join(scriptDir, "../../"))
@@ -27,6 +24,7 @@ from kuksa_viss_client import KuksaClientThread
 
 print("kuksa.val DBC example feeder")
 config_candidates=['/config/dbc_feeder.ini', '/etc/dbc_feeder.ini', os.path.join(scriptDir, 'config/dbc_feeder.ini')]
+configfile = None
 for candidate in config_candidates:
     if os.path.isfile(candidate):
         configfile=candidate
diff --git a/kuksa_feeders/setup.cfg b/kuksa_feeders/setup.cfg
new file mode 100644
index 0000000..4b69ccf
--- /dev/null
+++ b/kuksa_feeders/setup.cfg
@@ -0,0 +1,31 @@
+[metadata]
+name = dbc2val
+author = Sebastian Schildt, Naresh Nayak, Wenwen Chen
+author_email = sebastian.schildt@de.bosch.com, naresh.nayak@de.bosch.com, wenwen.chen@de.bosch.com
+description = kuksa.val DBC feeder
+long_description = file:README.md
+long_description_content_type = text/markdown
+url=https://github.com/eclipse/kuksa.val
+project_urls=
+  Source=https://github.com/eclipse/kuksa.val/tree/master/kuksa_feeders/dbc2val
+  Bug Tracker=https://github.com/eclipse/kuksa.val/issues
+classifiers = 
+    Intended Audience :: Developers
+    Development Status :: 3 - Alpha
+    Environment :: Console
+    Programming Language :: Python :: 3
+    License :: OSI Approved :: Eclipse Public License 2.0 (EPL-2.0)
+    Operating System :: OS Independent
+    Topic :: Software Development
+    
+license_file = ../LICENSE
+
+[options]
+python_requires = >=3.6
+install_requires=
+    pyserial
+    pyyaml
+    kuksa-viss-client
+packages=find:
+include_package_data = True
+scripts=dbc2val/dbcfeeder.py
diff --git a/kuksa_feeders/setup.py b/kuksa_feeders/setup.py
new file mode 100644
index 0000000..ad08d17
--- /dev/null
+++ b/kuksa_feeders/setup.py
@@ -0,0 +1,36 @@
+# To avoid shipping dbcfeeder.py in the module itself, use the
+# technique outlined at:
+#
+# https://stackoverflow.com/a/50592100
+#
+# This can be removed if the directory structure is ever reorganized
+# more along the lines of upstream recommendations.
+#
+
+import fnmatch
+from setuptools import find_packages, setup
+from setuptools.command.build_py import build_py as build_py_orig
+
+exclude = ['dbc2val.dbcfeeder']
+
+class build_py(build_py_orig):
+    def find_package_modules(self, package, package_dir):
+        modules = super().find_package_modules(package, package_dir)
+        print("modules = %s" % modules)
+        return [(pkg, mod, file, ) for (pkg, mod, file, ) in modules
+                if not any(fnmatch.fnmatchcase(pkg + '.' + mod, pat=pattern)
+                           for pattern in exclude)]
+
+setup(
+    version_config={
+        "template": "{tag}",
+        "dev_template": "{tag}-{ccount}",
+        "dirty_template": "{tag}-{ccount}-dirty",
+        "starting_version": "0.1.11",
+        "version_callback": None,
+        "version_file": None,
+        "count_commits_from_version_file": False
+    },
+    setup_requires=['setuptools-git-versioning'],
+    cmdclass={'build_py': build_py},
+)