chore: Remove setuptools from glad dependencies (#5392)

This commit is contained in:
Dave Lane
2026-07-08 16:04:52 -04:00
committed by GitHub
parent 0131793f96
commit dc419367f3
7 changed files with 11 additions and 40 deletions
+9 -10
View File
@@ -20,7 +20,7 @@ include_guard(GLOBAL)
#
# GLAD_SKIP_PIP_INSTALL is a hard override for environments where Python dependency installs cannot run
# at all (e.g. Flatpak, Homebrew). When OFF (the default) the code below checks
# whether jinja2+setuptools are importable and installs them with uv if they are not.
# whether jinja2 is importable and installs it with uv if it is not.
# When ON the caller is responsible for supplying a Python that already has jinja2,
# typically via -DPython_EXECUTABLE=/path/to/venv/python.
option(GLAD_SKIP_PIP_INSTALL
@@ -104,11 +104,11 @@ add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/glad/cmake" glad2-cmake)
unset(CMAKE_POLICY_VERSION_MINIMUM)
if(NOT GLAD_SKIP_PIP_INSTALL)
# Check whether jinja2 and pkg_resources (setuptools) are already importable.
# pkg_resources is provided by setuptools, which is no longer bundled with Python 3.12+
# on several distros (Debian Trixie, Arch Linux, COPR, FreeBSD, etc.).
# Check whether jinja2 is already importable. Supported Python versions use
# importlib.metadata and importlib.resources in glad, so setuptools' legacy
# pkg_resources module is not required by the generator.
execute_process(
COMMAND "${Python_EXECUTABLE}" -c "import jinja2; import pkg_resources"
COMMAND "${Python_EXECUTABLE}" -c "import jinja2"
RESULT_VARIABLE _glad_deps_import_result
OUTPUT_QUIET
ERROR_QUIET
@@ -118,13 +118,13 @@ if(NOT GLAD_SKIP_PIP_INSTALL)
find_program(UV_EXECUTABLE uv)
if(NOT UV_EXECUTABLE)
message(FATAL_ERROR
"glad: jinja2 or setuptools not found in ${Python_EXECUTABLE}, and uv is not available.\n"
"Install uv, or provide a Python interpreter with glad dependencies installed and set "
"glad: jinja2 not found in ${Python_EXECUTABLE}, and uv is not available.\n"
"Install uv, or provide a Python interpreter with jinja2 installed and set "
"-DGLAD_SKIP_PIP_INSTALL=ON.")
endif()
set(_glad_python_venv "${CMAKE_BINARY_DIR}/glad-python")
message(STATUS "glad: jinja2 or setuptools not found in ${Python_EXECUTABLE}, installing via uv...")
message(STATUS "glad: jinja2 not found in ${Python_EXECUTABLE}, installing via uv...")
execute_process(
COMMAND "${UV_EXECUTABLE}" venv
--python "${Python_EXECUTABLE}"
@@ -144,7 +144,6 @@ if(NOT GLAD_SKIP_PIP_INSTALL)
COMMAND "${UV_EXECUTABLE}" pip install
--python "${_glad_python_executable}"
--requirement "${CMAKE_SOURCE_DIR}/third-party/glad/requirements.txt"
"setuptools<81"
--quiet
COMMAND_ERROR_IS_FATAL ANY
)
@@ -154,7 +153,7 @@ if(NOT GLAD_SKIP_PIP_INSTALL)
set(PYTHON_EXECUTABLE "${Python_EXECUTABLE}" CACHE FILEPATH "Python interpreter for glad" FORCE)
else()
message(STATUS
"glad: jinja2 and setuptools already available in "
"glad: jinja2 already available in "
"${Python_EXECUTABLE}, skipping Python dependency install")
endif()
endif()