Skip to content

Commit d7d241c

Browse files
committed
Migrate cscore to semiwrap
1 parent 27a4d6a commit d7d241c

File tree

15 files changed

+126
-125
lines changed

15 files changed

+126
-125
lines changed

rdev.toml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ roborio = true
4848
[subprojects."native.wpimath"]
4949
roborio = true
5050

51-
# [subprojects."native.cscore"]
52-
# roborio = true
53-
5451
[subprojects."native.apriltag"]
5552
roborio = true
5653

@@ -83,9 +80,9 @@ roborio = true
8380
min_version = "2025.3.2"
8481
roborio = true
8582

86-
# [subprojects."robotpy-cscore"]
87-
# min_version = "2025.3.2"
88-
# roborio = true
83+
[subprojects."robotpy-cscore"]
84+
min_version = "2025.3.2"
85+
roborio = true
8986

9087
[subprojects."robotpy-apriltag"]
9188
min_version = "2025.3.2"

subprojects/native.cscore/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

subprojects/native.cscore/pyproject.toml

Lines changed: 0 additions & 43 deletions
This file was deleted.

subprojects/robotpy-cscore/.gitignore

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +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/_cscore
13+
/lib
14+
/dist
15+
/build
1516

1617
.project
1718
.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('wrapcfg')
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('wrapcfg/modules')
Lines changed: 62 additions & 34 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-
dependencies = [
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",
4+
"semiwrap",
5+
"hatch-meson",
6+
"hatch-robotpy",
7+
"hatchling",
178
"robotpy-wpiutil~=2025.3.2",
189
"robotpy-wpinet~=2025.3.2",
1910
"pyntcore~=2025.3.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"]

subprojects/robotpy-cscore/setup.py

Lines changed: 0 additions & 5 deletions
This file was deleted.
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

0 commit comments

Comments
 (0)