Skip to content

Commit e7a1d8a

Browse files
committed
routing: fix python build
1 parent aecad32 commit e7a1d8a

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

ortools/python/setup.py.in

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ setup(
103103
'$<TARGET_FILE_NAME:pdlp_pybind11>',
104104
'*.pyi'
105105
],
106-
'@[email protected]':['*.pyi'],
106+
107+
'$<TARGET_FILE_NAME:pywraprouting>',
108+
'*.pyi'
109+
],
107110
108111
'$<TARGET_FILE_NAME:routing_pybind11>',
109112
'*.pyi'

ortools/routing/python/routing.i

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424
%include "ortools/util/python/pair.i"
2525
%include "ortools/util/python/vector.i"
2626

27-
%import "ortools/constraint_solver/python/constraint_solver.i"
27+
// While the module name will be overridden by the one specified on the cmd line,
28+
// without this, derived classes (e.g. TypeRequirementChecker) will import base
29+
// class from the module specified in the following %import.
30+
%module pywraprouting
31+
%import(module="ortools.constraint_solver.pywrapcp") "ortools/constraint_solver/python/constraint_solver.i"
2832
%include "ortools/routing/python/types.i"
2933
%include "ortools/routing/python/index_manager.i"
3034

@@ -63,6 +67,8 @@ DEFINE_INDEX_TYPE_TYPEDEF(
6367
operations_research::RoutingResourceClassIndex,
6468
operations_research::RoutingModel::ResourceClassIndex);
6569

70+
// ============= Type conversions ==============
71+
6672
// See ./constraint_solver_helpers.i.
6773
PY_CONVERT_HELPER_INTEXPR_AND_INTVAR();
6874
PY_CONVERT_HELPER_PTR(IntervalVar);
@@ -99,9 +105,12 @@ PY_PROTO_TYPEMAP(ortools.routing.parameters_pb2,
99105
%include "ortools/routing/parameters.h"
100106
%unignoreall
101107

108+
%unignore operations_research;
109+
110+
namespace operations_research {
111+
102112
// %including a .pb.h is frowned upon (for good general reasons), so we
103113
// have to duplicate the OptionalBoolean enum here to give it to python users.
104-
namespace operations_research {
105114
enum OptionalBoolean {
106115
BOOL_UNSPECIFIED = 0,
107116
BOOL_FALSE = 2,

0 commit comments

Comments
 (0)