-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Very very early WIP to start building out pybind11 versions of CMake Bring over a bunch of the constants, but declare them as pybind11 enums. I'm not sure yet how best to expose some of the stuff PyAlembic will eventually need, and I needed to put PyImathVec.cpp in MODSOURCE as the register symbols were not being found in LIBSOURCE. Signed-off-by: Lucas Miller <[email protected]> * Add an option to build the pybind11 bindings. Make sure we dont try to use both at the same time. Signed-off-by: Lucas Miller <[email protected]> * Address most PR feedback. Signed-off-by: Lucas Miller <[email protected]> --------- Signed-off-by: Lucas Miller <[email protected]>
- Loading branch information
Showing
8 changed files
with
200 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright Contributors to the OpenEXR Project. | ||
|
||
pyimath_define_module(imath | ||
LIBNAME PyBindImath | ||
PRIV_EXPORT PYIMATH_BUILD | ||
CURDIR ${CMAKE_CURRENT_SOURCE_DIR} | ||
LIBSOURCE | ||
PyImathVec.cpp | ||
MODSOURCE | ||
imathmodule.cpp | ||
PyImathVec.cpp | ||
HEADERS | ||
PyImathExport.h | ||
DEPENDENCIES | ||
Imath | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// Copyright Contributors to the OpenEXR Project. | ||
// | ||
|
||
// clang-format off | ||
|
||
#include <pybind11/pybind11.h> | ||
#include <pybind11/pytypes.h> | ||
#include <pybind11/stl.h> | ||
#include <pybind11/stl_bind.h> | ||
#include <pybind11/operators.h> | ||
#include "PyImathExport.h" | ||
|
||
#ifndef _PyBindImath_h_ | ||
#define _PyBindImath_h_ | ||
|
||
namespace PyImath { | ||
|
||
PYIMATH_EXPORT void register_imath_vec(pybind11::module& m); | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// Copyright Contributors to the OpenEXR Project. | ||
// | ||
|
||
// clang-format off | ||
|
||
#ifndef PYBINDIMATHEXPORT_H | ||
#define PYBINDIMATHEXPORT_H | ||
|
||
#if defined(IMATH_DLL) | ||
#if defined(PLATFORM_VISIBILITY_AVAILABLE) | ||
#define PYIMATH_EXPORT __attribute__((visibility("default"))) | ||
#define PYIMATH_EXPORT __attribute__((visibility("default"))) | ||
#elif defined(_MSC_VER) | ||
#if defined(PYIMATH_BUILD) | ||
#define PYIMATH_EXPORT __declspec(dllexport) | ||
#else | ||
#define PYIMATH_EXPORT __declspec(dllimport) | ||
#endif | ||
#else | ||
#define PYIMATH_EXPORT | ||
#endif | ||
#else | ||
#define PYIMATH_EXPORT | ||
#endif | ||
|
||
#endif // #ifndef PYBINDIMATHEXPORT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// Copyright Contributors to the OpenEXR Project. | ||
// | ||
|
||
#include "PyImath.h" | ||
#include <ImathVec.h> | ||
|
||
namespace PyImath { | ||
|
||
void register_imath_vec(pybind11::module& m) | ||
{ | ||
// TODO fill in | ||
pybind11::class_<Imath::V3f>(m, "V3f"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// Copyright Contributors to the OpenEXR Project. | ||
// | ||
|
||
#include "PyImath.h" | ||
#include <ImathEuler.h> | ||
|
||
PYBIND11_MODULE(imath, m) | ||
{ | ||
m.doc() = "Imath module"; | ||
m.attr("__version__") = IMATH_VERSION_STRING; | ||
|
||
PyImath::register_imath_vec(m); | ||
// | ||
// Initialize constants | ||
// | ||
pybind11::enum_<IMATH_NAMESPACE::Eulerf::Order>(m, "Order") | ||
.value("EULER_XYZ", IMATH_NAMESPACE::Eulerf::XYZ) | ||
.value("EULER_XZY", IMATH_NAMESPACE::Eulerf::XZY) | ||
.value("EULER_YZX", IMATH_NAMESPACE::Eulerf::YZX) | ||
.value("EULER_YXZ", IMATH_NAMESPACE::Eulerf::YXZ) | ||
.value("EULER_ZXY", IMATH_NAMESPACE::Eulerf::ZXY) | ||
.value("EULER_ZYX", IMATH_NAMESPACE::Eulerf::ZYX) | ||
.value("EULER_XZX", IMATH_NAMESPACE::Eulerf::XZX) | ||
.value("EULER_XYX", IMATH_NAMESPACE::Eulerf::XYX) | ||
.value("EULER_YXY", IMATH_NAMESPACE::Eulerf::YXY) | ||
.value("EULER_YZY", IMATH_NAMESPACE::Eulerf::YZY) | ||
.value("EULER_ZYZ", IMATH_NAMESPACE::Eulerf::ZYZ) | ||
.value("EULER_ZXZ", IMATH_NAMESPACE::Eulerf::ZXZ) | ||
.value("EULER_XYZr", IMATH_NAMESPACE::Eulerf::XYZr) | ||
.value("EULER_XZYr", IMATH_NAMESPACE::Eulerf::XZYr) | ||
.value("EULER_YZXr", IMATH_NAMESPACE::Eulerf::YZXr) | ||
.value("EULER_YXZr", IMATH_NAMESPACE::Eulerf::YXZr) | ||
.value("EULER_ZXYr", IMATH_NAMESPACE::Eulerf::ZXYr) | ||
.value("EULER_ZYXr", IMATH_NAMESPACE::Eulerf::ZYXr) | ||
.value("EULER_XZXr", IMATH_NAMESPACE::Eulerf::XZXr) | ||
.value("EULER_XYXr", IMATH_NAMESPACE::Eulerf::XYXr) | ||
.value("EULER_YXYr", IMATH_NAMESPACE::Eulerf::YXYr) | ||
.value("EULER_YZYr", IMATH_NAMESPACE::Eulerf::YZYr) | ||
.value("EULER_ZYZr", IMATH_NAMESPACE::Eulerf::ZYZr) | ||
.value("EULER_ZXZr", IMATH_NAMESPACE::Eulerf::ZXZr) | ||
.export_values(); | ||
|
||
pybind11::enum_<IMATH_NAMESPACE::Eulerf::Axis>(m, "Axis") | ||
.value("EULER_X_AXIS", IMATH_NAMESPACE::Eulerf::X) | ||
.value("EULER_Y_AXIS", IMATH_NAMESPACE::Eulerf::Y) | ||
.value("EULER_Z_AXIS", IMATH_NAMESPACE::Eulerf::Z) | ||
.export_values(); | ||
|
||
pybind11::enum_<IMATH_NAMESPACE::Eulerf::InputLayout>(m, "InputLayout") | ||
.value("EULER_IJKLayout", IMATH_NAMESPACE::Eulerf::IJKLayout) | ||
.value("EULER_XYZLayout", IMATH_NAMESPACE::Eulerf::XYZLayout) | ||
.export_values(); | ||
|
||
|
||
m.attr("INT_MIN") = std::numeric_limits<int>::min(); | ||
m.attr("INT_MAX") = std::numeric_limits<int>::max(); | ||
m.attr("INT_LOWEST") = std::numeric_limits<int>::lowest(); | ||
m.attr("INT_EPS") = std::numeric_limits<int>::epsilon(); | ||
|
||
m.attr("FLT_MIN") = std::numeric_limits<float>::min(); | ||
m.attr("FLT_MAX") = std::numeric_limits<float>::max(); | ||
m.attr("FLT_LOWEST") = std::numeric_limits<float>::lowest(); | ||
m.attr("FLT_EPS") = std::numeric_limits<float>::epsilon(); | ||
|
||
m.attr("DBL_MIN") = std::numeric_limits<double>::min(); | ||
m.attr("DBL_MAX") = std::numeric_limits<double>::max(); | ||
m.attr("DBL_LOWEST") = std::numeric_limits<double>::lowest(); | ||
m.attr("DBL_EPS") = std::numeric_limits<double>::epsilon(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters