##// END OF EJS Templates
Few fixes to build on CentOS 7 and adds simple example of virtual product...
jeandet -
r1505:4bf34af32858
parent child
Show More
@@ -0,0 +1,38
1 import traceback
2 from SciQLopBindings import PyDataProvider, Product, VectorTimeSerie, ScalarTimeSerie, DataSeriesType
3 import numpy as np
4 from spwc.cache import _cache
5 from spwc.common.datetime_range import DateTimeRange
6 from datetime import datetime, timedelta, timezone
7 from spwc.common.variable import SpwcVariable
8 from spwc.amda import AMDA
9
10 amda = AMDA()
11
12
13 def vp_make_scalar(var=None):
14 if var is None:
15 return (((np.array([]), np.array([])), np.array([])), DataSeriesType.SCALAR)
16 else:
17 return (((var.time, np.array([])), var.data), DataSeriesType.SCALAR)
18
19 class DemoVP(PyDataProvider):
20 def __init__(self):
21 super().__init__()
22 self.register_products([Product("/VP/thb_fgm_gse_mod",[],{"type":"scalar"})])
23
24 def get_data(self,metadata,start,stop):
25 try:
26 tstart = datetime.fromtimestamp(start, tz=timezone.utc)
27 tend = datetime.fromtimestamp(stop, tz=timezone.utc)
28 thb_bs = amda.get_parameter(start_time=tstart, stop_time=tend, parameter_id='thb_bs', method="REST")
29 thb_bs.data = np.sqrt((thb_bs.data*thb_bs.data).sum(axis=1))
30 return vp_make_scalar(thb_bs)
31 except Exception as e:
32 print(traceback.format_exc())
33 print(f"Error in {__file__} ",str(e))
34 return (((np.array([]), np.array([])), np.array([])), ts_type)
35
36
37 t=DemoVP()
38
@@ -1,50 +1,55
1 shiboken2 = find_program('shiboken2')
1 shiboken2 = find_program('shiboken2')
2 qmake = find_program('qmake-qt5','qmake')
2 qmake = find_program('qmake-qt5','qmake')
3
3
4 pymod = import('python')
4 pymod = import('python')
5 python3 = pymod.find_installation('python3', modules:['PySide2','shiboken2', 'shiboken2_generator', 'numpy'])
5 python3 = pymod.find_installation('python3', modules:['PySide2','shiboken2', 'shiboken2_generator', 'numpy'])
6 python3_dep = python3.dependency(embed:true)
6 python3_dep = python3.dependency(embed:true)
7 numpy_inc = run_command(python3, '-c', 'import numpy;print(numpy.get_include())').stdout().strip('\n')
7 numpy_inc = run_command(python3, '-c', 'import numpy;print(numpy.get_include())').stdout().strip('\n')
8
8
9 qt5_modules = ['QtCore','QtGui','QtWidgets']
9 qt5_modules = ['QtCore','QtGui','QtWidgets']
10
10
11 qt_headers_path = run_command(qmake, '-query', 'QT_INSTALL_HEADERS').stdout().strip('\n')
11 qt_headers_path = run_command(qmake, '-query', 'QT_INSTALL_HEADERS').stdout().strip('\n')
12 generated_srcs = run_command(python3, 'src_list.py', 'meson').stdout().split(';')
12 generated_srcs = run_command(python3, 'src_list.py', 'meson').stdout().split(';')
13
13
14 modules_arg = '--modules=@0@'.format(','.join(qt5_modules))
14 modules_arg = '--modules=@0@'.format(','.join(qt5_modules))
15
15
16 shiboken2_build_flags = run_command(python3, 'shiboken-helper.py', '--includes', modules_arg).stdout().strip('\n').split(' ')
16 shiboken2_build_flags = run_command(python3, 'shiboken-helper.py', '--includes', modules_arg).stdout().strip('\n').split(' ')
17 shiboken2_link_flags = run_command(python3, 'shiboken-helper.py', '--libs', modules_arg).stdout().strip('\n').split(' ')
17 shiboken2_link_flags = run_command(python3, 'shiboken-helper.py', '--libs', modules_arg).stdout().strip('\n').split(' ')
18 shiboken2_typesystem = run_command(python3, 'shiboken-helper.py', '--typesystem').stdout().strip('\n')
18 shiboken2_typesystem = run_command(python3, 'shiboken-helper.py', '--typesystem').stdout().strip('\n')
19
19
20 message('shiboken2_build_flags = @0@'.format(shiboken2_build_flags))
21 message('shiboken2_link_flags = @0@'.format(shiboken2_link_flags))
22 message('shiboken2_typesystem = @0@'.format(shiboken2_typesystem))
23
24
20 sciqlop_bindings_incs = shiboken2_build_flags + [
25 sciqlop_bindings_incs = shiboken2_build_flags + [
21 '-I'+meson.current_source_dir()+'/../../gui/include',
26 '-I'+meson.current_source_dir()+'/../../gui/include',
22 '-I'+meson.current_source_dir()+'/../../core/include',
27 '-I'+meson.current_source_dir()+'/../../core/include',
23 '-I'+meson.current_source_dir()+'/../../subprojects/TimeSeries/include',
28 '-I'+meson.current_source_dir()+'/../../subprojects/TimeSeries/include',
24 '-I'+meson.current_source_dir()+'/../../subprojects/cpp_utils/include',
29 '-I'+meson.current_source_dir()+'/../../subprojects/cpp_utils/include',
25 '-I'+python3.get_path('include'),
30 '-I'+python3.get_path('include'),
26 '-I'+qt_headers_path,
31 '-I'+qt_headers_path,
27 '-I'+numpy_inc
32 '-I'+numpy_inc
28 ]
33 ]
29
34
30 foreach mod:qt5_modules
35 foreach mod:qt5_modules
31 sciqlop_bindings_incs += ['-I'+qt_headers_path+'/'+mod]
36 sciqlop_bindings_incs += ['-I'+qt_headers_path+'/'+mod]
32 endforeach
37 endforeach
33
38
34
39
35 sciqlop_bindings_src = files('bindings.h', 'PyDataProvider.h', 'numpy_wrappers.h', 'numpy_wrappers.cpp')
40 sciqlop_bindings_src = files('bindings.h', 'PyDataProvider.h', 'numpy_wrappers.h', 'numpy_wrappers.cpp')
36
41
37 subdir('SciQLopBindings')
42 subdir('SciQLopBindings')
38 subdir('plugins')
43 subdir('plugins')
39
44
40 shiboken_dep = declare_dependency(compile_args: shiboken2_build_flags, link_args: shiboken2_link_flags)
45 shiboken_dep = declare_dependency(compile_args: shiboken2_build_flags, link_args: shiboken2_link_flags)
41
46
42 sciqlop_bindings = python3.extension_module('SciQLopBindings',sciqlop_bindings_src,shiboken2_generator_out,
47 sciqlop_bindings = python3.extension_module('SciQLopBindings',sciqlop_bindings_src,shiboken2_generator_out,
43 dependencies : [sciqlop_app_dep, python3_dep, shiboken_dep, cpp_utils_dep],
48 dependencies : [sciqlop_app_dep, python3_dep, shiboken_dep, cpp_utils_dep],
44 include_directories : numpy_inc
49 include_directories : numpy_inc
45 )
50 )
46
51
47
52
48 configure_file(input:'main.py', output:'main.py', copy:true)
53 configure_file(input:'main.py', output:'main.py', copy:true)
49
54
50 executable('sciqlop', 'main.cpp', dependencies :python3_dep)
55 executable('sciqlop', 'main.cpp', dependencies :python3_dep)
@@ -1,3 +1,4
1
1
2 configure_file(input:'TestPlugin.py', output:'TestPlugin.py', copy:true)
2 configure_file(input:'TestPlugin.py', output:'TestPlugin.py', copy:true)
3 configure_file(input:'SPWC-Amda.py', output:'SPWC-Amda.py', copy:true)
3 configure_file(input:'SPWC-Amda.py', output:'SPWC-Amda.py', copy:true)
4 configure_file(input:'Demo-virtual-product.py', output:'Demo-virtual-product.py', copy:true)
@@ -1,46 +1,46
1 #!/bin/env python3
1 #!/bin/env python3
2
2
3 import os
3 import os
4 import sys
4 import sys
5 import importlib
5 import importlib
6 import argparse
6 import argparse
7 from glob import glob
7 from glob import glob
8
8
9
9
10 shiboken2_generator = importlib.import_module('shiboken2_generator')
10 shiboken2_generator = importlib.import_module('shiboken2_generator')
11 shiboken2 = importlib.import_module('shiboken2')
11 shiboken2 = importlib.import_module('shiboken2')
12 PySide2 = importlib.import_module('PySide2')
12 PySide2 = importlib.import_module('PySide2')
13
13
14
14
15 parser = argparse.ArgumentParser(description='PySide2/shiboken2 ')
15 parser = argparse.ArgumentParser(description='PySide2/shiboken2 ')
16 group = parser.add_mutually_exclusive_group()
16 group = parser.add_mutually_exclusive_group()
17 group.add_argument('--libs',action='store_true')
17 group.add_argument('--libs',action='store_true')
18 group.add_argument('--includes',action='store_true')
18 group.add_argument('--includes',action='store_true')
19 parser.add_argument('--modules')
19 parser.add_argument('--modules')
20 group.add_argument('--typesystem', action='store_true')
20 group.add_argument('--typesystem', action='store_true')
21 args = parser.parse_args()
21 args = parser.parse_args()
22
22
23
23
24 def first_existing_path(path_list):
24 def first_existing_path(path_list):
25 return next((path for path in path_list if os.path.exists(path)), None)
25 return next((path for path in path_list if os.path.exists(path)), None)
26
26
27
27
28 if shiboken2.__file__ and shiboken2_generator.__file__ and PySide2.__file__:
28 if shiboken2.__file__ and shiboken2_generator.__file__ and PySide2.__file__:
29 PySide2_inc = first_existing_path([PySide2.__path__[0]+'/include','/usr/include/PySide2'])
29 PySide2_inc = first_existing_path([PySide2.__path__[0]+'/include','/usr/include/PySide2'])
30 PySide2_typesys = first_existing_path([PySide2.__path__[0]+'/typesystems','/usr/share/PySide2/typesystems'])
30 PySide2_typesys = first_existing_path([PySide2.__path__[0]+'/typesystems','/usr/share/PySide2/typesystems'])
31 PySide2_includes = first_existing_path([PySide2.__path__[0]+'/include','/usr/include/PySide2'])
31 PySide2_includes = first_existing_path([PySide2.__path__[0]+'/include','/usr/include/PySide2'])
32 shiboken2_includes = first_existing_path([shiboken2.__path__[0]+'/include','/usr/include/shiboken2'])
32 shiboken2_includes = first_existing_path([shiboken2.__path__[0]+'/include',shiboken2_generator.__path__[0]+'/include','/usr/include/shiboken2'])
33
33
34 if args.typesystem:
34 if args.typesystem:
35 print(PySide2_typesys)
35 print(PySide2_typesys)
36 modules = args.modules.split(',')
36 modules = args.modules.split(',')
37 if args.libs:
37 if args.libs:
38 main_lib = (glob(shiboken2.__path__[0]+'/libshiboken2'+importlib.machinery.EXTENSION_SUFFIXES[0])+glob("/usr/lib64/"+'/libshiboken2'+importlib.machinery.EXTENSION_SUFFIXES[0]))[0]
38 main_lib = (glob(shiboken2.__path__[0]+'/libshiboken2'+importlib.machinery.EXTENSION_SUFFIXES[0]+'*')+glob("/usr/lib64/"+'/libshiboken2'+importlib.machinery.EXTENSION_SUFFIXES[0]+'*'))[0]
39 main_lib += " "+(glob(PySide2.__path__[0]+'/libpyside2'+importlib.machinery.EXTENSION_SUFFIXES[0])+glob("/usr/lib64/"+'/libpyside2'+importlib.machinery.EXTENSION_SUFFIXES[0]))[0]
39 main_lib += " "+(glob(PySide2.__path__[0]+'/libpyside2'+importlib.machinery.EXTENSION_SUFFIXES[0]+'*')+glob("/usr/lib64/"+'/libpyside2'+importlib.machinery.EXTENSION_SUFFIXES[0]+'*'))[0]
40 modules_libs = [importlib.import_module(f'PySide2.{module}').__file__ for module in modules]
40 modules_libs = [importlib.import_module(f'PySide2.{module}').__file__ for module in modules]
41 print(" ".join([main_lib]+ modules_libs))
41 print(" ".join([main_lib]+ modules_libs))
42 if args.includes:
42 if args.includes:
43 modules_incs = [f"-I{PySide2_includes}/{module}" for module in modules]
43 modules_incs = [f"-I{PySide2_includes}/{module}" for module in modules]
44 print(" ".join([f"-I{PySide2_includes} -I{shiboken2_includes}"]+ modules_incs))
44 print(" ".join([f"-I{PySide2_includes} -I{shiboken2_includes}"]+ modules_incs))
45
45
46
46
General Comments 0
You need to be logged in to leave comments. Login now