Skip to content

Commit 1866969

Browse files
committed
Update robotpy-cscore to semiwrap
1 parent 1237fa1 commit 1866969

File tree

12 files changed

+126
-78
lines changed

12 files changed

+126
-78
lines changed

subprojects/robotpy-cscore/.gitignore

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
__pycache__
44
*.so
55
*.dll
6+
*.pybind11.json
7+
*.pc
68

7-
/cscore/_init_cscore.py
9+
/cscore/_init__cscore.py
10+
/cscore/trampolines
11+
/cscore/version.py
812

9-
dist
10-
build
11-
version.py
12-
13-
/cscore/pkgcfg.py
14-
/cscore/py.typed
15-
/cscore/_cscore
13+
/lib
14+
/dist
15+
/build
1616

1717
.project
1818
.pydevproject

subprojects/robotpy-cscore/cscore/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from . import _init_cscore
1+
from . import _init__cscore
22

33
# autogenerated by 'robotpy-build create-imports cscore cscore._cscore'
44
from ._cscore import (

subprojects/robotpy-cscore/cscore/src/main.cpp

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

2-
#include <rpygen_wrapper.hpp>
2+
#include <semiwrap_init.cscore._cscore.hpp>
33

44
#include "cscore_cpp.h"
55

@@ -9,7 +9,7 @@ extern "C" {
99
}
1010
#endif
1111

12-
RPYBUILD_PYBIND11_MODULE(m) {
12+
SEMIWRAP_PYBIND11_MODULE(m) {
1313
initWrapper(m);
1414

1515
static int unused; // the capsule needs something to reference
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
project('robotpy-cscore', ['cpp'],
2+
default_options: ['warning_level=1', 'cpp_std=c++20',
3+
'b_colorout=auto', 'optimization=2', 'b_pie=true'])
4+
5+
subdir('semiwrap')
6+
7+
cscore_sources += files(
8+
'cscore/src/main.cpp',
9+
'cscore/cvnp/cvnp.cpp',
10+
'cscore/cvnp/cvnp_synonyms.cpp',
11+
)
12+
13+
#
14+
# Statically link to cscore/opencv to avoid exporting opencv symbols
15+
#
16+
17+
cpp = meson.get_compiler('cpp')
18+
libs_path = meson.current_source_dir() + '/lib/lib'
19+
20+
cscore_deps += [
21+
cpp.find_library('opencv480', dirs: libs_path),
22+
cpp.find_library('cscore', dirs: libs_path),
23+
cpp.find_library('cameraserver', dirs: libs_path),
24+
]
25+
26+
subdir('semiwrap/modules')
Lines changed: 65 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,92 @@
1-
[tool.robotpy-build.metadata]
2-
name = "robotpy-cscore"
3-
description = "RobotPy bindings for cscore image processing library"
4-
author = "RobotPy Development Team"
5-
author_email = "[email protected]"
6-
url = "https://github.com/robotpy/robotpy-cscore"
7-
license = "BSD-3-Clause"
8-
install_requires = [
9-
"robotpy-wpiutil==THIS_VERSION",
10-
"robotpy-wpinet==THIS_VERSION",
11-
"pyntcore==THIS_VERSION",
12-
]
13-
141
[build-system]
2+
build-backend = "hatchling.build"
153
requires = [
16-
"robotpy-build~=2025.1.0",
17-
"robotpy-wpiutil~=2025.3.2",
18-
"robotpy-wpinet~=2025.3.2",
19-
"pyntcore~=2025.3.2",
4+
"semiwrap~=0.1",
5+
"hatch-meson~=0.1.0b2",
6+
"hatch-robotpy~=0.2",
7+
"hatchling",
8+
"robotpy-wpiutil==2025.3.2.2",
9+
"robotpy-wpinet==2025.3.2.2",
10+
"pyntcore==2025.3.2.2",
2011
# "numpy", # required for pybind11-stubgen to not complain, broken in raspbian CI
2112
]
2213

23-
[tool.robotpy-build]
24-
base_package = "cscore"
25-
update_init = [
26-
"cscore"
14+
[project]
15+
name = "robotpy-cscore"
16+
version = "2025.3.2.2"
17+
description = "RobotPy bindings for cscore image processing library"
18+
authors = [
19+
{name = "RobotPy Development Team", email = "[email protected]"},
20+
]
21+
license = "BSD-3-Clause"
22+
dependencies = [
23+
"robotpy-wpiutil==2025.3.2.2",
24+
"robotpy-wpinet==2025.3.2.2",
25+
"pyntcore==2025.3.2.2",
2726
]
2827

29-
[tool.robotpy-build.static_libs."cscore_cpp".maven_lib_download]
28+
[project.urls]
29+
"Source code" = "https://github.com/robotpy/mostrobotpy"
30+
31+
[tool.hatch.build.targets.wheel]
32+
packages = ["cscore"]
33+
34+
[tool.hatch.build.hooks.robotpy]
35+
version_file = "cscore/version.py"
36+
37+
#
38+
# cscore is different -- we download everything as a static library
39+
# and don't include them in the wheel to avoid OpenCV symbol conflicts
40+
#
41+
42+
43+
[[tool.hatch.build.hooks.robotpy.maven_lib_download]]
3044
artifact_id = "cscore-cpp"
3145
group_id = "edu.wpi.first.cscore"
3246
repo_url = "https://frcmaven.wpi.edu/artifactory/release"
3347
version = "2025.3.2"
3448

35-
libs = ["cscore"]
49+
staticlibs = ["cscore"]
50+
extract_to = "lib"
3651

37-
[tool.robotpy-build.static_libs."cameraserver_cpp".maven_lib_download]
52+
[[tool.hatch.build.hooks.robotpy.maven_lib_download]]
3853
artifact_id = "cameraserver-cpp"
3954
group_id = "edu.wpi.first.cameraserver"
4055
repo_url = "https://frcmaven.wpi.edu/artifactory/release"
4156
version = "2025.3.2"
4257

43-
libs = ["cameraserver"]
58+
staticlibs = ["cameraserver"]
59+
extract_to = "lib"
4460

45-
[tool.robotpy-build.static_libs."opencv_cpp".maven_lib_download]
61+
[[tool.hatch.build.hooks.robotpy.maven_lib_download]]
4662
artifact_id = "opencv-cpp"
4763
group_id = "edu.wpi.first.thirdparty.frc2024.opencv"
4864
repo_url = "https://frcmaven.wpi.edu/artifactory/release"
4965
version = "4.8.0-1"
5066

51-
libs = ["opencv480"]
67+
staticlibs = ["opencv480"]
68+
extract_to = "lib"
5269

53-
[tool.robotpy-build.wrappers."cscore"]
54-
name = "cscore"
5570

56-
sources = [
57-
"cscore/src/main.cpp",
58-
"cscore/cvnp/cvnp.cpp",
59-
"cscore/cvnp/cvnp_synonyms.cpp",
71+
[tool.hatch.build.hooks.semiwrap]
72+
73+
[tool.hatch.build.hooks.meson]
74+
75+
76+
[tool.semiwrap]
77+
update_init = [
78+
"cscore"
6079
]
6180

62-
depends = ["wpiutil", "wpinet", "ntcore", "opencv_cpp", "cscore_cpp", "cameraserver_cpp", ]
63-
generation_data = "gen"
81+
[tool.semiwrap.extension_modules."cscore._cscore"]
82+
name = "cscore"
83+
84+
depends = ["wpiutil", "wpinet", "ntcore", "cscore-casters"]
85+
includes = [
86+
"lib/include"
87+
]
6488

65-
[tool.robotpy-build.wrappers."cscore".autogen_headers]
89+
[tool.semiwrap.extension_modules."cscore._cscore".headers]
6690
# cameraserver
6791
CameraServer = "cameraserver/CameraServer.h"
6892

@@ -72,6 +96,10 @@ cscore_oo = "cscore_oo.h"
7296
cscore_cv = "cscore_cv.h"
7397
cscore_runloop = "cscore_runloop.h"
7498

75-
[[tool.robotpy-build.wrappers."cscore".type_casters]]
99+
[tool.semiwrap.export_type_casters.cscore-casters]
100+
pypackage = "cscore"
101+
includedir = ["cscore"]
102+
103+
[[tool.semiwrap.export_type_casters.cscore-casters.headers]]
76104
header = "cvnp/cvnp.h"
77105
types = ["cv::Mat"]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/meson.build
2+
/modules/meson.build
3+
/trampolines/meson.build

subprojects/robotpy-cscore/gen/CameraServer.yml renamed to subprojects/robotpy-cscore/semiwrap/CameraServer.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
---
21

32
extra_includes:
43
- optional
54

65
classes:
7-
CameraServer:
6+
frc::CameraServer:
87
attributes:
98
kBasePort:
109
kSize640x480:
@@ -56,7 +55,7 @@ classes:
5655
AddCamera:
5756
RemoveCamera:
5857
SetSize:
59-
inline_code: |
58+
inline_code: |-
6059
.def_static("waitForever", []() {
6160
auto time_module = py::module::import("time");
6261
while (true) {
@@ -66,4 +65,4 @@ classes:
6665
.def_static("enableLogging", [](std::optional<int> level) {
6766
auto lm = py::module::import("cscore._logging");
6867
lm.attr("enableLogging")(level);
69-
}, py::arg("level") = py::none(), py::doc("Enable cscore logging"))
68+
}, py::arg("level") = py::none(), py::doc("Enable cscore logging"))

subprojects/robotpy-cscore/gen/cscore_cpp.yml renamed to subprojects/robotpy-cscore/semiwrap/cscore_cpp.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21

32
functions:
43
GetPropertyKind:
@@ -242,15 +241,15 @@ functions:
242241
GetNetworkInterfaces:
243242
ignore: true
244243
classes:
245-
UsbCameraInfo:
244+
cs::UsbCameraInfo:
246245
attributes:
247246
dev:
248247
path:
249248
name:
250249
otherPaths:
251250
vendorId:
252251
productId:
253-
VideoMode:
252+
cs::VideoMode:
254253
force_no_trampoline: true
255254
ignored_bases:
256255
- CS_VideoMode
@@ -269,7 +268,7 @@ classes:
269268
.def_readwrite("width", &VideoMode::width)
270269
.def_readwrite("height", &VideoMode::height)
271270
.def_readwrite("fps", &VideoMode::fps)
272-
RawEvent:
271+
cs::RawEvent:
273272
attributes:
274273
kind:
275274
ignore: true

subprojects/robotpy-cscore/gen/cscore_cv.yml renamed to subprojects/robotpy-cscore/semiwrap/cscore_cv.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21

32
extra_includes:
43
- opencv2/core/core.hpp
@@ -24,7 +23,7 @@ functions:
2423
GrabSinkFrameTimeout:
2524
ignore: true
2625
classes:
27-
CvSource:
26+
cs::CvSource:
2827
doc: A source for user code to provide OpenCV images as video frames.
2928
force_no_trampoline: true
3029
methods:
@@ -35,7 +34,7 @@ classes:
3534
std::string_view, const VideoMode&:
3635
std::string_view, VideoMode::PixelFormat, int, int, int:
3736
PutFrame:
38-
CvSink:
37+
cs::CvSink:
3938
doc: A sink for user code to accept video frames as OpenCV images.
4039
force_no_trampoline: true
4140
methods:

0 commit comments

Comments
 (0)