Skip to content

Commit 5c33913

Browse files
authored
refactor: remove mmCoreAndDevices source code , use meson wraps (#65)
* wip using meson wraps * working * add test dep * remove wheelhouse * more update * remove file * fix meson * add test * fix version * add setup * change download * fix sdist * add download * remove uvx * remove bash * update deploy version * less stuff * remove generate_dist * remove factory * fix tests * whoops * clean wheelhouse too * use test-groups instead * update readme * add pymmcore-plus test * remove src/mmcore * remove nodev * remove no build isolation * change adapter strategy * use msvc
1 parent f019dc9 commit 5c33913

216 files changed

Lines changed: 795 additions & 50625 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,10 @@ jobs:
3636
if: matrix.platform == 'windows-latest'
3737
with:
3838
toolset: "14.29"
39-
40-
# - name: install boost
41-
# if: matrix.platform == 'windows-latest'
42-
# run: choco install boost-msvc-14.2
4339

4440
- name: install
45-
# install with devices=true coverage=true
46-
run: just install true true
41+
# install with coverage=true
42+
run: just install true
4743

4844
- name: test
4945
run: uv run --no-sync pytest --color=yes -v --cov --cov-report=xml
@@ -55,3 +51,40 @@ jobs:
5551
with:
5652
token: ${{ secrets.CODECOV_TOKEN }}
5753
files: ./coverage.xml,./coverage_cpp.xml
54+
55+
test-pymmcore-plus:
56+
name: test pymmcore-plus ${{ matrix.os }}
57+
runs-on: ${{ matrix.os }}
58+
strategy:
59+
fail-fast: false
60+
matrix:
61+
os: [ubuntu-latest, windows-latest, macos-latest]
62+
env:
63+
UV_NO_SYNC: "1"
64+
steps:
65+
- uses: actions/checkout@v5
66+
with:
67+
repository: pymmcore-plus/pymmcore-plus
68+
- uses: actions/checkout@v5
69+
with:
70+
path: pymmcore-nano
71+
- uses: astral-sh/setup-uv@v6
72+
with:
73+
python-version: "3.13"
74+
enable-cache: true
75+
- uses: ilammy/msvc-dev-cmd@v1
76+
if: matrix.os == 'windows-latest'
77+
with:
78+
toolset: "14.29"
79+
- name: Setup MM test adapters
80+
uses: pymmcore-plus/setup-mm-test-adapters@main
81+
with:
82+
version: 74
83+
- name: Install dependencies
84+
run: |
85+
uv sync --no-dev --group test
86+
uv pip install ./pymmcore-nano
87+
uv pip uninstall pymmcore
88+
uv pip list
89+
90+
- run: uv run pytest -v --color=yes -W ignore

.github/workflows/deploy.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,11 @@ jobs:
2929
- uses: actions/checkout@v5
3030
with:
3131
fetch-depth: 0
32-
submodules: "recursive"
33-
3432
- uses: ilammy/msvc-dev-cmd@v1
3533
with:
3634
toolset: "14.29"
37-
38-
- run: |
39-
pip install meson
40-
meson rewrite kwargs set project / version $(python scripts/extract_version.py)
35+
- uses: astral-sh/setup-uv@v6
36+
- run: uv run --no-dev --group build scripts/extract_version.py --update
4137

4238
- name: Build wheels
4339
uses: pypa/cibuildwheel@v3.1
@@ -60,13 +56,11 @@ jobs:
6056
- uses: actions/checkout@v5
6157
with:
6258
fetch-depth: 0
63-
submodules: "recursive"
64-
59+
- uses: astral-sh/setup-uv@v6
6560
- name: Build sdist
6661
run: |
67-
pip install -U pip build meson
68-
meson rewrite kwargs set project / version $(python scripts/extract_version.py)
69-
python -m build --sdist
62+
uv run --no-dev --group build scripts/extract_version.py --update
63+
uv build --sdist
7064
7165
- uses: actions/upload-artifact@v4
7266
with:

.github/workflows/docs.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ jobs:
2222
uses: actions/checkout@v5
2323
with:
2424
fetch-depth: 0
25-
submodules: "recursive"
26-
2725
- uses: astral-sh/setup-uv@v6
2826

2927
- name: Deploy to GitHub Pages

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ __pycache__
1515
.coverage
1616
coverage/
1717
coverage*
18-
tests/adapters/
18+
wheelhouse/

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ci:
33
autofix_commit_msg: "style(pre-commit.ci): auto fixes [...]"
44
autoupdate_commit_msg: "ci(pre-commit.ci): autoupdate"
55

6-
exclude: ^src/mmCoreAndDevices
6+
exclude: ^subprojects/
77

88
repos:
99
- repo: https://github.com/pre-commit/pre-commit-hooks

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,22 @@ Experimental python bindings for [CMMCore](https://github.com/micro-manager/mmCo
1010
(the device abstraction layer for micro-manager) using [nanobind](https://nanobind.readthedocs.io/en/latest/).
1111

1212
This package can be used as a (mostly) drop-in replacement for [`pymmcore`](https://pypi.org/project/pymmcore/).
13-
There are a few slight differences in behavior. You are encouraged to try it where you might use
13+
There are a few slight differences in behavior. You are encouraged to try it where you might use
1414
pymmcore; and [let us know](https://github.com/pymmcore-plus/pymmcore-nano/issues) if you run into any issues!
1515

1616
## Installation
1717

1818
```sh
1919
pip install pymmcore-nano
20+
21+
# optionally include device adapters commonly used for demos and testing
22+
# (DemoCamera, Utilities, etc...)
23+
pip install 'pymmcore-nano[test-devices]'
2024
```
2125

2226
Versioning is the same as for pymmcore.
2327

24-
```
28+
```txt
2529
MMCoreMajor.MMCoreMinor.MMCorePatch.DeviceInterface.pymmcore-nano-build
2630
```
2731

@@ -32,7 +36,6 @@ For example, the version `11.3.0.71.2` refers to:
3236
- pymmcore-nano build number of 2 (this is a zero indexed version that resets each time
3337
the MMCore or Device Interface versions increment)
3438

35-
3639
## For Developers
3740

3841
### Clone repo

justfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ set windows-shell := ["pwsh", "-NoLogo", "-NoProfileLoadTime", "-Command"]
44
builddir := "builddir"
55

66
# install deps and editable package for development
7-
install devices="true" coverage="false" verbose="true":
7+
install coverage="false" verbose="true":
88
uv sync --no-install-project
99
uv pip install -e . \
1010
--no-build-isolation \
1111
--no-deps \
1212
--force-reinstall \
13-
-C=setup-args="-Dbuild_device_adapters={{devices}}" \
1413
-C=setup-args="-Db_coverage={{coverage}}" \
1514
-C=setup-args="-Dbuildtype=debugoptimized" \
1615
-C=build-dir={{builddir}} \
@@ -22,7 +21,7 @@ build:
2221

2322
# clean up all build artifacts
2423
clean:
25-
rm -rf build dist {{ builddir }}
24+
rm -rf build dist wheelhouse {{ builddir }}
2625
rm -rf .coverage coverage coverage.info coverage.xml coverage_cpp.xml
2726
rm -rf .ruff_cache .mypy_cache .pytest_cache
2827
rm -rf .mesonpy-*
@@ -42,7 +41,7 @@ test:
4241
# run tests with coverage
4342
test-cov:
4443
just clean-cov
45-
just install true true true
44+
just install true true
4645
rm -rf coverage coverage.xml coverage_cpp.xml
4746
{{ python }} -m pytest -v --color=yes --cov --cov-report=xml
4847
gcovr

meson.build

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,31 @@
11
# replace the version by running:
22
# meson rewrite kwargs set project / version $(python scripts/extract_version.py)
33
project(
4-
'pymmcore-nano',
5-
'cpp',
6-
version : '11.9.0.73.2',
7-
meson_version : '>= 1.2.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'],
99
)
1010

1111
if host_machine.system() == 'darwin'
12-
add_project_arguments('-U_LIBCPP_ENABLE_ASSERTIONS', language: 'cpp')
12+
add_project_arguments('-U_LIBCPP_ENABLE_ASSERTIONS', language: 'cpp')
1313
endif
1414

1515
py = import('python').find_installation(pure: false)
1616
nanobind_dep = dependency('nanobind', static: true)
1717

18-
1918
# Run a command to get the Python include path
2019
python_include_path = run_command(
21-
py.full_path(), ['-c', 'import sysconfig; print(sysconfig.get_paths()["include"])']
20+
py.full_path(),
21+
['-c', 'import sysconfig; print(sysconfig.get_paths()["include"])'],
2222
).stdout().strip()
2323

24-
# Include the subprojects.
25-
subdir('src/mmCoreAndDevices/MMDevice')
26-
subdir('src/mmCoreAndDevices/MMCore')
27-
if get_option('build_device_adapters')
28-
subdir('src/mmCoreAndDevices/DeviceAdapters')
29-
endif
30-
31-
mmdevice_dep = dependency('mmdevice_dep')
32-
mmcore_dep = dependency('mmcore_dep')
33-
24+
mmcore_proj = subproject(
25+
'mmcore',
26+
default_options: {'default_library': 'static', 'tests': 'disabled'},
27+
)
28+
mmcore_dep = mmcore_proj.get_variable('mmcore')
3429

3530
# --------------------------
3631

@@ -47,11 +42,10 @@ if get_option('match_swig')
4742
cpp_args += ['-DMATCH_SWIG']
4843
endif
4944

50-
5145
ext_module = py.extension_module(
5246
'_pymmcore_nano',
53-
sources: ['src/_pymmcore_nano.cc'] + mmcore_sources,
54-
dependencies: [nanobind_dep, mmcore_dep, mmdevice_dep],
47+
sources: ['src/_pymmcore_nano.cc'],
48+
dependencies: [nanobind_dep, mmcore_dep],
5549
install: true,
5650
subdir: 'pymmcore_nano',
5751
cpp_args: cpp_args + ['-DNB_DOMAIN=pmn'],
@@ -67,7 +61,8 @@ custom_target(
6761
py.full_path(),
6862
meson.project_source_root() + '/scripts/build_stubs.py',
6963
ext_module.full_path(),
70-
meson.project_source_root() + '/src/pymmcore_nano/_pymmcore_nano.pyi',
64+
meson.project_source_root()
65+
+ '/src/pymmcore_nano/_pymmcore_nano.pyi',
7166
],
7267
depends: ext_module,
7368
)
@@ -91,5 +86,3 @@ test(
9186
args: ['-m', 'pytest', '--color=yes', '-v'],
9287
workdir: meson.current_source_dir(),
9388
)
94-
95-
meson.add_dist_script(py.full_path(), meson.current_source_dir() / 'scripts/generate_dist.py')

meson_options.txt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,5 @@ option(
88
'match_swig',
99
type: 'boolean',
1010
value: true,
11-
description: 'Define MATCH_SWIG, to export all enum instances as top level names'
12-
)
13-
option('client_interface', type: 'boolean', value: false,
14-
description: 'Build for use by MMCore, as opposed to by a device adapter',
15-
)
16-
option('build_device_adapters', type: 'boolean', value: false,
17-
description: 'Build device adapters in addition to the core library',
11+
description: 'Define MATCH_SWIG, to export all enum instances as top level names',
1812
)

pyproject.toml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,26 @@ classifiers = [
3232
]
3333
dependencies = ["numpy>=1.25"]
3434

35+
[project.optional-dependencies]
36+
test-devices = ["mm-test-adapters~=74.0"]
37+
3538
[dependency-groups]
3639
build = ["meson-python", "nanobind", "ninja", "ruff", "typing_extensions"]
40+
test = [
41+
"pytest",
42+
"pytest-cov",
43+
"gcovr",
44+
"libclang>=18.1.1",
45+
"pymmcore-nano[test-devices]",
46+
]
3747
dev = [
48+
{ include-group = "test" },
3849
{ include-group = "build" },
3950
"clang-format>=19.1.7",
40-
"libclang>=18.1.1",
41-
"gcovr",
4251
"ipython",
4352
"mypy",
4453
"pdbpp; sys_platform != 'win32'",
4554
"pre-commit-uv",
46-
"pytest-cov",
47-
"pytest",
4855
"rich",
4956
"rust-just",
5057
]
@@ -67,7 +74,7 @@ show_missing = true
6774

6875
[tool.coverage.run]
6976
omit = ['subprojects/']
70-
source = ["pymmcore_nano", "mmCoreAndDevices"]
77+
source = ["pymmcore_nano"]
7178

7279
[tool.cibuildwheel]
7380
build-verbosity = 1
@@ -76,9 +83,8 @@ build-verbosity = 1
7683
# is specific to glibc and not available in musl-libc
7784
skip = ["*-manylinux_i686", "*-musllinux*", "*-win32", "pp*"]
7885
build = ["cp39-*", "cp310-*", "cp311-*", "cp312-*", "cp313-*"]
79-
test-requires = ["pytest", 'libclang>=18.1.1']
86+
test-groups = ["test"]
8087
test-command = 'pytest "{project}/tests" -v'
81-
test-skip = ["*-macosx*", "*linux*"] # until we build device adapters locally
8288

8389
[tool.cibuildwheel.macos]
8490
# https://cibuildwheel.readthedocs.io/en/stable/faq/#apple-silicon

0 commit comments

Comments
 (0)