Adapt to jrl-cmakemodules v2 and nix flake + nanobind bindings#67
Adapt to jrl-cmakemodules v2 and nix flake + nanobind bindings#67arntanguy wants to merge 31 commits intojrl-umi3218:masterfrom
Conversation
…d the package to be installed first
[pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci
94c5341 to
cfc9153
Compare
| path = cmake | ||
| url = https://github.com/jrl-umi3218/jrl-cmakemodules | ||
| [submodule "cmake-v2"] | ||
| path = cmake-v2 |
There was a problem hiding this comment.
You could use this script to handle the new jrl-cmakemodules.
This allows to remove submodules completely.
There was a problem hiding this comment.
Thanks. I didn't want to bother with figuring out nix setup (we cannot use FetchContent in that case), so I went the easy route of submodule for now. Turns out it was simple to handle in nix, so this is fixed in e590621
There was a problem hiding this comment.
Good. Once the JRL V2 PR is merged, don't forget to update the link in the fetchcontent part
__init__.py: This is needed to make sphinx doc display as sva.<symbol> instead of sva.sva_pywrap.<symbol> __init__.pyi (generated by cmake): This is needed for LSPs such as pyright to recognise sva.<symbol> Is this a clean way of handling this issue?
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
|
Thanks @ahoarau for the review! Can I ask your opinion on 00ea437 ? When exporting bindings for nanobind, we do and in cmake and With the default everything works as expected in the python interpreter, however other tools are less intuitive. Notably symbols appear under import sva
sva.xxx # does not trigger lsp completion
sva.sva_pywrap.xxx # triggers lsp completionI played around a bit, and:
# Re-export all public names from sva_pywrap
# This is done to get a flat package structure where types appear as
# sva.<classname> instead of sva.sva_pywrap.<symbol>
#
# Consider symbols prefixed with an underscore _<symbol> as private.
# They remain accessible as sva.sva_pywrap._<symbol>
from . import sva_pywrap
for name in dir(sva_pywrap):
if not name.startswith("_"):
globals()[name] = getattr(sva_pywrap, name)
__all__ = [name for name in dir(sva_pywrap) if not name.startswith("_")]we get the expected behaviour in sphinx, however LSP still does not work. To get LSP working, we also need an from .sva_pywrap import *With these changes, it seems that everything works as is most intuitive. However I am not very familiar with python initialization, so I am not sure how valid of an approach this is? If this is a valid approach, should we make it the default/an option for jrl-cmakemodules? |
Interesting point. I must admit I only ported the previous behavior. I must invoke @jorisv on this point. Meanwhile, can you try with: instead of: |
Properties depending on eigen only are bound: - simple eigen types are bound to numpy arrays - quaternions use eigennanopy - tests use numpy and eigennanopy fix pre-commit
…rmd test test_sva_ptransformd is a direct port of the test initially written for cython
for more information, see https://pre-commit.ci
|
My point of view is that the generated stub file should twin the compiled module. Kind of weird that LSP doesn't pick up the symbols from the init file and that an init stub file is required. This shouldn't be the case. In my experience a star import in the init is usually sufficient? |
1c09874 to
d8c579a
Compare
d8c579a to
3b14c12
Compare
This PR is intended as a test of jrl-cmakemodules v2 (jrl-umi3218/jrl-cmakemodules#798) and nix flake integration. It is based on the ongoing nanobind bindings rewrite.
As-is:
add_subdirectory(src)and instead inline the code in the mainCMakeLists. Otherwisejrl_export_package()fails becauseSpaceVecAlgis not found in BUILDSYSTEM_TARGETS