1
1
# replace the version by running:
2
2
# meson rewrite kwargs set project / version $(python scripts/extract_version.py)
3
3
project (
4
- ' pymmcore-nano' ,
5
- ' cpp' ,
6
- version : ' 11.10.0.74.0' ,
7
- meson_version : ' >=1.4.0' ,
8
- default_options : [' cpp_std=c++17' ]
4
+ ' pymmcore-nano' ,
5
+ ' cpp' ,
6
+ version : ' 11.10.0.74.0' ,
7
+ meson_version : ' >=1.4.0' ,
8
+ default_options : [' cpp_std=c++17' ],
9
9
)
10
10
11
11
if host_machine .system() == ' darwin'
@@ -52,37 +52,50 @@ ext_module = py.extension_module(
52
52
)
53
53
54
54
# Create stubs using nanobind.stubgen
55
- custom_target (
55
+ stub_target = custom_target (
56
56
' generate_stubs' ,
57
- build_by_default : true ,
58
57
input : [ext_module],
59
58
output : ' _pymmcore_nano.pyi' ,
60
59
command : [
61
60
py.full_path(),
62
- meson .project_source_root() + ' /scripts/build_stubs.py' ,
63
- ext_module.full_path(),
64
- meson .project_source_root()
65
- + ' /src/pymmcore_nano/_pymmcore_nano.pyi' ,
61
+ meson .project_source_root() / ' scripts' / ' build_stubs.py' ,
62
+ ' @INPUT@' , # path to built extension
63
+ ' @OUTPUT@' , # write stub to this path
66
64
],
65
+ build_by_default : true ,
66
+ install : true ,
67
+ install_dir : py.get_install_dir() / ' pymmcore_nano' ,
67
68
depends : ext_module,
68
69
)
69
70
70
- # install the Python package into the site-packages directory
71
- install_subdir (
72
- ' src/pymmcore_nano' ,
73
- install_dir : py.get_install_dir() / ' pymmcore_nano' ,
74
- strip_directory : true ,
71
+ # Copy stub to source tree for development (so Pyright can find it)
72
+ custom_target (
73
+ ' copy_stubs_to_src' ,
74
+ input : stub_target,
75
+ output : ' stub_copied_marker' ,
76
+ command : [
77
+ py.full_path(),
78
+ ' -c' ,
79
+ ' import shutil; shutil.copy(r"@INPUT@", r"@0@")' .format(
80
+ meson .project_source_root() / ' src' / ' pymmcore_nano' / ' _pymmcore_nano.pyi'
81
+ )
82
+ ],
83
+ build_by_default : true ,
84
+ depends : stub_target,
75
85
)
76
86
77
- # also install the stubs into the site-packages directory
78
- install_data (
79
- ' src/pymmcore_nano/_pymmcore_nano.pyi' ,
80
- install_dir : py.get_install_dir() / ' pymmcore_nano' ,
87
+ # Install the pure-Python package bits
88
+ py.install_sources(
89
+ files (
90
+ ' src/pymmcore_nano/__init__.py' ,
91
+ ' src/pymmcore_nano/py.typed' ,
92
+ ),
93
+ subdir : ' pymmcore_nano' ,
81
94
)
82
95
83
96
test (
84
97
' test_script' ,
85
98
py,
86
99
args : [' -m' , ' pytest' , ' --color=yes' , ' -v' ],
87
100
workdir : meson .current_source_dir(),
88
- )
101
+ )
0 commit comments