Files
ortools-clone/ortools/sat/python/BUILD.bazel

134 lines
3.7 KiB
Python
Raw Normal View History

2025-01-10 11:35:44 +01:00
# Copyright 2010-2025 Google LLC
2022-06-20 18:27:09 +02:00
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
2022-03-30 13:12:32 +02:00
# Python wrapper for cp_model.
2023-04-01 02:42:04 +02:00
load("@pip_deps//:requirements.bzl", "requirement")
2022-03-30 13:12:32 +02:00
load("@pybind11_bazel//:build_defs.bzl", "pybind_extension")
2025-07-23 09:05:10 +00:00
load("@rules_python//python:py_library.bzl", "py_library")
load("@rules_python//python:py_test.bzl", "py_test")
2022-03-30 13:12:32 +02:00
cc_library(
name = "linear_expr_doc",
hdrs = ["linear_expr_doc.h"],
)
cc_library(
name = "linear_expr",
srcs = ["linear_expr.cc"],
hdrs = ["linear_expr.h"],
deps = [
"//ortools/sat:cp_model_cc_proto",
2025-07-18 11:59:34 +00:00
"//ortools/sat:cp_model_utils",
"//ortools/util:fp_roundtrip_conv",
"//ortools/util:sorted_interval_list",
"@abseil-cpp//absl/container:btree",
"@abseil-cpp//absl/container:fixed_array",
"@abseil-cpp//absl/container:flat_hash_map",
"@abseil-cpp//absl/log:check",
"@abseil-cpp//absl/strings",
],
)
2025-07-18 11:59:34 +00:00
cc_library(
name = "wrappers",
srcs = ["wrappers.cc"],
hdrs = ["wrappers.h"],
deps = [
"@abseil-cpp//absl/base:nullability",
"@abseil-cpp//absl/container:flat_hash_map",
"@abseil-cpp//absl/container:flat_hash_set",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/log:check",
"@abseil-cpp//absl/log:die_if_null",
"@abseil-cpp//absl/strings",
"@abseil-cpp//absl/types:span",
"@protobuf",
],
)
cc_binary(
name = "gen_proto_builder_pybind11",
srcs = ["gen_proto_builder_pybind11.cc"],
deps = [
":wrappers",
"//ortools/base",
"//ortools/sat:cp_model_cc_proto",
"//ortools/sat:sat_parameters_cc_proto",
"@abseil-cpp//absl/log:die_if_null",
"@abseil-cpp//absl/strings:str_format",
],
)
genrule(
name = "run_gen_proto_builder_pybind11",
outs = ["proto_builder_pybind11.h"],
cmd = "$(location :gen_proto_builder_pybind11) > $@",
tools = [":gen_proto_builder_pybind11"],
)
cc_library(
name = "proto_builder_pybind11",
hdrs = ["proto_builder_pybind11.h"],
)
2022-03-30 13:12:32 +02:00
pybind_extension(
name = "cp_model_helper",
srcs = ["cp_model_helper.cc"],
2022-03-31 11:36:33 +02:00
visibility = ["//visibility:public"],
2022-03-30 13:12:32 +02:00
deps = [
":linear_expr",
":linear_expr_doc",
2025-07-18 11:59:34 +00:00
":proto_builder_pybind11",
2025-07-21 17:25:33 +02:00
"//ortools/base:string_view_migration",
2022-03-30 13:12:32 +02:00
"//ortools/sat:cp_model_cc_proto",
2024-12-30 11:41:18 +01:00
"//ortools/sat:cp_model_utils",
"//ortools/sat:sat_parameters_cc_proto",
2022-03-30 13:12:32 +02:00
"//ortools/sat:swig_helper",
"@abseil-cpp//absl/strings",
2022-03-30 13:12:32 +02:00
],
)
2023-01-23 17:37:56 +01:00
py_test(
name = "cp_model_helper_test",
srcs = ["cp_model_helper_test.py"],
2023-01-23 17:37:56 +01:00
deps = [
":cp_model_helper",
2023-03-01 11:35:04 +01:00
"//ortools/util/python:sorted_interval_list",
2023-01-23 17:37:56 +01:00
requirement("absl-py"),
],
)
2022-03-30 13:12:32 +02:00
py_library(
name = "cp_model",
srcs = ["cp_model.py"],
visibility = ["//visibility:public"],
deps = [
":cp_model_helper",
requirement("numpy"),
requirement("pandas"),
2023-03-01 11:35:04 +01:00
"//ortools/util/python:sorted_interval_list",
2022-03-30 13:12:32 +02:00
],
)
2023-01-23 17:28:11 +01:00
py_test(
name = "cp_model_test",
srcs = ["cp_model_test.py"],
deps = [
":cp_model",
":cp_model_helper",
2023-01-23 17:37:56 +01:00
requirement("absl-py"),
requirement("numpy"),
2023-01-23 17:28:11 +01:00
],
2023-01-23 17:37:56 +01:00
)