Skip to content

Commit 0f47fe0

Browse files
committed
Fix python wheel builds
1 parent bd328d4 commit 0f47fe0

File tree

8 files changed

+35
-23
lines changed

8 files changed

+35
-23
lines changed

.github/workflows/wheels.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
default: '0'
1010

1111
env:
12-
CIBW_SKIP: pp* cp27-* cp35-* cp36-* cp37-* cp38-macosx_arm64
12+
CIBW_SKIP: pp* *-musllinux* cp27-* cp35-* cp36-* cp37-* cp38-macosx_arm64
1313
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
1414
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014
1515
CIBW_ARCHS_WINDOWS: auto64

CMakeLists.txt

+11-6
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ endif()
8080

8181
if (MSVC)
8282
set(NANOGUI_NATIVE_FLAGS_DEFAULT "")
83-
elseif (APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
83+
elseif (APPLE AND (CMAKE_OSX_ARCHITECTURES MATCHES "arm64"))
8484
# Apple M1 compatibility
8585
set(NANOGUI_NATIVE_FLAGS_DEFAULT "-mcpu=apple-a12")
8686
else()
@@ -578,16 +578,21 @@ 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+
584+
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
585+
581586
execute_process(
582587
COMMAND
583-
"${PYTHON_EXECUTABLE}" -c
584-
"import nanobind; print(nanobind.get_cmake_dir())"
588+
"${PYTHON_EXECUTABLE}" -c "import nanobind; print(nanobind.cmake_dir())"
585589
OUTPUT_VARIABLE _tmp_dir
586-
OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ECHO STDOUT)
587-
list(APPEND CMAKE_PREFIX_PATH "${_tmp_dir}")
590+
OUTPUT_STRIP_TRAILING_WHITESPACE)
591+
list(APPEND CMAKE_PREFIX_PATH "${_tmp_dir}")
592+
588593
find_package(nanobind CONFIG REQUIRED)
589594
else()
590-
find_package(Python COMPONENTS Interpreter Development REQUIRED)
595+
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
591596

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

README.rst

+6-10
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

include/nanogui/common.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
#include <stdexcept>
2323

2424
#define NANOGUI_VERSION_MAJOR 0
25-
#define NANOGUI_VERSION_MINOR 1
26-
#define NANOGUI_VERSION_PATCH 4
25+
#define NANOGUI_VERSION_MINOR 2
26+
#define NANOGUI_VERSION_PATCH 0
2727

2828
#define NANOGUI_STRINGIFY(x) #x
2929
#define NANOGUI_TOSTRING(x) NANOGUI_STRINGIFY(x)

include/nanogui/layout.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,8 @@ class NANOGUI_EXPORT AdvancedGridLayout : public Layout {
408408
/// Allows for printing out Anchor position, size, and alignment.
409409
operator std::string() const {
410410
char buf[50];
411-
std::snprintf(buf, 50, "Format[pos=(%i, %i), size=(%i, %i), align=(%i, %i)]",
412-
pos[0], pos[1], size[0], size[1], (int) align[0], (int) align[1]);
411+
snprintf(buf, 50, "Format[pos=(%i, %i), size=(%i, %i), align=(%i, %i)]",
412+
pos[0], pos[1], size[0], size[1], (int) align[0], (int) align[1]);
413413
return buf;
414414
}
415415
};

nanogui/__init__.py

+1-1
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

+2-1
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

+10
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)