Skip to content

Commit a3eeb6a

Browse files
committed
feat: build python wheel
1 parent 8dba28a commit a3eeb6a

File tree

7 files changed

+138
-22
lines changed

7 files changed

+138
-22
lines changed

BUILD.bazel

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,28 @@
1-
# This is an empty BUILD file, to ensure that the project's root directory is a
2-
# bazel package.
1+
LIBC3_COMPONENTS = [
2+
"//core:core",
3+
"//multibody:multibody",
4+
"//systems:systems",
5+
]
6+
7+
package(default_visibility = ["//visibility:public"])
8+
9+
# Filegroup collecting all headers
10+
filegroup(
11+
name = "c3_headers",
12+
srcs = [
13+
"//core:headers",
14+
"//multibody:headers",
15+
"//systems:headers",
16+
],
17+
)
18+
19+
# Combined target that provides both the shared library and headers
20+
cc_library(
21+
name = "libc3",
22+
hdrs = [":c3_headers"], # Changed from srcs to hdrs for headers
23+
deps = LIBC3_COMPONENTS + [
24+
"@drake//:drake_shared_library",
25+
],
26+
include_prefix = "c3",
27+
visibility = ["//visibility:public"],
28+
)

bindings/pyc3/BUILD.bazel

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ pybind_py_library(
3535
cc_srcs = ["c3_multibody_py.cc"],
3636
py_deps = [
3737
":module_py",
38-
"@drake//bindings/pydrake"
3938
],
4039
py_imports = ["."],
4140
)
@@ -53,7 +52,6 @@ pybind_py_library(
5352
cc_srcs = ["c3_systems_py.cc"],
5453
py_deps = [
5554
":module_py",
56-
"@drake//bindings/pydrake"
5755
],
5856
py_imports = ["."],
5957
)
@@ -100,12 +98,16 @@ py_package(
10098

10199
py_wheel(
102100
name = "pyc3_wheel",
101+
author = "DAIRLab",
103102
# Package data. We're building "example_minimal_package-0.0.1-py3-none-any.whl"
104103
distribution = "pyc3",
105104
license = "MIT",
106105
platform = "linux_x86_64",
107106
python_tag = "py3",
108107
strip_path_prefixes = ["bindings/"],
108+
requires_file = "//bindings/pyc3:requirements.txt",
109109
version = "0.0.2",
110-
deps = [":c3_pkg"],
110+
deps = [
111+
":c3_pkg",
112+
],
111113
)

bindings/pyc3/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Importing everything in this directory to this package
2+
import pydrake
23
from . import *
34
from .c3 import *
45
from .systems import *

bindings/pyc3/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
drake
2+

core/BUILD.bazel

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33

44
package(default_visibility = ["//visibility:public"])
55

6+
cc_library(
7+
name = "core",
8+
visibility = ["//visibility:public"],
9+
deps = [
10+
":c3",
11+
":options",
12+
":lcs",
13+
],
14+
)
15+
616
cc_library(
717
name = "options",
818
hdrs = ["c3_options.h",
@@ -12,6 +22,13 @@ cc_library(
1222
],
1323
)
1424

25+
filegroup(
26+
name = "default_solver_options",
27+
srcs = [
28+
"configs/solver_options_default.yaml",
29+
],
30+
)
31+
1532
cc_library(
1633
name = "c3",
1734
srcs = [
@@ -30,11 +47,11 @@ cc_library(
3047
"c3_miqp.h",
3148
"c3_qp.h",
3249
],
50+
data = [
51+
":default_solver_options",
52+
],
3353
copts = ["-fopenmp"],
3454
linkopts = ["-fopenmp"],
35-
data = glob([
36-
"configs/**",
37-
]),
3855
deps = [
3956
":lcs",
4057
":options",
@@ -43,6 +60,7 @@ cc_library(
4360
"//tools:with_gurobi": ["@gurobi//:gurobi_cxx"],
4461
"//conditions:default": [],
4562
}),
63+
includes = ['.']
4664
)
4765

4866
cc_library(
@@ -83,4 +101,11 @@ cc_test(
83101
],
84102
)
85103

104+
filegroup(
105+
name = "headers",
106+
srcs = glob([
107+
"*.h",
108+
]),
109+
visibility = ["//visibility:public"],
110+
)
86111

multibody/BUILD.bazel

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33

44
package(default_visibility = ["//visibility:public"])
55

6+
cc_library(
7+
name = "multibody",
8+
visibility = ["//visibility:public"],
9+
deps = [
10+
":lcs_factory",
11+
":options"
12+
],
13+
)
14+
615
cc_library(
716
name = "lcs_factory",
817
srcs = ["lcs_factory.cc",
@@ -47,5 +56,12 @@ cc_test(
4756
":lcs_factory",
4857
"@gtest//:main",
4958
],
59+
)
5060

61+
filegroup(
62+
name = "headers",
63+
srcs = glob([
64+
"*.h",
65+
]),
66+
visibility = ["//visibility:public"],
5167
)

systems/BUILD.bazel

Lines changed: 58 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,79 @@
44
package(default_visibility = ["//visibility:public"])
55

66
cc_library(
7-
name = "vector",
7+
name = "systems",
8+
visibility = ["//visibility:public"],
9+
deps = [
10+
":framework",
11+
":options",
12+
":c3_controller",
13+
":lcs_simulator",
14+
":lcs_factory_system",
15+
]
16+
)
17+
18+
cc_library(
19+
name = "framework",
820
srcs = [
21+
"framework/c3_output.cc",
922
"framework/timestamped_vector.cc",
1023
],
1124
hdrs = [
25+
"framework/c3_output.h",
1226
"framework/timestamped_vector.h",
1327
],
1428
deps = [
1529
"@drake//:drake_shared_library",
1630
],
1731
)
1832

19-
cc_library(
20-
name = "systems",
33+
cc_library( name = "c3_controller",
2134
srcs = [
2235
"c3_controller.cc",
23-
"lcs_simulator.cc",
24-
"framework/c3_output.cc",
25-
"lcs_factory_system.cc",
2636
],
2737
hdrs = [
2838
"c3_controller.h",
29-
"lcs_simulator.h",
30-
"framework/c3_output.h",
31-
"lcs_factory_system.h",
32-
33-
],
39+
],
3440
deps = [
35-
":vector",
3641
":options",
42+
":framework",
3743
"//core:c3",
3844
"//core:options",
3945
"//multibody:lcs_factory",
4046
"@drake//:drake_shared_library",
4147
],
4248
)
4349

50+
cc_library( name = "lcs_simulator",
51+
srcs = [
52+
"lcs_simulator.cc",
53+
],
54+
hdrs = [
55+
"lcs_simulator.h",
56+
],
57+
deps = [
58+
"//core:lcs",
59+
"@drake//:drake_shared_library",
60+
],
61+
)
62+
63+
cc_library(
64+
name = "lcs_factory_system",
65+
srcs = [
66+
"lcs_factory_system.cc",
67+
],
68+
hdrs = [
69+
"lcs_factory_system.h",
70+
],
71+
deps = [
72+
":framework",
73+
"//core:lcs",
74+
"//core:options",
75+
"//multibody:lcs_factory",
76+
"@drake//:drake_shared_library",
77+
],
78+
)
79+
4480
cc_library(
4581
name = "options",
4682
hdrs = [
@@ -64,7 +100,6 @@ cc_library(
64100
"@drake//:drake_shared_library",
65101
],
66102
)
67-
68103
cc_test(
69104
name = "systems_test",
70105
srcs = [
@@ -91,7 +126,16 @@ cc_test(
91126
],
92127
deps = [
93128
":systems",
94-
":vector",
129+
":framework",
95130
"@gtest//:main",
96131
],
97132
)
133+
134+
filegroup(
135+
name = "headers",
136+
srcs = glob([
137+
"*.h",
138+
"**/*.h",
139+
]),
140+
visibility = ["//visibility:public"],
141+
)

0 commit comments

Comments
 (0)