diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000000000000000000000000000000000..a90eb86150542c0283e6e7a9c45ceef1ec376b0c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "pybind11"] + path = pybind11 + url = https://github.com/pybind/pybind11.git diff --git a/pybind11 b/pybind11 new file mode 160000 index 0000000000000000000000000000000000000000..8fbb5594fdf02eea6024d7b0c5eef3891d7366ab --- /dev/null +++ b/pybind11 @@ -0,0 +1 @@ +Subproject commit 8fbb5594fdf02eea6024d7b0c5eef3891d7366ab diff --git a/src/python.cpp b/src/python.cpp new file mode 100644 index 0000000000000000000000000000000000000000..34d24a190c60d9434a2f4e405eb6148e3a1f8bd6 --- /dev/null +++ b/src/python.cpp @@ -0,0 +1,44 @@ +/* + * python.cpp + * + * Copyright 2018 Maximilian Reininghaus <maximilian.reininghaus@kit.edu> + * + * This file is part of ngC. + * + * ngC is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * ngC is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include <pybind11/pybind11.h> +#include "ParticleID.hpp" + +/* + * to compile, cd to ngc/build and + * g++ -shared -fPIC -std=c++14 -I /usr/include/python3.5/ \ + * -I ../pybind11/include/ -I ../include \ + * -o example`python3-config --extension-suffix` ../src/python.cpp + * then open a python3 shell and import example + */ + +PYBIND11_MODULE(example, m) { + m.doc() = "pybind11 example plugin"; // optional module docstring + + pybind11::enum_<ngc::ParticleID>(m, "ParticleID") + .value("gamma", ngc::ParticleID::GAMMA) + .value("positron", ngc::ParticleID::POSITRON) + .value("electron", ngc::ParticleID::ELECTRON) + .value("mu_p", ngc::ParticleID::MU_P) + .value("mu_m", ngc::ParticleID::MU_M); + // to be continued... +}