From b91f6cbf25b39d0fe1b2391a9117e865e6861192 Mon Sep 17 00:00:00 2001 From: snoyer Date: Wed, 18 Dec 2024 15:34:24 +0400 Subject: [PATCH 01/26] reorder bindings declaration --- python/F3DPythonBindings.cxx | 60 +++++++++++++++++------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/python/F3DPythonBindings.cxx b/python/F3DPythonBindings.cxx index 96c54a7f98..403c394d98 100644 --- a/python/F3DPythonBindings.cxx +++ b/python/F3DPythonBindings.cxx @@ -328,7 +328,6 @@ PYBIND11_MODULE(pyf3d, module) .def_readwrite("focal_point", &f3d::camera_state_t::focalPoint) .def_readwrite("view_up", &f3d::camera_state_t::viewUp) .def_readwrite("view_angle", &f3d::camera_state_t::viewAngle); - // f3d::window py::class_> window(module, "Window"); @@ -367,6 +366,28 @@ PYBIND11_MODULE(pyf3d, module) .def("get_display_from_world", &f3d::window::getDisplayFromWorld, "Get display coordinate point from world coordinate"); + // libInformation + py::class_(module, "LibInformation") + .def_readonly("version", &f3d::engine::libInformation::Version) + .def_readonly("version_full", &f3d::engine::libInformation::VersionFull) + .def_readonly("build_date", &f3d::engine::libInformation::BuildDate) + .def_readonly("build_system", &f3d::engine::libInformation::BuildSystem) + .def_readonly("compiler", &f3d::engine::libInformation::Compiler) + .def_readonly("modules", &f3d::engine::libInformation::Modules) + .def_readonly("vtk_version", &f3d::engine::libInformation::VTKVersion) + .def_readonly("copyrights", &f3d::engine::libInformation::Copyrights) + .def_readonly("license", &f3d::engine::libInformation::License); + + // readerInformation + py::class_(module, "ReaderInformation") + .def_readonly("name", &f3d::engine::readerInformation::Name) + .def_readonly("description", &f3d::engine::readerInformation::Description) + .def_readonly("extensions", &f3d::engine::readerInformation::Extensions) + .def_readonly("mime_types", &f3d::engine::readerInformation::MimeTypes) + .def_readonly("plugin_name", &f3d::engine::readerInformation::PluginName) + .def_readonly("has_scene_reader", &f3d::engine::readerInformation::HasSceneReader) + .def_readonly("has_geometry_reader", &f3d::engine::readerInformation::HasGeometryReader); + // f3d::engine py::class_ engine(module, "Engine"); @@ -407,39 +428,9 @@ PYBIND11_MODULE(pyf3d, module) .def_static("get_readers_info", &f3d::engine::getReadersInfo) .def_static("get_rendering_backend_list", &f3d::engine::getRenderingBackendList); - // libInformation - py::class_(module, "LibInformation") - .def_readonly("version", &f3d::engine::libInformation::Version) - .def_readonly("version_full", &f3d::engine::libInformation::VersionFull) - .def_readonly("build_date", &f3d::engine::libInformation::BuildDate) - .def_readonly("build_system", &f3d::engine::libInformation::BuildSystem) - .def_readonly("compiler", &f3d::engine::libInformation::Compiler) - .def_readonly("modules", &f3d::engine::libInformation::Modules) - .def_readonly("vtk_version", &f3d::engine::libInformation::VTKVersion) - .def_readonly("copyrights", &f3d::engine::libInformation::Copyrights) - .def_readonly("license", &f3d::engine::libInformation::License); - - // readerInformation - py::class_(module, "ReaderInformation") - .def_readonly("name", &f3d::engine::readerInformation::Name) - .def_readonly("description", &f3d::engine::readerInformation::Description) - .def_readonly("extensions", &f3d::engine::readerInformation::Extensions) - .def_readonly("mime_types", &f3d::engine::readerInformation::MimeTypes) - .def_readonly("plugin_name", &f3d::engine::readerInformation::PluginName) - .def_readonly("has_scene_reader", &f3d::engine::readerInformation::HasSceneReader) - .def_readonly("has_geometry_reader", &f3d::engine::readerInformation::HasGeometryReader); - // f3d::log py::class_ log(module, "Log"); - log // - .def_static("set_verbose_level", &f3d::log::setVerboseLevel, py::arg("level"), - py::arg("force_std_err") = false) - .def_static("set_use_coloring", &f3d::log::setUseColoring) - .def_static("print", - [](f3d::log::VerboseLevel& level, const std::string& message) - { f3d::log::print(level, message); }); - py::enum_(log, "VerboseLevel") .value("DEBUG", f3d::log::VerboseLevel::DEBUG) .value("INFO", f3d::log::VerboseLevel::INFO) @@ -447,4 +438,11 @@ PYBIND11_MODULE(pyf3d, module) .value("ERROR", f3d::log::VerboseLevel::ERROR) .value("QUIET", f3d::log::VerboseLevel::QUIET) .export_values(); + + log // + .def_static("set_verbose_level", &f3d::log::setVerboseLevel, py::arg("level"), + py::arg("force_std_err") = false) + .def_static("set_use_coloring", &f3d::log::setUseColoring) + .def_static("print", [](f3d::log::VerboseLevel& level, const std::string& message) + { f3d::log::print(level, message); }); } From 3742e54eb7310a81deefd33affe899243814f094 Mon Sep 17 00:00:00 2001 From: snoyer Date: Wed, 18 Dec 2024 15:34:34 +0400 Subject: [PATCH 02/26] add type aliases --- python/__init__.py.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/__init__.py.in b/python/__init__.py.in index 1cbcd1ac0f..63161bbdb3 100644 --- a/python/__init__.py.in +++ b/python/__init__.py.in @@ -28,6 +28,10 @@ Engine.autoload_plugins() __version__ = "@F3D_VERSION@" +point3_t = tuple[float, float, float] +vector3_t = tuple[float, float, float] + + ################################################################################ # monkey patch `options.update` From 6a0277ebfe14c329860a6886fcd61eab27f78e9f Mon Sep 17 00:00:00 2001 From: snoyer Date: Wed, 18 Dec 2024 15:45:45 +0400 Subject: [PATCH 03/26] format --- python/F3DPythonBindings.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/F3DPythonBindings.cxx b/python/F3DPythonBindings.cxx index 403c394d98..5274ece131 100644 --- a/python/F3DPythonBindings.cxx +++ b/python/F3DPythonBindings.cxx @@ -443,6 +443,7 @@ PYBIND11_MODULE(pyf3d, module) .def_static("set_verbose_level", &f3d::log::setVerboseLevel, py::arg("level"), py::arg("force_std_err") = false) .def_static("set_use_coloring", &f3d::log::setUseColoring) - .def_static("print", [](f3d::log::VerboseLevel& level, const std::string& message) - { f3d::log::print(level, message); }); + .def_static("print", + [](f3d::log::VerboseLevel& level, const std::string& message) + { f3d::log::print(level, message); }); } From f0fb1ecc3b0006ad837719a24442aadfb6cea5f0 Mon Sep 17 00:00:00 2001 From: snoyer Date: Wed, 18 Dec 2024 15:49:22 +0400 Subject: [PATCH 04/26] format again --- python/F3DPythonBindings.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/F3DPythonBindings.cxx b/python/F3DPythonBindings.cxx index 5274ece131..fc79c70914 100644 --- a/python/F3DPythonBindings.cxx +++ b/python/F3DPythonBindings.cxx @@ -445,5 +445,5 @@ PYBIND11_MODULE(pyf3d, module) .def_static("set_use_coloring", &f3d::log::setUseColoring) .def_static("print", [](f3d::log::VerboseLevel& level, const std::string& message) - { f3d::log::print(level, message); }); + { f3d::log::print(level, message); }); } From ddaefd3479779c49a3995fb527c56d04a98572f8 Mon Sep 17 00:00:00 2001 From: snoyer Date: Wed, 18 Dec 2024 20:31:30 +0400 Subject: [PATCH 05/26] remove sketchy type alias --- python/__init__.py.in | 4 ---- 1 file changed, 4 deletions(-) diff --git a/python/__init__.py.in b/python/__init__.py.in index 63161bbdb3..1cbcd1ac0f 100644 --- a/python/__init__.py.in +++ b/python/__init__.py.in @@ -28,10 +28,6 @@ Engine.autoload_plugins() __version__ = "@F3D_VERSION@" -point3_t = tuple[float, float, float] -vector3_t = tuple[float, float, float] - - ################################################################################ # monkey patch `options.update` From e19eec997fab2dd586c4f21eb8f2c621b6f74872 Mon Sep 17 00:00:00 2001 From: snoyer Date: Wed, 18 Dec 2024 20:35:22 +0400 Subject: [PATCH 06/26] add stubs generation script --- python/generate_stubs.py | 85 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 python/generate_stubs.py diff --git a/python/generate_stubs.py b/python/generate_stubs.py new file mode 100644 index 0000000000..f0463603ad --- /dev/null +++ b/python/generate_stubs.py @@ -0,0 +1,85 @@ +import re +import subprocess +import sys +from argparse import ArgumentParser +from pathlib import Path +from tempfile import TemporaryDirectory, gettempdir + + +def main(): + argparser = ArgumentParser() + argparser.add_argument( + "-o", + "--into", + help="output directory for the post-processed stubs", + default=gettempdir(), + ) + args = argparser.parse_args() + + with TemporaryDirectory() as tmp_dir: + run_pybind11_stubgen(tmp_dir) + postprocess_generated_stubs(tmp_dir, args.into) + + +def run_pybind11_stubgen(out_dir: str): + stubgen_cmd = ( + # use current python interpreter to run stubs generation for the `f3d` module + *(sys.executable, "-m", "pybind11_stubgen", "f3d"), + # fix enum for default values in `Image.save()` and `Image.save_buffer()` + *("--enum-class-locations", "SaveFormat:Image"), + # ignore `f3d.vector3_t` and `f3d.point3_t` as we dont actually map them + # but let them auto-convert from and to `tuple[float, float, float]` + # (all occurrences will be postprocessed later) + *("--ignore-unresolved-names", r"f3d\.(vector3_t|point3_t)"), + # output in temporary directory as we're going to post process + *("--output-dir", out_dir), + ) + subprocess.check_call(stubgen_cmd) + + +def postprocess_generated_stubs(stubs_dir: str, into: str): + replacements = [ + ( + # change `point3_t` and `vector3_t` parameter annotations and return types + # to `tuple[float, float, float]` + r"((:|->)\s*)f3d\.(vector3_t|point3_t)", + r"\1tuple[float, float, float]", + ), + ( + # remove `point3_t` and `vector3_t` being imported `as tuple` + r"from builtins import tuple as (vector3_t|point3_t)[\n\r]+", + r"", + ), + ( + # add missing template parameter to raw `os.PathLike` (`os.PathLike[str | bytes]`) + r"(PathLike)(?!\[)", + r"\1[str | bytes]", + ), + ( + # remove `_pybind11_conduit_v1_` static methods + r"^\s+@staticmethod[\n\r]+\s+def _pybind11_conduit_v1_\(\*args, \*\*kwargs\):[\n\r]+\s+\.\.\.[\n\r]", + "", + ), + ] + + tmp_dir = Path(stubs_dir) + out_dir = Path(into) + + for tmp_fn in tmp_dir.glob("**/*.pyi"): + rel_fn = tmp_fn.relative_to(tmp_dir) + out_fn = out_dir / rel_fn + out_fn.parent.mkdir(exist_ok=True, parents=True) + + src = tmp_fn.read_text() + for pattern, repl in replacements: + src = re.sub(pattern, repl, src, flags=re.MULTILINE) + out_fn.write_text(src) + + try: + subprocess.call(["diff", "-u", str(tmp_fn), str(out_fn)]) + except IOError: + pass # no `diff` executable + + +if __name__ == "__main__": + main() From 4154d6b0145a19d4188733b6fb74d47bd97c117a Mon Sep 17 00:00:00 2001 From: snoyer Date: Thu, 19 Dec 2024 11:14:24 +0400 Subject: [PATCH 07/26] typing, private methods --- python/__init__.py.in | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/python/__init__.py.in b/python/__init__.py.in index 1cbcd1ac0f..b7d9e3282e 100644 --- a/python/__init__.py.in +++ b/python/__init__.py.in @@ -2,10 +2,11 @@ # Refer to python/__init__.py.in source file import os -import sys import re +import sys import warnings from pathlib import Path +from typing import Any, Iterable, Mapping, Union F3D_ABSOLUTE_DLLS = [ # @F3D_ABSOLUTE_DLLS_FIXUP@ @@ -32,7 +33,9 @@ __version__ = "@F3D_VERSION@" # monkey patch `options.update` -def f3d_options_update(self, arg): +def _f3d_options_update( + self, arg: Union[Mapping[str, Any], Iterable[tuple[str, Any]]] +) -> None: try: for k, v in arg.items(): self[k] = v @@ -47,17 +50,17 @@ def f3d_options_update(self, arg): except AttributeError: pass - raise ValueError(f"cannot update {self} from {args}") + raise ValueError(f"cannot update {self} from {arg}") -Options.update = f3d_options_update +Options.update = _f3d_options_update ################################################################################ # add deprecated warnings -def deprecated_decorator(f, reason): +def _deprecated_decorator(f, reason): def g(*args, **kwargs): warnings.warn(reason, DeprecationWarning, 2) return f(*args, **kwargs) @@ -65,7 +68,7 @@ def deprecated_decorator(f, reason): return g -def add_deprecation_warnings(): +def _add_deprecation_warnings(): for f3d_class in ( Camera, Scene, @@ -73,6 +76,7 @@ def add_deprecation_warnings(): Interactor, Engine, Window, + Image, ): for name, member in f3d_class.__dict__.items(): if callable(member) and member.__doc__: @@ -80,7 +84,7 @@ def add_deprecation_warnings(): if m: reason = m.group(1) or "" msg = f"{f3d_class.__qualname__}.{name} is deprecated{reason}" - setattr(f3d_class, name, deprecated_decorator(member, msg)) + setattr(f3d_class, name, _deprecated_decorator(member, msg)) -add_deprecation_warnings() +_add_deprecation_warnings() From 8f7600738b5b74145e5bf628dcc8b207af13c0c2 Mon Sep 17 00:00:00 2001 From: snoyer Date: Thu, 19 Dec 2024 11:14:50 +0400 Subject: [PATCH 08/26] drop python 3.8 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d1e2a78b60..59440a84f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "scikit_build_core.build" [project] name = "f3d" -requires-python = ">=3.8" +requires-python = ">=3.9" dynamic = ["version"] description = "F3D, a fast and minimalist 3D viewer" readme = "README.md" From 80b87d3ee9bacd538d921f844c8a8d6ee4e48ea2 Mon Sep 17 00:00:00 2001 From: snoyer Date: Thu, 19 Dec 2024 11:15:40 +0400 Subject: [PATCH 09/26] improve stubs generation --- python/generate_stubs.py | 77 +++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 33 deletions(-) diff --git a/python/generate_stubs.py b/python/generate_stubs.py index f0463603ad..71891b75a4 100644 --- a/python/generate_stubs.py +++ b/python/generate_stubs.py @@ -2,8 +2,11 @@ import subprocess import sys from argparse import ArgumentParser +from contextlib import contextmanager +from difflib import unified_diff from pathlib import Path -from tempfile import TemporaryDirectory, gettempdir +from tempfile import gettempdir +from typing import Iterable def main(): @@ -11,33 +14,35 @@ def main(): argparser.add_argument( "-o", "--into", - help="output directory for the post-processed stubs", - default=gettempdir(), + help="output directory for the post-processed stubs (default: %(default)s)", + default=f"{gettempdir()}/stubs", ) args = argparser.parse_args() - with TemporaryDirectory() as tmp_dir: - run_pybind11_stubgen(tmp_dir) - postprocess_generated_stubs(tmp_dir, args.into) + stubs = run_pybind11_stubgen(Path(args.into)) + if diff := postprocess_generated_stubs(stubs): + print("\n".join(diff)) -def run_pybind11_stubgen(out_dir: str): +def run_pybind11_stubgen(out_dir: Path, module: str = "f3d"): stubgen_cmd = ( # use current python interpreter to run stubs generation for the `f3d` module - *(sys.executable, "-m", "pybind11_stubgen", "f3d"), + *(sys.executable, "-m", "pybind11_stubgen", module), # fix enum for default values in `Image.save()` and `Image.save_buffer()` *("--enum-class-locations", "SaveFormat:Image"), # ignore `f3d.vector3_t` and `f3d.point3_t` as we dont actually map them # but let them auto-convert from and to `tuple[float, float, float]` # (all occurrences will be postprocessed later) *("--ignore-unresolved-names", r"f3d\.(vector3_t|point3_t)"), - # output in temporary directory as we're going to post process + # output directory so we can retrieve and post process *("--output-dir", out_dir), ) - subprocess.check_call(stubgen_cmd) + with retrieve_changed_files(out_dir, f"{module}/**/*.pyi") as changed_files: + subprocess.check_call(stubgen_cmd) + return changed_files -def postprocess_generated_stubs(stubs_dir: str, into: str): +def postprocess_generated_stubs(filenames: Iterable[Path]): replacements = [ ( # change `point3_t` and `vector3_t` parameter annotations and return types @@ -46,39 +51,45 @@ def postprocess_generated_stubs(stubs_dir: str, into: str): r"\1tuple[float, float, float]", ), ( - # remove `point3_t` and `vector3_t` being imported `as tuple` - r"from builtins import tuple as (vector3_t|point3_t)[\n\r]+", - r"", - ), - ( - # add missing template parameter to raw `os.PathLike` (`os.PathLike[str | bytes]`) + # add missing template parameter to raw `os.PathLike` (`os.PathLike[str]`) r"(PathLike)(?!\[)", - r"\1[str | bytes]", + r"\1[str]", ), ( # remove `_pybind11_conduit_v1_` static methods - r"^\s+@staticmethod[\n\r]+\s+def _pybind11_conduit_v1_\(\*args, \*\*kwargs\):[\n\r]+\s+\.\.\.[\n\r]", + r"^\s+@staticmethod\s+def _pybind11_conduit_v1_\(\*args, *\*\*kwargs\):\s*\.\.\.[\n\r]", "", ), ] - tmp_dir = Path(stubs_dir) - out_dir = Path(into) + diff: list[str] = [] - for tmp_fn in tmp_dir.glob("**/*.pyi"): - rel_fn = tmp_fn.relative_to(tmp_dir) - out_fn = out_dir / rel_fn - out_fn.parent.mkdir(exist_ok=True, parents=True) - - src = tmp_fn.read_text() + for filename in filenames: + processed = original = filename.read_text() for pattern, repl in replacements: - src = re.sub(pattern, repl, src, flags=re.MULTILINE) - out_fn.write_text(src) + processed = re.sub(pattern, repl, processed, flags=re.MULTILINE) + filename.write_text(processed) + + diff += unified_diff( + original.splitlines(), + processed.splitlines(), + str(filename), + str(filename), + n=1, + lineterm="", + ) - try: - subprocess.call(["diff", "-u", str(tmp_fn), str(out_fn)]) - except IOError: - pass # no `diff` executable + return diff + + +@contextmanager +def retrieve_changed_files(directory: Path, files_glob: str): + mtimes = {f: f.stat().st_mtime for f in directory.glob(files_glob)} + changed_files: list[Path] = [] + yield changed_files + changed_files += ( + f for f in directory.glob(files_glob) if f.stat().st_mtime > mtimes.get(f, 0) + ) if __name__ == "__main__": From 4cea63ce44fca05fe4fbd510abc3123ea381b561 Mon Sep 17 00:00:00 2001 From: Michael Migliore Date: Sat, 21 Dec 2024 14:30:04 +0100 Subject: [PATCH 10/26] Try packaging --- .github/actions/generic-ci/action.yml | 2 ++ doc/dev/BUILD.md | 1 + pyproject.toml | 1 + python/CMakeLists.txt | 15 +++++++++++++++ 4 files changed, 19 insertions(+) diff --git a/.github/actions/generic-ci/action.yml b/.github/actions/generic-ci/action.yml index 2423088e23..4a2dafa8c4 100644 --- a/.github/actions/generic-ci/action.yml +++ b/.github/actions/generic-ci/action.yml @@ -102,6 +102,7 @@ runs: run: | python -m pip install --upgrade pip python -m pip install pytest==8.0.0 + python -m pip install pybind11_stubgen - name: Setup Directories shell: bash @@ -151,6 +152,7 @@ runs: -DCMAKE_PREFIX_PATH:PATH=$(pwd)/../dependencies/install/ -DF3D_BINDINGS_JAVA=${{ (runner.os != 'macOS' || inputs.cpu == 'arm64') && inputs.optional_deps_label == 'optional-deps' && 'ON' || 'OFF' }} -DF3D_BINDINGS_PYTHON=${{ inputs.optional_deps_label == 'optional-deps' && 'ON' || 'OFF' }} + -DF3D_BINDINGS_PYTHON_GENERATE_STUBS=${{ inputs.optional_deps_label == 'optional-deps' && 'ON' || 'OFF' }} -DF3D_EXCLUDE_DEPRECATED=${{ inputs.exclude_deprecated_label == 'exclude-deprecated' && 'ON' || 'OFF' }} -DF3D_LINUX_GENERATE_MAN=ON -DF3D_LINUX_INSTALL_DEFAULT_CONFIGURATION_FILE_IN_PREFIX=ON diff --git a/doc/dev/BUILD.md b/doc/dev/BUILD.md index cd008ab3f2..137391c096 100644 --- a/doc/dev/BUILD.md +++ b/doc/dev/BUILD.md @@ -51,6 +51,7 @@ Some modules, plugins and language bindings depending on external libraries can * `F3D_PLUGIN_BUILD_USD`: Support for USD file format. Requires `OpenUSD`. Disabled by default. * `F3D_PLUGIN_BUILD_VDB`: Support for VDB file format. Requires that VTK has been built with `IOOpenVDB` module (and `OpenVDB`). Disabled by default. * `F3D_BINDINGS_PYTHON`: Generate python bindings (requires `Python` and `pybind11`). Disabled by default. +* `F3D_BINDINGS_PYTHON_GENERATE_STUBS`: Generate python stubs (requires `Python` and `pybind11_stubgen`). Disabled by default. * `F3D_BINDINGS_JAVA`: Generate java bindings (requires `Java` and `JNI`). Disabled by default. Some dependencies are provided internally, eg: ImGui, dmon and others. Use `F3D_USE_EXTERNAL_*` to use an external version of these libraries. diff --git a/pyproject.toml b/pyproject.toml index 59440a84f0..f2baffbacb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,6 +58,7 @@ fallback_version = "2.5.1" CMAKE_OSX_DEPLOYMENT_TARGET = "10.15" BUILD_SHARED_LIBS = "ON" F3D_BINDINGS_PYTHON = "ON" +F3D_BINDINGS_PYTHON_GENERATE_STUBS = "ON" F3D_PLUGINS_STATIC_BUILD = "ON" F3D_BUILD_APPLICATION = "OFF" F3D_WINDOWS_BUILD_SHELL_THUMBNAILS_EXTENSION = "OFF" diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 96e31a07c7..4973bd538a 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.21) project(pyf3d) +option(F3D_BINDINGS_PYTHON_GENERATE_STUBS "Generate Python stubs" OFF) + list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_LIST_DIR}/cmake") include(GNUInstallDirs) include(f3dPython) @@ -83,6 +85,15 @@ endif() configure_file("${CMAKE_CURRENT_SOURCE_DIR}/__init__.py.in" "${CMAKE_CURRENT_BINARY_DIR}/__init__.py-install" @ONLY) +# Stubs +if (F3D_BINDINGS_PYTHON_GENERATE_STUBS) + add_custom_command( + TARGET pyf3d + POST_BUILD + COMMAND /home/michael/.venv/bin/python ${CMAKE_CURRENT_SOURCE_DIR}/generate_stubs.py --into=${CMAKE_BINARY_DIR} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +endif() + # testing if(BUILD_TESTING) add_subdirectory(testing) @@ -93,3 +104,7 @@ install(TARGETS pyf3d LIBRARY DESTINATION ${f3d_python_install_path} COMPONENT python) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/__init__.py-install" RENAME "__init__.py" DESTINATION ${f3d_python_install_path} COMPONENT python) +if (F3D_BINDINGS_PYTHON_GENERATE_STUBS) + install(FILES "${f3d_module_dir}/__init__.pyi" "${f3d_module_dir}/pyf3d.pyi" + DESTINATION ${f3d_python_install_path} COMPONENT python) +endif() From 37ae5fd1fb527d71701de0ed3ac1f09d12db7adb Mon Sep 17 00:00:00 2001 From: Michael Migliore Date: Sat, 21 Dec 2024 14:35:59 +0100 Subject: [PATCH 11/26] oups --- python/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 4973bd538a..951d983b67 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -90,7 +90,7 @@ if (F3D_BINDINGS_PYTHON_GENERATE_STUBS) add_custom_command( TARGET pyf3d POST_BUILD - COMMAND /home/michael/.venv/bin/python ${CMAKE_CURRENT_SOURCE_DIR}/generate_stubs.py --into=${CMAKE_BINARY_DIR} + COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/generate_stubs.py --into=${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) endif() From bfc5640f77a80517de38d0c3641bea9d9e18070a Mon Sep 17 00:00:00 2001 From: Michael Migliore Date: Sat, 21 Dec 2024 14:53:58 +0100 Subject: [PATCH 12/26] fix windows --- python/CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 951d983b67..3ec89ef5d7 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -27,7 +27,8 @@ set(f3d_python_package_name "f3d") set(f3d_python_package_suffix "python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages") get_property(F3D_MULTI_CONFIG_GENERATOR GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) -set(f3d_module_dir "${CMAKE_BINARY_DIR}$<${F3D_MULTI_CONFIG_GENERATOR}:/$>/${f3d_python_package_name}") +set(f3d_binary_dir "${CMAKE_BINARY_DIR}$<${F3D_MULTI_CONFIG_GENERATOR}:/$>") +set(f3d_module_dir "${f3d_binary_dir}/${f3d_python_package_name}") set_target_properties(pyf3d PROPERTIES CXX_STANDARD 17 @@ -90,8 +91,8 @@ if (F3D_BINDINGS_PYTHON_GENERATE_STUBS) add_custom_command( TARGET pyf3d POST_BUILD - COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/generate_stubs.py --into=${CMAKE_BINARY_DIR} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) + COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/generate_stubs.py --into=${f3d_binary_dir} + WORKING_DIRECTORY ${f3d_binary_dir}) endif() # testing From 20d0e4721de711c8e5ff12569e34c177d1d716d7 Mon Sep 17 00:00:00 2001 From: Michael Migliore Date: Mon, 23 Dec 2024 16:07:25 +0100 Subject: [PATCH 13/26] try --- .github/actions/python-ci/action.yml | 1 + python/CMakeLists.txt | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/actions/python-ci/action.yml b/.github/actions/python-ci/action.yml index 22da57353a..f5e79b74e8 100644 --- a/.github/actions/python-ci/action.yml +++ b/.github/actions/python-ci/action.yml @@ -53,6 +53,7 @@ runs: run: | python -m pip install --upgrade pip python -m pip install pytest==8.0.0 + python -m pip install pybind11_stubgen - name: Set PATH windows if: runner.os == 'Windows' diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 3ec89ef5d7..45c110b8cd 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -59,7 +59,11 @@ if(WIN32) if(PROJECT_IS_TOP_LEVEL) f3d_python_windows_dll_fixup(PATHS "$" OUTPUT F3D_ABSOLUTE_DLLS_FIXUP) else() - f3d_python_windows_dll_fixup(PATHS "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" "$" OUTPUT F3D_ABSOLUTE_DLLS_FIXUP) + set(f3d_win_dll_paths "$") + if(BUILD_SHARED_LIBS) + list(APPEND f3d_win_dll_paths "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") + endif() + f3d_python_windows_dll_fixup(PATHS "${f3d_win_dll_paths}" OUTPUT F3D_ABSOLUTE_DLLS_FIXUP) endif() endif() From bd14e2255742db1b682bf148353d809b7c63033d Mon Sep 17 00:00:00 2001 From: Michael Migliore Date: Mon, 23 Dec 2024 16:11:14 +0100 Subject: [PATCH 14/26] dep --- pyproject.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index f2baffbacb..4cf325f9a2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,6 +30,10 @@ classifiers = [ "Topic :: Scientific/Engineering :: Visualization", ] +dependencies = [ + "pybind11_stubgen" +] + [project.urls] Homepage = "https://f3d.app" Repository = "https://github.com/f3d-app/f3d.git" From c2e75c1c405c93f9f9b1e529928663f6eac438a9 Mon Sep 17 00:00:00 2001 From: Michael Migliore Date: Tue, 31 Dec 2024 09:52:00 +0100 Subject: [PATCH 15/26] moved --- python/F3DPythonBindings.cxx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/python/F3DPythonBindings.cxx b/python/F3DPythonBindings.cxx index fc79c70914..3ff0fe1eb8 100644 --- a/python/F3DPythonBindings.cxx +++ b/python/F3DPythonBindings.cxx @@ -294,6 +294,16 @@ PYBIND11_MODULE(pyf3d, module) .def("load_animation_time", &f3d::scene::loadAnimationTime) .def("animation_time_range", &f3d::scene::animationTimeRange); + // f3d::camera_state_t + py::class_(module, "CameraState") + .def(py::init<>()) + .def(py::init()) + .def_readwrite("position", &f3d::camera_state_t::position) + .def_readwrite("focal_point", &f3d::camera_state_t::focalPoint) + .def_readwrite("view_up", &f3d::camera_state_t::viewUp) + .def_readwrite("view_angle", &f3d::camera_state_t::viewAngle); + // f3d::camera py::class_> camera(module, "Camera"); camera // @@ -320,14 +330,6 @@ PYBIND11_MODULE(pyf3d, module) .def("reset_to_default", &f3d::camera::resetToDefault) .def("reset_to_bounds", &f3d::camera::resetToBounds, py::arg("zoom_factor") = 0.9); - py::class_(module, "CameraState") - .def(py::init<>()) - .def(py::init()) - .def_readwrite("position", &f3d::camera_state_t::position) - .def_readwrite("focal_point", &f3d::camera_state_t::focalPoint) - .def_readwrite("view_up", &f3d::camera_state_t::viewUp) - .def_readwrite("view_angle", &f3d::camera_state_t::viewAngle); // f3d::window py::class_> window(module, "Window"); From 95f4f6fb7fe50175a2fe0d54b0affe727d4cceb9 Mon Sep 17 00:00:00 2001 From: Michael Migliore Date: Tue, 31 Dec 2024 10:20:37 +0100 Subject: [PATCH 16/26] try --- pyproject.toml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4cf325f9a2..862c6e17e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["scikit-build-core", "setuptools-scm>=8.0"] +requires = ["scikit-build-core", "setuptools-scm>=8.0", "pybind11_stubgen"] build-backend = "scikit_build_core.build" [project] @@ -30,10 +30,6 @@ classifiers = [ "Topic :: Scientific/Engineering :: Visualization", ] -dependencies = [ - "pybind11_stubgen" -] - [project.urls] Homepage = "https://f3d.app" Repository = "https://github.com/f3d-app/f3d.git" From f1fab2f2c821c57ca5b8e9c90d52ee30e0160744 Mon Sep 17 00:00:00 2001 From: Michael Migliore Date: Wed, 1 Jan 2025 21:52:07 +0100 Subject: [PATCH 17/26] try --- .github/actions/python-ci/action.yml | 1 - python/CMakeLists.txt | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/actions/python-ci/action.yml b/.github/actions/python-ci/action.yml index f5e79b74e8..22da57353a 100644 --- a/.github/actions/python-ci/action.yml +++ b/.github/actions/python-ci/action.yml @@ -53,7 +53,6 @@ runs: run: | python -m pip install --upgrade pip python -m pip install pytest==8.0.0 - python -m pip install pybind11_stubgen - name: Set PATH windows if: runner.os == 'Windows' diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 45c110b8cd..95583ea00c 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -60,9 +60,9 @@ if(WIN32) f3d_python_windows_dll_fixup(PATHS "$" OUTPUT F3D_ABSOLUTE_DLLS_FIXUP) else() set(f3d_win_dll_paths "$") - if(BUILD_SHARED_LIBS) + #if(BUILD_SHARED_LIBS) list(APPEND f3d_win_dll_paths "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") - endif() + #endif() f3d_python_windows_dll_fixup(PATHS "${f3d_win_dll_paths}" OUTPUT F3D_ABSOLUTE_DLLS_FIXUP) endif() endif() From e0e948aa2c6cb8b22eb23bc0eba4fc78f877f1f3 Mon Sep 17 00:00:00 2001 From: Michael Migliore Date: Wed, 1 Jan 2025 22:00:47 +0100 Subject: [PATCH 18/26] restore --- python/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 95583ea00c..45c110b8cd 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -60,9 +60,9 @@ if(WIN32) f3d_python_windows_dll_fixup(PATHS "$" OUTPUT F3D_ABSOLUTE_DLLS_FIXUP) else() set(f3d_win_dll_paths "$") - #if(BUILD_SHARED_LIBS) + if(BUILD_SHARED_LIBS) list(APPEND f3d_win_dll_paths "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") - #endif() + endif() f3d_python_windows_dll_fixup(PATHS "${f3d_win_dll_paths}" OUTPUT F3D_ABSOLUTE_DLLS_FIXUP) endif() endif() From 93e3d0e5346fbee462dd2bef5512621f6cade9c5 Mon Sep 17 00:00:00 2001 From: Michael Migliore Date: Wed, 1 Jan 2025 22:46:27 +0100 Subject: [PATCH 19/26] debug --- .github/actions/generic-ci/action.yml | 2 +- python/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/generic-ci/action.yml b/.github/actions/generic-ci/action.yml index 4a2dafa8c4..0a2433f675 100644 --- a/.github/actions/generic-ci/action.yml +++ b/.github/actions/generic-ci/action.yml @@ -144,7 +144,7 @@ runs: --warn-uninitialized -DBUILD_SHARED_LIBS=${{ inputs.static_label == 'static' && 'OFF' || 'ON' }} -DBUILD_TESTING=ON - -DCMAKE_BUILD_TYPE=Release + -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=../install -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON -DCMAKE_POLICY_DEFAULT_CMP0091=NEW diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 45c110b8cd..26bff2bb18 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -8,7 +8,7 @@ list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_LIST_DIR}/cmake") include(GNUInstallDirs) include(f3dPython) -find_package(Python 3.8 COMPONENTS Interpreter Development) +find_package(Python 3.9 COMPONENTS Interpreter Development) find_package(pybind11 2.2 REQUIRED) pybind11_add_module(pyf3d MODULE F3DPythonBindings.cxx) From 83f71a20b88bcb372240525e919fbe3507317c44 Mon Sep 17 00:00:00 2001 From: Michael Migliore Date: Thu, 2 Jan 2025 16:47:21 +0100 Subject: [PATCH 20/26] disable stubs --- .github/actions/generic-ci/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/generic-ci/action.yml b/.github/actions/generic-ci/action.yml index 0a2433f675..9bbb380697 100644 --- a/.github/actions/generic-ci/action.yml +++ b/.github/actions/generic-ci/action.yml @@ -144,7 +144,7 @@ runs: --warn-uninitialized -DBUILD_SHARED_LIBS=${{ inputs.static_label == 'static' && 'OFF' || 'ON' }} -DBUILD_TESTING=ON - -DCMAKE_BUILD_TYPE=Debug + -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=../install -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON -DCMAKE_POLICY_DEFAULT_CMP0091=NEW @@ -152,7 +152,7 @@ runs: -DCMAKE_PREFIX_PATH:PATH=$(pwd)/../dependencies/install/ -DF3D_BINDINGS_JAVA=${{ (runner.os != 'macOS' || inputs.cpu == 'arm64') && inputs.optional_deps_label == 'optional-deps' && 'ON' || 'OFF' }} -DF3D_BINDINGS_PYTHON=${{ inputs.optional_deps_label == 'optional-deps' && 'ON' || 'OFF' }} - -DF3D_BINDINGS_PYTHON_GENERATE_STUBS=${{ inputs.optional_deps_label == 'optional-deps' && 'ON' || 'OFF' }} + -DF3D_BINDINGS_PYTHON_GENERATE_STUBS=OFF -DF3D_EXCLUDE_DEPRECATED=${{ inputs.exclude_deprecated_label == 'exclude-deprecated' && 'ON' || 'OFF' }} -DF3D_LINUX_GENERATE_MAN=ON -DF3D_LINUX_INSTALL_DEFAULT_CONFIGURATION_FILE_IN_PREFIX=ON From 328ec4c042c9fad07391db242bf88ab86b50665d Mon Sep 17 00:00:00 2001 From: Michael Migliore Date: Thu, 2 Jan 2025 17:27:14 +0100 Subject: [PATCH 21/26] try dll path --- .github/actions/generic-ci/action.yml | 2 +- python/CMakeLists.txt | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/actions/generic-ci/action.yml b/.github/actions/generic-ci/action.yml index 9bbb380697..98be5a404a 100644 --- a/.github/actions/generic-ci/action.yml +++ b/.github/actions/generic-ci/action.yml @@ -232,7 +232,7 @@ runs: - name: Test shell: bash working-directory: ${{github.workspace}}/build - run: ctest -E "${{ env.F3D_CTEST_EXCEPTIONS }}" -C Release -j 2 --output-on-failure || ctest -E "${{ env.F3D_CTEST_EXCEPTIONS }}" -C Release -j 1 --rerun-failed -VV + run: ctest -R pytest -E "${{ env.F3D_CTEST_EXCEPTIONS }}" -C Release -j 2 --output-on-failure || ctest -E "${{ env.F3D_CTEST_EXCEPTIONS }}" -C Release -j 1 --rerun-failed -VV - name: Upload Tests Artifact if: failure() diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 26bff2bb18..305b26d982 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -59,11 +59,7 @@ if(WIN32) if(PROJECT_IS_TOP_LEVEL) f3d_python_windows_dll_fixup(PATHS "$" OUTPUT F3D_ABSOLUTE_DLLS_FIXUP) else() - set(f3d_win_dll_paths "$") - if(BUILD_SHARED_LIBS) - list(APPEND f3d_win_dll_paths "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") - endif() - f3d_python_windows_dll_fixup(PATHS "${f3d_win_dll_paths}" OUTPUT F3D_ABSOLUTE_DLLS_FIXUP) + f3d_python_windows_dll_fixup(PATHS "$" "$" OUTPUT F3D_ABSOLUTE_DLLS_FIXUP) endif() endif() From e4c60fe575c9db3a0b176e071e77c8e4de71f596 Mon Sep 17 00:00:00 2001 From: Michael Migliore Date: Thu, 2 Jan 2025 17:39:01 +0100 Subject: [PATCH 22/26] ... --- .github/actions/generic-ci/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/generic-ci/action.yml b/.github/actions/generic-ci/action.yml index 98be5a404a..ce0bb32a0b 100644 --- a/.github/actions/generic-ci/action.yml +++ b/.github/actions/generic-ci/action.yml @@ -232,7 +232,7 @@ runs: - name: Test shell: bash working-directory: ${{github.workspace}}/build - run: ctest -R pytest -E "${{ env.F3D_CTEST_EXCEPTIONS }}" -C Release -j 2 --output-on-failure || ctest -E "${{ env.F3D_CTEST_EXCEPTIONS }}" -C Release -j 1 --rerun-failed -VV + run: ctest -R pyf3d -E "${{ env.F3D_CTEST_EXCEPTIONS }}" -C Release -j 2 --output-on-failure || ctest -E "${{ env.F3D_CTEST_EXCEPTIONS }}" -C Release -j 1 --rerun-failed -VV - name: Upload Tests Artifact if: failure() From ca1a959cfc7aa3877a6a7580482e9d6730b7ae5c Mon Sep 17 00:00:00 2001 From: Michael Migliore Date: Thu, 2 Jan 2025 17:50:00 +0100 Subject: [PATCH 23/26] try --- python/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 305b26d982..9b5d324413 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -59,7 +59,7 @@ if(WIN32) if(PROJECT_IS_TOP_LEVEL) f3d_python_windows_dll_fixup(PATHS "$" OUTPUT F3D_ABSOLUTE_DLLS_FIXUP) else() - f3d_python_windows_dll_fixup(PATHS "$" "$" OUTPUT F3D_ABSOLUTE_DLLS_FIXUP) + f3d_python_windows_dll_fixup(PATHS "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" "$" OUTPUT F3D_ABSOLUTE_DLLS_FIXUP) endif() endif() From 1731ae33cfae9742c4cdf69fb39103169914bd2d Mon Sep 17 00:00:00 2001 From: Michael Migliore Date: Thu, 2 Jan 2025 18:15:13 +0100 Subject: [PATCH 24/26] fix --- .github/actions/generic-ci/action.yml | 6 ++++++ python/CMakeLists.txt | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/actions/generic-ci/action.yml b/.github/actions/generic-ci/action.yml index ce0bb32a0b..386744333b 100644 --- a/.github/actions/generic-ci/action.yml +++ b/.github/actions/generic-ci/action.yml @@ -200,6 +200,12 @@ runs: with: path: ${{github.workspace}}\build\bin_Release + - name: Install Mesa Windows Python + if: runner.os == 'Windows' + uses: f3d-app/install-mesa-windows-action@v1 + with: + path: ${{github.workspace}}\build\Release\f3d + # A EGL test is crashing in the CI but not locally - name: Set CI test exception for Linux EGL if: diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 9b5d324413..305b26d982 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -59,7 +59,7 @@ if(WIN32) if(PROJECT_IS_TOP_LEVEL) f3d_python_windows_dll_fixup(PATHS "$" OUTPUT F3D_ABSOLUTE_DLLS_FIXUP) else() - f3d_python_windows_dll_fixup(PATHS "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" "$" OUTPUT F3D_ABSOLUTE_DLLS_FIXUP) + f3d_python_windows_dll_fixup(PATHS "$" "$" OUTPUT F3D_ABSOLUTE_DLLS_FIXUP) endif() endif() From b2e479e71aee62caa0daed7a4fea4c3a8638293c Mon Sep 17 00:00:00 2001 From: Michael Migliore Date: Thu, 2 Jan 2025 18:33:32 +0100 Subject: [PATCH 25/26] should work now --- .github/actions/generic-ci/action.yml | 4 ++-- python/CMakeLists.txt | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/actions/generic-ci/action.yml b/.github/actions/generic-ci/action.yml index 386744333b..9aa3483977 100644 --- a/.github/actions/generic-ci/action.yml +++ b/.github/actions/generic-ci/action.yml @@ -152,7 +152,7 @@ runs: -DCMAKE_PREFIX_PATH:PATH=$(pwd)/../dependencies/install/ -DF3D_BINDINGS_JAVA=${{ (runner.os != 'macOS' || inputs.cpu == 'arm64') && inputs.optional_deps_label == 'optional-deps' && 'ON' || 'OFF' }} -DF3D_BINDINGS_PYTHON=${{ inputs.optional_deps_label == 'optional-deps' && 'ON' || 'OFF' }} - -DF3D_BINDINGS_PYTHON_GENERATE_STUBS=OFF + -DF3D_BINDINGS_PYTHON_GENERATE_STUBS=${{ inputs.optional_deps_label == 'optional-deps' && 'ON' || 'OFF' }} -DF3D_EXCLUDE_DEPRECATED=${{ inputs.exclude_deprecated_label == 'exclude-deprecated' && 'ON' || 'OFF' }} -DF3D_LINUX_GENERATE_MAN=ON -DF3D_LINUX_INSTALL_DEFAULT_CONFIGURATION_FILE_IN_PREFIX=ON @@ -238,7 +238,7 @@ runs: - name: Test shell: bash working-directory: ${{github.workspace}}/build - run: ctest -R pyf3d -E "${{ env.F3D_CTEST_EXCEPTIONS }}" -C Release -j 2 --output-on-failure || ctest -E "${{ env.F3D_CTEST_EXCEPTIONS }}" -C Release -j 1 --rerun-failed -VV + run: ctest -E "${{ env.F3D_CTEST_EXCEPTIONS }}" -C Release -j 2 --output-on-failure || ctest -E "${{ env.F3D_CTEST_EXCEPTIONS }}" -C Release -j 1 --rerun-failed -VV - name: Upload Tests Artifact if: failure() diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 305b26d982..45b43eb094 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -59,7 +59,11 @@ if(WIN32) if(PROJECT_IS_TOP_LEVEL) f3d_python_windows_dll_fixup(PATHS "$" OUTPUT F3D_ABSOLUTE_DLLS_FIXUP) else() - f3d_python_windows_dll_fixup(PATHS "$" "$" OUTPUT F3D_ABSOLUTE_DLLS_FIXUP) + set(f3d_win_dll_paths "$") + if(BUILD_SHARED_LIBS) + list(APPEND f3d_win_dll_paths "$") + endif() + f3d_python_windows_dll_fixup(PATHS "${f3d_win_dll_paths}" OUTPUT F3D_ABSOLUTE_DLLS_FIXUP) endif() endif() From 407425896e61de726a682978500de0ac9b645975 Mon Sep 17 00:00:00 2001 From: Michael Migliore Date: Fri, 3 Jan 2025 09:41:09 +0100 Subject: [PATCH 26/26] stubs --- doc/libf3d/LANGUAGE_BINDINGS.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/libf3d/LANGUAGE_BINDINGS.md b/doc/libf3d/LANGUAGE_BINDINGS.md index d88b99b086..58678a241d 100644 --- a/doc/libf3d/LANGUAGE_BINDINGS.md +++ b/doc/libf3d/LANGUAGE_BINDINGS.md @@ -23,6 +23,11 @@ eng.interactor.start() You can see more examples using python bindings in the dedicated example folder [here](https://github.com/f3d-app/f3d/tree/master/examples/libf3d/python). +### Stubs + +It's also possible to generate Python stubs automatically by enabling the CMake option `F3D_BINDINGS_PYTHON_GENERATE_STUBS`. +Python stubs are `.pyi` files defining the public interface, allowing IDEs to auto-complete and do static analysis. + ## Java (experimental) If the Java bindings have been generated using the `F3D_BINDINGS_JAVA` CMake option, the libf3d can be used directly from Java.