cython setup imc_termite pytho module
This commit is contained in:
18
cython/imc_termite.pxd
Normal file
18
cython/imc_termite.pxd
Normal file
@@ -0,0 +1,18 @@
|
||||
# cython: language_level = 3
|
||||
|
||||
# use some C++ STL libraries
|
||||
from libcpp.string cimport string
|
||||
from libcpp.vector cimport vector
|
||||
from libcpp cimport bool
|
||||
|
||||
cdef extern from "imc_raw.hpp" namespace "imc":
|
||||
cdef cppclass imc_termite "imc::raw":
|
||||
# constructor(s)
|
||||
imc_termite() except +
|
||||
imc_termite(string rawfile) except +
|
||||
# provide raw file
|
||||
void submit_file(string rawfile) except+
|
||||
# get JSON list of channels
|
||||
vector[string] get_channels() except+
|
||||
# print all channels
|
||||
void print_channels(string outputdir) except+
|
27
cython/py_imc_termite.pyx
Normal file
27
cython/py_imc_termite.pyx
Normal file
@@ -0,0 +1,27 @@
|
||||
# distutils: language = c++
|
||||
|
||||
from imc_termite cimport imc_termite
|
||||
|
||||
import json as jn
|
||||
# import numpy as np
|
||||
|
||||
cdef class imctermite:
|
||||
|
||||
# C++ instance of class => stack allocated (requires nullary constructor!)
|
||||
cdef imc_termite cpp_imc
|
||||
|
||||
# constructor
|
||||
def __cinit__(self, string rawfile):
|
||||
self.cpp_imc = imc_termite(rawfile)
|
||||
|
||||
# provide raw file
|
||||
def submit_file(self,string rawfile):
|
||||
self.cpp_tdm.set_file(rawfile)
|
||||
|
||||
# get JSON list of channels
|
||||
def get_channels(self, bool data):
|
||||
return self.cpp_imc.get_channels()
|
||||
|
||||
# print a channels
|
||||
def print_channel(self, string outputdir):
|
||||
self.cpp_tdm.print_channels(outputdir)
|
24
cython/setup.py
Normal file
24
cython/setup.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from distutils.core import setup
|
||||
from distutils.extension import Extension
|
||||
from Cython.Build import cythonize
|
||||
|
||||
extensions = Extension(
|
||||
name="imc_termite",
|
||||
sources=["cython/py_imc_termite.pyx"],
|
||||
# libraries=[""],
|
||||
# library_dirs=["lib"],
|
||||
include_dirs=["lib"],
|
||||
language='c++',
|
||||
extra_compile_args=['-std=c++17','-Wno-unused-variable'],
|
||||
extra_link_args=['-std=c++17'],
|
||||
)
|
||||
|
||||
setup(
|
||||
version='0.1',
|
||||
description='IMCtermite cython extension',
|
||||
author='Record Evolution GmbH',
|
||||
author_email='mario.fink@record-evolution.de',
|
||||
url='https://github.com/RecordEvolution/IMCtermite.git',
|
||||
name="imc_termite",
|
||||
ext_modules=cythonize(extensions)
|
||||
)
|
Reference in New Issue
Block a user