From c78cc3fd13e998c00ed117d511834e18742dec17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 8 Feb 2023 01:03:41 +0100 Subject: [PATCH] python: expose the BUILD_DEPRECATED constants as well. Ugh, I thought I would never need them but then there are plugin features depending on this and it's A MESS. --- doc/python/conf.py | 8 ++++++-- doc/python/corrade.rst | 1 + doc/python/magnum.rst | 1 + doc/python/pages/changelog.rst | 4 ++++ src/python/corrade/corrade.cpp | 7 +++++++ src/python/magnum/magnum.cpp | 7 +++++++ 6 files changed, 26 insertions(+), 2 deletions(-) diff --git a/doc/python/conf.py b/doc/python/conf.py index a73f538..a862b0d 100644 --- a/doc/python/conf.py +++ b/doc/python/conf.py @@ -24,13 +24,14 @@ import magnum.trade # So the doc see everything # TODO: use just +=, m.css should reorder this on its own -corrade.__all__ = ['containers', 'pluginmanager', 'BUILD_STATIC', 'BUILD_MULTITHREADED', 'TARGET_UNIX', 'TARGET_APPLE', 'TARGET_IOS', 'TARGET_IOS_SIMULATOR', 'TARGET_WINDOWS', 'TARGET_WINDOWS_RT', 'TARGET_EMSCRIPTEN', 'TARGET_ANDROID'] -magnum.__all__ = ['math', 'gl', 'meshtools', 'platform', 'primitives', 'shaders', 'scenegraph', 'text', 'trade', 'BUILD_STATIC', 'TARGET_GL', 'TARGET_GLES', 'TARGET_GLES2', 'TARGET_WEBGL', 'TARGET_EGL', 'TARGET_VK'] + magnum.__all__ +corrade.__all__ = ['containers', 'pluginmanager', 'BUILD_DEPRECATED', 'BUILD_STATIC', 'BUILD_MULTITHREADED', 'TARGET_UNIX', 'TARGET_APPLE', 'TARGET_IOS', 'TARGET_IOS_SIMULATOR', 'TARGET_WINDOWS', 'TARGET_WINDOWS_RT', 'TARGET_EMSCRIPTEN', 'TARGET_ANDROID'] +magnum.__all__ = ['math', 'gl', 'meshtools', 'platform', 'primitives', 'shaders', 'scenegraph', 'text', 'trade', 'BUILD_DEPRECATED', 'BUILD_STATIC', 'TARGET_GL', 'TARGET_GLES', 'TARGET_GLES2', 'TARGET_WEBGL', 'TARGET_EGL', 'TARGET_VK'] + magnum.__all__ # hide values of the preprocessor defines to avoid confusion by assigning a # class without __repr__ to them # TODO: more systematic solution directly in m.css class DoNotPrintValue: pass +corrade.BUILD_DEPRECATED = DoNotPrintValue() corrade.BUILD_STATIC = DoNotPrintValue() corrade.BUILD_MULTITHREADED = DoNotPrintValue() corrade.TARGET_UNIX = DoNotPrintValue() @@ -41,6 +42,7 @@ corrade.TARGET_WINDOWS = DoNotPrintValue() corrade.TARGET_WINDOWS_RT = DoNotPrintValue() corrade.TARGET_EMSCRIPTEN = DoNotPrintValue() corrade.TARGET_ANDROID = DoNotPrintValue() +magnum.BUILD_DEPRECATED = DoNotPrintValue() magnum.BUILD_STATIC = DoNotPrintValue() magnum.TARGET_GL = DoNotPrintValue() magnum.TARGET_GLES = DoNotPrintValue() @@ -51,6 +53,7 @@ magnum.TARGET_VK = DoNotPrintValue() # TODO ugh... can this be expressed directly in pybind? corrade.__annotations__ = { + 'BUILD_DEPRECATED': bool, 'BUILD_STATIC': bool, 'BUILD_MULTITHREADED': bool, 'TARGET_UNIX': bool, @@ -63,6 +66,7 @@ corrade.__annotations__ = { 'TARGET_ANDROID': bool } magnum.__annotations__ = { + 'BUILD_DEPRECATED': bool, 'BUILD_STATIC': bool, 'TARGET_GL': bool, 'TARGET_GLES': bool, diff --git a/doc/python/corrade.rst b/doc/python/corrade.rst index b5dcd0a..0e35a17 100644 --- a/doc/python/corrade.rst +++ b/doc/python/corrade.rst @@ -36,6 +36,7 @@ >>> from corrade import * .. py:module:: corrade + :data BUILD_DEPRECATED: Build with deprecated features enabled :data BUILD_STATIC: Static library build :data BUILD_MULTITHREADED: Multi-threaded build :data TARGET_UNIX: Unix target diff --git a/doc/python/magnum.rst b/doc/python/magnum.rst index 6e6992d..da14f88 100644 --- a/doc/python/magnum.rst +++ b/doc/python/magnum.rst @@ -29,6 +29,7 @@ >>> from magnum import * .. py:module:: magnum + :data BUILD_DEPRECATED: Build with deprecated features enabled :data BUILD_STATIC: Static library build :data TARGET_GL: OpenGL interoperability :data TARGET_GLES: OpenGL ES target diff --git a/doc/python/pages/changelog.rst b/doc/python/pages/changelog.rst index 971ef15..8700cdd 100644 --- a/doc/python/pages/changelog.rst +++ b/doc/python/pages/changelog.rst @@ -35,6 +35,10 @@ Changelog `Changes since 2020.06`_ ======================== +- Exposed the :ref:`corrade.BUILD_DEPRECATED` and + :ref:`magnum.BUILD_DEPRECATED` constants, as some features may work + differently depending on these being enabled or not and it's useful to be + able to query this - Exposed missing :ref:`Vector4` constructor from a :ref:`Vector3` and a W component and :ref:`Vector3` from :ref:`Vector2` and a Z component - Renamed :py:`Matrix3.from()` / :py:`Matrix4.from()` to :ref:`Matrix3.from_()` diff --git a/src/python/corrade/corrade.cpp b/src/python/corrade/corrade.cpp index 4e5fbee..96bbe44 100644 --- a/src/python/corrade/corrade.cpp +++ b/src/python/corrade/corrade.cpp @@ -39,6 +39,13 @@ namespace py = pybind11; extern "C" PYBIND11_EXPORT PyObject* PyInit__corrade(); PYBIND11_MODULE(_corrade, m) { m.doc() = "Root Corrade module"; + m.attr("BUILD_DEPRECATED") = + #ifdef CORRADE_BUILD_DEPRECATED + true + #else + false + #endif + ; m.attr("BUILD_STATIC") = #ifdef CORRADE_BUILD_STATIC true diff --git a/src/python/magnum/magnum.cpp b/src/python/magnum/magnum.cpp index 6bd82d7..f6d6312 100644 --- a/src/python/magnum/magnum.cpp +++ b/src/python/magnum/magnum.cpp @@ -156,6 +156,13 @@ template void imageViewFromMutable(py::class_>& } void magnum(py::module_& m) { + m.attr("BUILD_DEPRECATED") = + #ifdef MAGNUM_BUILD_DEPRECATED + true + #else + false + #endif + ; m.attr("BUILD_STATIC") = #ifdef MAGNUM_BUILD_STATIC true