Commit 2ea4d9e9 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[python] add first bindings

parent e177065e
......@@ -85,6 +85,22 @@ else ()
message(FATAL_ERROR "OpenCascade sources not found")
endif ()
# option to enable/disable python bindings (default: on)
option(FRACKIT_ENABLE_PYTHONBINDINGS "Enable python bindings for Frackit" ON)
# python and pybind11 for python bindings
find_package(PythonInterp 3)
find_package(pybind11)
if (FRACKIT_ENABLE_PYTHONBINDINGS AND NOT PYTHONINTERP_FOUND)
set(FRACKIT_ENABLE_PYTHONBINDINGS OFF)
message("Python interpreter not found. This is required to build the python library.")
elseif (FRACKIT_ENABLE_PYTHONBINDINGS AND NOT pybind11_FOUND)
set(FRACKIT_ENABLE_PYTHONBINDINGS OFF)
message("Pybind11 is required to build the python library.")
endif ()
# TODO: make sure pip is installed
# indicate the documentation build as an option and set it to ON by default
option(FRACKIT_BUILD_DOC "Build documentation" ON)
......@@ -118,4 +134,7 @@ add_subdirectory(appl)
add_subdirectory(cmake)
add_subdirectory(doc)
add_subdirectory(frackit)
if (FRACKIT_ENABLE_PYTHONBINDINGS)
add_subdirectory(python)
endif ()
add_subdirectory(test)
......@@ -8,4 +8,7 @@ add_subdirectory(io)
add_subdirectory(magnitude)
add_subdirectory(occ)
add_subdirectory(precision)
if (FRACKIT_ENABLE_PYTHONBINDINGS)
add_subdirectory(python)
endif ()
add_subdirectory(sampling)
if (FRACKIT_ENABLE_PYTHONBINDINGS)
add_subdirectory(frackit)
# modify contents (version etc) in setup file and symlink
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in
${CMAKE_CURRENT_SOURCE_DIR}/setup.py)
frackit_symlink_or_copy(FILES setup.py)
# define target for python library
add_custom_target(install_python
COMMAND "${PYTHON_EXECUTABLE}" -m pip install "${CMAKE_CURRENT_BINARY_DIR}"
COMMENT "Installing the python package at ${CMAKE_CURRENT_BINARY_DIR}"
)
# installation rule
install(CODE "message(\"Installing the python package wheel at ${CMAKE_CURRENT_BINARY_DIR}\")
execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip wheel ${CMAKE_CURRENT_BINARY_DIR}
ERROR_MESSAGE \"Error installing wheel for python package at ${CMAKE_CURRENT_BINARY_DIR}\")"
)
endif()
add_subdirectory(common)
add_subdirectory(geometry)
add_subdirectory(precision)
frackit_symlink_or_copy(FILES __init__.py)
pybind11_add_module(_common _common.cc)
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program 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. *
* *
* This program 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 <frackit/python/common/math.hh>
PYBIND11_MODULE(_common, module)
{
Frackit::Python::registerMath<double>(module);
}
frackit_symlink_or_copy(FILES __init__.py)
pybind11_add_module(_geometry _geometry.cc)
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program 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. *
* *
* This program 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 <frackit/python/geometry/geometry.hh>
#include <frackit/python/geometry/point.hh>
#include <frackit/python/geometry/direction.hh>
#include <frackit/python/geometry/plane.hh>
#include <frackit/python/geometry/vector.hh>
#include <frackit/python/geometry/segment.hh>
#include <frackit/python/geometry/line.hh>
#include <frackit/python/geometry/triangle.hh>
#include <frackit/python/geometry/quadrilateral.hh>
#include <frackit/python/geometry/ellipticalgeometry.hh>
#include <frackit/python/geometry/ellipse.hh>
#include <frackit/python/geometry/ellipsearc.hh>
#include <frackit/python/geometry/disk.hh>
#include <frackit/python/geometry/circle.hh>
#include <frackit/python/geometry/cylinder.hh>
#include <frackit/python/geometry/hollowcylinder.hh>
#include <frackit/python/geometry/cylindersurface.hh>
#include <frackit/python/geometry/box.hh>
PYBIND11_MODULE(_geometry, module)
{
Frackit::Python::registerGeometry(module);
Frackit::Python::registerPoint<double>(module);
Frackit::Python::registerVector<double>(module);
Frackit::Python::registerDirection<double>(module);
Frackit::Python::registerSegment<double>(module);
Frackit::Python::registerLine<double>(module);
Frackit::Python::registerEllipticalGeometry<double>(module);
Frackit::Python::registerEllipse<double>(module);
Frackit::Python::registerEllipseArc<double>(module);
Frackit::Python::registerCircle<double>(module);
Frackit::Python::registerPlane<double>(module);
Frackit::Python::registerTriangle<double>(module);
Frackit::Python::registerQuadrilateral<double>(module);
Frackit::Python::registerDisk<double>(module);
Frackit::Python::registerCylinderSurface<double>(module);
Frackit::Python::registerCylinder<double>(module);
Frackit::Python::registerHollowCylinder<double>(module);
Frackit::Python::registerBox<double>(module);
}
frackit_symlink_or_copy(FILES __init__.py)
pybind11_add_module(_precision _precision.cc)
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program 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. *
* *
* This program 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 <frackit/python/precision/precision.hh>
PYBIND11_MODULE(_precision, module)
{
// register the precision class
Frackit::Python::registerPrecision<double>(module);
}
from setuptools import setup, find_namespace_packages
setup(
name = "frackit",
version = "1.0.0",
author = "Dennis Glaeser",
author_email = "dennis.glaeser@iws.uni-stuttgart.de",
description = "Frackit Python library",
long_description = "",
packages = find_namespace_packages(include=["frackit.*"]),
package_data = {"": ["*.so"]},
zip_safe = False,
)
from setuptools import setup, find_namespace_packages
setup(
name = "frackit",
version = "${FRACKIT_VERSION}",
author = "Dennis Glaeser",
author_email = "dennis.glaeser@iws.uni-stuttgart.de",
description = "Frackit Python library",
long_description = "",
packages = find_namespace_packages(include=["frackit.*"]),
package_data = {"": ["*.so"]},
zip_safe = False,
)
Supports Markdown
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