From 7d85affd4e9eb33c550c399e8a6bcbee50d6bdb3 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Wed, 24 Jun 2026 10:33:05 -0700 Subject: [PATCH 1/2] `setup.py`: Windows `openPMD_CMAKE_...` Env Vars We pass openPMD_CMAKE_= environment variables through as `-D` flags to CMake configure. Windows environment variable are all CAPS, so also accept the all-caps variant of the prefix, then the `openPMD_` CMake option names are case-sensitive, so restore the "openPMD_" prefix that upper-casing would destroy. All suffixes of our options are luckily `..._ALL_CAPS` anyway. --- setup.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 8f7ccee1ad..b47d4e8599 100644 --- a/setup.py +++ b/setup.py @@ -171,13 +171,23 @@ def build_extension(self, ext): # extra CMake arguments extra_cmake_args = [] +# Pass openPMD_CMAKE_= environment variables through as -D +# flags. Windows environment variable are all CAPS, so also accept the +# all-caps variant of the prefix, then the openPMD_ CMake option names are case- +# sensitive, so restore the "openPMD_" prefix that upper-casing would destroy. +# All suffixes of our options are luckily ..._ALL_CAPS anyway. +extra_cmake_args_prefix = "openPMD_CMAKE_" for k, v in os.environ.items(): - extra_cmake_args_prefix = "openPMD_CMAKE_" - if k.startswith(extra_cmake_args_prefix) and \ - len(k) > len(extra_cmake_args_prefix): - extra_cmake_args.append("-D{0}={1}".format( - k[len(extra_cmake_args_prefix):], - v)) + if k.startswith(extra_cmake_args_prefix): + cmake_var = k[len(extra_cmake_args_prefix):] + elif k.startswith(extra_cmake_args_prefix.upper()): + cmake_var = k[len(extra_cmake_args_prefix):] + if cmake_var.startswith("OPENPMD_"): + cmake_var = "openPMD_" + cmake_var[len("openPMD_"):] + else: + continue + if cmake_var: + extra_cmake_args.append("-D{0}={1}".format(cmake_var, v)) # https://cmake.org/cmake/help/v3.0/command/if.html if openPMD_USE_MPI.upper() in ['1', 'ON', 'TRUE', 'YES']: From 9d6b307128c9a02b214af1eb71ad38f0408139b0 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Wed, 24 Jun 2026 23:34:45 -0700 Subject: [PATCH 2/2] Flake8: Chop off 1 char --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b47d4e8599..e0c45c0603 100644 --- a/setup.py +++ b/setup.py @@ -173,7 +173,7 @@ def build_extension(self, ext): extra_cmake_args = [] # Pass openPMD_CMAKE_= environment variables through as -D # flags. Windows environment variable are all CAPS, so also accept the -# all-caps variant of the prefix, then the openPMD_ CMake option names are case- +# all-caps variant of the prefix, then the openPMD_ CMake option names are case # sensitive, so restore the "openPMD_" prefix that upper-casing would destroy. # All suffixes of our options are luckily ..._ALL_CAPS anyway. extra_cmake_args_prefix = "openPMD_CMAKE_"