Commit 53db3b12 authored by TOUZE Francois's avatar TOUZE Francois
Browse files

docker containers creation: step 2

parent 58fd6992
......@@ -2,5 +2,5 @@
how to wrap C++ with Cython.
Assuming you have Python, Cython, Git and a C++ compiler installed
$ python setup.py build_ext --inplace
$ python pspaclass.py build_ext --inplace
#include <iostream>
#include "cppcode.h"
#include "pspaclass.h"
#include "componentFactory.h"
......
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
xtension = Extension(
name="pypspaclass",
sources=["pypspaclass.pyx",
"/home/pspa/backend/pspa/v0/src/Core/dataManager.cpp"],
libraries=["pspa","uap","antlr","xerces-c"],
include_dirs=["/home/pspa/backend/pspa/v0/src/Core",
"/home/pspa/backend/pspa/v0/src/KindOfElements",
"/usr/local/accelerator-ml-code",
"/usr/local/json/include"],
library_dirs=["/home/pspa/backend/pspa/v0/Linux-x86_64",
"/usr/local/accelerator-ml-code/lib",
"/usr/local/lib"]
)
setup(
name="pypspaclass",
ext_modules=cythonize([xtension])
)
This diff is collapsed.
#ifndef __SETTINGPLOTS_H__
#define __SETTINGPLOTS_H__
#include <string>
#include <vector>
#include <map>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
using namespace std;
class pspaplot
{
string userDir_;
json phaseSpace(json,string);
json plotSelection(json);
vector<double> menu1(string,json);
map<string,vector<double> > menu2(string,json);
json beamParameters(json);
void submenu1(string,json,double&,vector<double>&);
void submenu2(string,json,map<string,vector<double> >&);
void menu(string,json,map<string,vector<double> >&);
json lineplots(vector<double>,map<string,vector<double> >);
public:
pspaplot();
pspaplot( string );
~pspaplot();
void settings( string );
};
#endif
from libcpp.string cimport string
cdef extern from "pspaplot.cpp":
pass
cdef extern from "pspaplot.h":
cdef cppclass pspaplot:
pspaplot() except +
pspaplot( string ) except +
void settings( string )
from distutils.core import setup
from Cython.Build import cythonize
setup(
ext_modules=cythonize("pypspaplot.pyx")
)
# distutils: language = c++
from pspaplot cimport pspaplot
from libcpp.string cimport string
cdef class PyPspaPlot:
cdef pspaplot *ptr
def __cinit__(self):
self.ptr = new pspaplot()
def __cinit__(self, string s):
self.ptr = new pspaplot( s )
def __dealloc__(self):
del self.ptr
def settings(self, string s):
return self.ptr.settings( s )
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment