Skip to content

Commit 819262f

Browse files
committed
Fix python wheel builds
1 parent bd328d4 commit 819262f

File tree

5 files changed

+31
-16
lines changed

5 files changed

+31
-16
lines changed

CMakeLists.txt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -578,16 +578,24 @@ if (NANOGUI_BUILD_PYTHON)
578578
message(STATUS "NanoGUI: building the Python plugin.")
579579
if (NOT TARGET nanobind::module)
580580
if (SKBUILD)
581+
# Constrain FindPython to find the Python version used by scikit-build
582+
set(Python_VERSION "${PYTHON_VERSION_STRING}")
583+
set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}")
584+
set(Python_INCLUDE_DIR "${PYTHON_INCLUDE_DIR}")
585+
set(Python_LIBRARIES "${PYTHON_LIBRARY}")
586+
587+
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
588+
581589
execute_process(
582590
COMMAND
583-
"${PYTHON_EXECUTABLE}" -c
584-
"import nanobind; print(nanobind.get_cmake_dir())"
591+
"${PYTHON_EXECUTABLE}" -c "import nanobind; print(nanobind.cmake_dir())"
585592
OUTPUT_VARIABLE _tmp_dir
586593
OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ECHO STDOUT)
587-
list(APPEND CMAKE_PREFIX_PATH "${_tmp_dir}")
594+
list(APPEND CMAKE_PREFIX_PATH "${_tmp_dir}")
595+
588596
find_package(nanobind CONFIG REQUIRED)
589597
else()
590-
find_package(Python COMPONENTS Interpreter Development REQUIRED)
598+
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
591599

592600
# Allow overriding the nanobind library used to compile NanoGUI
593601
set(NANOGUI_NANOBIND_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ext/nanobind"

README.rst

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
NanoGUI
22
========================================================================================
3-
|docs| |travis| |appveyor|
3+
|docs| |gha|
44

55
.. |docs| image:: https://readthedocs.org/projects/nanogui/badge/?version=latest
66
:target: http://nanogui.readthedocs.org/en/latest/?badge=latest
77
:alt: Docs
88

9-
.. |travis| image:: https://travis-ci.org/wjakob/nanogui.svg?branch=master
10-
:target: https://travis-ci.org/wjakob/nanogui
11-
:alt: Travis Build Status
12-
13-
.. |appveyor| image:: https://ci.appveyor.com/api/projects/status/m8h3uyvdb4ej2i02/branch/master?svg=true
14-
:target: https://ci.appveyor.com/project/wjakob/nanogui/branch/master
15-
:alt: Appveyor Build Status
9+
.. |gha| image:: https://github.com/mitsuba-renderer/nanogui/actions/workflows/build.yml/badge.svg
10+
:target: https://github.com/mitsuba-renderer/nanogui/actions/workflows/build.yml
11+
:alt: GitHub Actions Build Status
1612

1713
.. begin_brief_description
1814
1915
NanoGUI is a minimalistic cross-platform widget library for OpenGL 3+, GLES
2016
2/3, and Metal. It supports automatic layout generation, stateful C++ lambdas
2117
callbacks, a variety of useful widget types and Retina-capable rendering on
2218
Apple devices thanks to NanoVG_ by Mikko Mononen. Python bindings of all
23-
functionality are provided using pybind11_. Binary wheels of NanoGUI are
19+
functionality are provided using nanobind_. Binary wheels of NanoGUI are
2420
available on PyPI_.
2521

2622
**Note**: This repository contains an improved port of the original NanoGUI_.
@@ -57,7 +53,7 @@ the the repository here incorporates the following changes:
5753
7. The Entypo_ icon font has been replaced by FontAwesome_ (v5.10.1).
5854

5955
.. _NanoVG: https://github.com/memononen/NanoVG
60-
.. _pybind11: https://github.com/wjakob/pybind11
56+
.. _nanobind: https://github.com/wjakob/nanobind
6157
.. _PyPi: https://pypi.org/project/nanogui
6258
.. _NanoGUI: https://github.com/wjakob/nanogui
6359
.. _Tekari: https://rgl.epfl.ch/tekari?url=%2F%2Frgl.s3.eu-central-1.amazonaws.com%2Fmedia%2Fuploads%2Fwjakob%2F2018%2F08%2F27%2Firidescent-paper.txt&log=1

nanogui/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
_import('nanogui.nanogui_ext')
44

5-
def get_cmake_dir():
5+
def cmake_dir():
66
from os import path
77
file_dir = path.abspath(path.dirname(__file__))
88
cmake_path = path.join(file_dir, "share", "cmake", "nanogui")

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[build-system]
2-
requires = ["setuptools", "wheel", "scikit-build @ git+https://github.com/scikit-build/scikit-build.git@master", "cmake", "ninja", "nanobind>=0.0.7"]
2+
requires = ["setuptools", "wheel", "scikit-build", "cmake", "ninja", "nanobind>=0.0.8"]
3+
build-backend = "setuptools.build_meta"

src/python/widget.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,19 @@ int widget_tp_traverse_base(PyObject *self, visitproc visit, void *arg, PyTypeOb
3030
strcmp(name + name_len - suffix_len, suffix) != 0)
3131
continue;
3232

33+
34+
#if PY_VERSION_HEX < 0x03090000
35+
PyObject *func = PyObject_GetAttr(self, key),
36+
*result = nullptr;
37+
if (func) {
38+
result = _PyObject_Vectorcall(func, nullptr, 0, nullptr);
39+
Py_DECREF(func);
40+
}
41+
#else
3342
PyObject *args[] = { self };
3443
PyObject *result = PyObject_VectorcallMethod(
3544
key, args, 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, nullptr);
45+
#endif
3646

3747
if (!result) {
3848
PyErr_Clear();

0 commit comments

Comments
 (0)