Skip to content

Commit

Permalink
Fix setting the Python version via env variable (#2958)
Browse files Browse the repository at this point in the history
* Fix setting the Python version via env variable

* Fix Python class declaration

* Fix build

* Fix Docker image name
  • Loading branch information
oitel authored Jul 9, 2024
1 parent 0a7667a commit 6368575
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ IF(MESHLIB_PYTHON_SUPPORT AND NOT MR_EMSCRIPTEN)
ENDIF()

IF($ENV{MESHLIB_PYTHON_VERSION})
set(MR_PYTHON_VERSION $ENV{MESHLIB_PYTHON_VERSION})
set(MESHLIB_PYTHON_VERSION $ENV{MESHLIB_PYTHON_VERSION})
ENDIF()

IF(DEFINED MESHLIB_PYTHON_VERSION)
Expand Down
4 changes: 2 additions & 2 deletions source/MRMesh/MRPython.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ MR_ADD_PYTHON_CUSTOM_DEF( moduleName, name##_inst_, [] ( pybind11::module_& modu
* @endcode
* See also \ref MR_ADD_PYTHON_VEC and \ref MR_ADD_PYTHON_MAP macros for customized class definition examples.
*/
#define MR_ADD_PYTHON_CUSTOM_CLASS( moduleName, name, type ) \
MR_ADD_PYTHON_CUSTOM_CLASS_DECL( moduleName, name, type ) \
#define MR_ADD_PYTHON_CUSTOM_CLASS( moduleName, name, ... ) \
MR_ADD_PYTHON_CUSTOM_CLASS_DECL( moduleName, name, __VA_ARGS__ ) \
MR_ADD_PYTHON_CUSTOM_CLASS_INST( moduleName, name )

#define MR_ADD_PYTHON_VEC( moduleName, name, type) \
Expand Down
26 changes: 21 additions & 5 deletions source/mrmeshpy/MRPythonBooleanExposing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,29 @@
#include "MRMesh/MRMeshBoolean.h"
#include "MRMesh/MRUniteManyMeshes.h"
#include "MRMesh/MRId.h"

#include <pybind11/functional.h>

#include <variant>

MR_ADD_PYTHON_CUSTOM_CLASS( mrmeshpy, EdgeTri, MR::EdgeTri )

MR_ADD_PYTHON_CUSTOM_CLASS( mrmeshpy, VariableEdgeTri, MR::VariableEdgeTri, MR::EdgeTri )

MR_ADD_PYTHON_CUSTOM_CLASS( mrmeshpy, OneMeshIntersection, MR::OneMeshIntersection )

MR_ADD_PYTHON_CUSTOM_CLASS( mrmeshpy, OneMeshContour, MR::OneMeshContour )

MR_ADD_PYTHON_CUSTOM_DEF( mrmeshpy, MeshIntersectinosTypes, [] ( pybind11::module_& m )
{
pybind11::class_<MR::EdgeTri>( m, "EdgeTri", "edge from one mesh and triangle from another mesh" ).
MR_PYTHON_CUSTOM_CLASS( EdgeTri ).doc() =
"edge from one mesh and triangle from another mesh";
MR_PYTHON_CUSTOM_CLASS( EdgeTri ).
def( pybind11::init<>() ).
def_readwrite( "edge", &MR::EdgeTri::edge ).
def_readwrite( "tri", &MR::EdgeTri::tri );

pybind11::class_<MR::VariableEdgeTri, MR::EdgeTri>( m, "VariableEdgeTri" ).
MR_PYTHON_CUSTOM_CLASS( VariableEdgeTri ).
def( pybind11::init<>() ).
def_readwrite( "isEdgeATriB", &MR::VariableEdgeTri::isEdgeATriB );

Expand All @@ -31,7 +43,9 @@ MR_ADD_PYTHON_CUSTOM_DEF( mrmeshpy, MeshIntersectinosTypes, [] ( pybind11::modul
def( "getEdge", [] ( const OneMeshIntersectionVariant& self ) { return std::get<MR::EdgeId>( self ); } ).
def( "getVert", [] ( const OneMeshIntersectionVariant& self ) { return std::get<MR::VertId>( self ); } );

pybind11::class_<MR::OneMeshIntersection>( m, "OneMeshIntersection", "Simple point on mesh, represented by primitive id and coordinate in mesh space" ).
MR_PYTHON_CUSTOM_CLASS( OneMeshIntersection ).doc() =
"Simple point on mesh, represented by primitive id and coordinate in mesh space";
MR_PYTHON_CUSTOM_CLASS( OneMeshIntersection ).
def( pybind11::init<>() ).
def_readwrite( "primitiveId", &MR::OneMeshIntersection::primitiveId ).
def_readwrite( "coordinate", &MR::OneMeshIntersection::coordinate );
Expand All @@ -53,9 +67,11 @@ MR_ADD_PYTHON_VEC( mrmeshpy, ContinuousContours, MR::ContinuousContour )

MR_ADD_PYTHON_VEC( mrmeshpy, vectorOneMeshIntersection, MR::OneMeshIntersection )

MR_ADD_PYTHON_CUSTOM_DEF( mrmeshpy, MeshIntersectinosTypes2, [] ( pybind11::module_& m )
MR_ADD_PYTHON_CUSTOM_DEF( mrmeshpy, MeshIntersectinosTypes2, [] ( pybind11::module_& )
{
pybind11::class_<MR::OneMeshContour>( m, "OneMeshContour", "One contour on mesh" ).
MR_PYTHON_CUSTOM_CLASS( OneMeshContour ).doc() =
"One contour on mesh";
MR_PYTHON_CUSTOM_CLASS( OneMeshContour ).
def( pybind11::init<>() ).
def_readwrite( "intersections", &MR::OneMeshContour::intersections ).
def_readwrite( "closed", &MR::OneMeshContour::closed );
Expand Down

0 comments on commit 6368575

Please sign in to comment.