From d0a86b8b74ebc432db0926727a2767a2d7db268f Mon Sep 17 00:00:00 2001 From: sbein Date: Fri, 27 Mar 2026 18:57:30 +0100 Subject: [PATCH 1/9] Fix correction config paths for editable installs --- src/correctionlib/cli.py | 15 ++++++++++++--- tests/test_binding.py | 22 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/correctionlib/cli.py b/src/correctionlib/cli.py index ae3c26f..93e8629 100644 --- a/src/correctionlib/cli.py +++ b/src/correctionlib/cli.py @@ -152,10 +152,20 @@ def setup_merge(subparsers): return parser -def config(console: Console, args: argparse.Namespace) -> int: +def _artifact_base_dir(): + import correctionlib._core as _core + from pathlib import Path + + base = Path(_core.__file__).resolve().parent + if (base / "cmake").exists() and (base / "include").exists(): + return base + from .util import this_module_path + return this_module_path() - base_dir = this_module_path() + +def config(console: Console, args: argparse.Namespace) -> int: + base_dir = _artifact_base_dir() incdir = base_dir / "include" libdir = base_dir / "lib" out = [] @@ -176,7 +186,6 @@ def config(console: Console, args: argparse.Namespace) -> int: console.out(" ".join(out), highlight=False) return 0 - def setup_config(subparsers): parser = subparsers.add_parser( "config", help="Configuration and linking information" diff --git a/tests/test_binding.py b/tests/test_binding.py index 853ccf1..244cd1f 100644 --- a/tests/test_binding.py +++ b/tests/test_binding.py @@ -114,3 +114,25 @@ def test_cmake_static_compilation(csetstr: str): subprocess.run( [os.path.join(tmpdir, prog)], capture_output=True, check=True, cwd=tmpdir ) + +def test_cli_config_paths(): + import subprocess + from pathlib import Path + + incdir = Path( + subprocess.check_output(["correction", "config", "--incdir"]) + .decode() + .strip() + ) + cmakeflag = ( + subprocess.check_output(["correction", "config", "--cmake"]) + .decode() + .strip() + ) + cmakedir = Path(cmakeflag.split("=", 1)[1]) + + assert incdir.exists() + assert (incdir / "correction.h").exists() + assert cmakedir.exists() + assert (cmakedir / "correctionlibConfig.cmake").exists() + From 07c5c046c6e2dca449db87cdf476cf78c168f573 Mon Sep 17 00:00:00 2001 From: sbein Date: Fri, 27 Mar 2026 19:49:47 +0100 Subject: [PATCH 2/9] Link lwtnn-stat on MSVC builds --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3491301..2336f0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,8 +61,8 @@ if(MSVC) target_compile_options(correctionlib PRIVATE /Zc:__cplusplus /utf-8) else() target_compile_options(correctionlib PRIVATE -Wall -Wextra -Wpedantic -Werror) -target_link_libraries(correctionlib PRIVATE lwtnn-stat) endif() +target_link_libraries(correctionlib PRIVATE lwtnn-stat) if(ZLIB_FOUND) target_link_libraries(correctionlib PRIVATE ZLIB::ZLIB) endif() From 1dde8051b61a71dde9a8dae5a4ec2f58bfdfb89f Mon Sep 17 00:00:00 2001 From: sbein Date: Thu, 2 Apr 2026 18:46:20 +0200 Subject: [PATCH 3/9] Added comment about editable configuration check and ran formatting --- src/correctionlib/cli.py | 7 ++++++- tests/test_binding.py | 15 +++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/correctionlib/cli.py b/src/correctionlib/cli.py index 93e8629..d187332 100644 --- a/src/correctionlib/cli.py +++ b/src/correctionlib/cli.py @@ -153,14 +153,18 @@ def setup_merge(subparsers): def _artifact_base_dir(): - import correctionlib._core as _core from pathlib import Path + import correctionlib._core as _core + + # Prefer extension-module path in editable installs, since headers live with built artifacts, not the source tree. + # Prevents failure in test_cmake_static_compilation: fatal error: correction.h: No such file or directory base = Path(_core.__file__).resolve().parent if (base / "cmake").exists() and (base / "include").exists(): return base from .util import this_module_path + return this_module_path() @@ -186,6 +190,7 @@ def config(console: Console, args: argparse.Namespace) -> int: console.out(" ".join(out), highlight=False) return 0 + def setup_config(subparsers): parser = subparsers.add_parser( "config", help="Configuration and linking information" diff --git a/tests/test_binding.py b/tests/test_binding.py index 244cd1f..266d77a 100644 --- a/tests/test_binding.py +++ b/tests/test_binding.py @@ -3,11 +3,10 @@ import subprocess import tempfile -import correctionlib.version -import pytest - import correctionlib import correctionlib.schemav2 as cs +import correctionlib.version +import pytest @pytest.fixture(scope="module") @@ -115,19 +114,16 @@ def test_cmake_static_compilation(csetstr: str): [os.path.join(tmpdir, prog)], capture_output=True, check=True, cwd=tmpdir ) + def test_cli_config_paths(): import subprocess from pathlib import Path incdir = Path( - subprocess.check_output(["correction", "config", "--incdir"]) - .decode() - .strip() + subprocess.check_output(["correction", "config", "--incdir"]).decode().strip() ) cmakeflag = ( - subprocess.check_output(["correction", "config", "--cmake"]) - .decode() - .strip() + subprocess.check_output(["correction", "config", "--cmake"]).decode().strip() ) cmakedir = Path(cmakeflag.split("=", 1)[1]) @@ -135,4 +131,3 @@ def test_cli_config_paths(): assert (incdir / "correction.h").exists() assert cmakedir.exists() assert (cmakedir / "correctionlibConfig.cmake").exists() - From a71893292f25a4dbc5e8226e3531c028a84c8ad3 Mon Sep 17 00:00:00 2001 From: sbein Date: Thu, 2 Apr 2026 20:27:39 +0200 Subject: [PATCH 4/9] Match pre-commit import ordering in test_binding --- tests/test_binding.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_binding.py b/tests/test_binding.py index 266d77a..cadb225 100644 --- a/tests/test_binding.py +++ b/tests/test_binding.py @@ -3,11 +3,11 @@ import subprocess import tempfile -import correctionlib -import correctionlib.schemav2 as cs import correctionlib.version import pytest +import correctionlib +import correctionlib.schemav2 as cs @pytest.fixture(scope="module") def csetstr(): From 568773f946ef06fdfe3b7b9989bf936a31b9530f Mon Sep 17 00:00:00 2001 From: sbein Date: Fri, 3 Apr 2026 00:09:23 +0200 Subject: [PATCH 5/9] updating spooky spaces that might be causing a problem? --- tests/test_binding.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_binding.py b/tests/test_binding.py index cadb225..3acb763 100644 --- a/tests/test_binding.py +++ b/tests/test_binding.py @@ -9,6 +9,7 @@ import correctionlib import correctionlib.schemav2 as cs + @pytest.fixture(scope="module") def csetstr(): ptweight = cs.Correction( From cbc83f788a8c99c5155422b0c8d7b5ff980cff32 Mon Sep 17 00:00:00 2001 From: sbein Date: Fri, 3 Apr 2026 01:27:46 +0200 Subject: [PATCH 6/9] Preserve correctionlib version variables across lwtnn subproject --- CMakeLists.txt | 3 +++ include/version.h.in | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2336f0b..80ab6af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,10 +4,13 @@ if(NOT SKBUILD_PROJECT_VERSION) set(SKBUILD_PROJECT_VERSION "0.0.0") # provided by scikit-build-core endif() string(REPLACE "." ";" VERSION_SPLIT ${SKBUILD_PROJECT_VERSION}) +set(CORRECTIONLIB_SKBUILD_PROJECT_VERSION "${SKBUILD_PROJECT_VERSION}") list(GET VERSION_SPLIT 0 SPLIT_VERSION_MAJOR) list(GET VERSION_SPLIT 1 SPLIT_VERSION_MINOR) project(correctionlib VERSION ${SPLIT_VERSION_MAJOR}.${SPLIT_VERSION_MINOR} LANGUAGES CXX) +set(CORRECTIONLIB_VERSION_MAJOR "${correctionlib_VERSION_MAJOR}") +set(CORRECTIONLIB_VERSION_MINOR "${correctionlib_VERSION_MINOR}") option(BUILD_DEMO "Build demo program" ON) diff --git a/include/version.h.in b/include/version.h.in index 2e87d6d..b73f84c 100644 --- a/include/version.h.in +++ b/include/version.h.in @@ -4,9 +4,9 @@ #include namespace correction { - constexpr std::string_view correctionlib_version{"@SKBUILD_PROJECT_VERSION@"}; - constexpr int correctionlib_major_version{@correctionlib_VERSION_MAJOR@}; - constexpr int correctionlib_minor_version{@correctionlib_VERSION_MINOR@}; + constexpr std::string_view correctionlib_version{"@CORRECTIONLIB_SKBUILD_PROJECT_VERSION@"}; + constexpr int correctionlib_major_version{@CORRECTIONLIB_VERSION_MAJOR@}; + constexpr int correctionlib_minor_version{@CORRECTIONLIB_VERSION_MINOR@}; } #endif // CORRECTIONLIB_VERSION_H From db13dde711a5255c7d8abc6f44c0a2a37b22e5c8 Mon Sep 17 00:00:00 2001 From: sbein Date: Sun, 5 Apr 2026 12:18:31 +0200 Subject: [PATCH 7/9] updating version call --- tests/test_binding.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/test_binding.py b/tests/test_binding.py index 3acb763..4125b2e 100644 --- a/tests/test_binding.py +++ b/tests/test_binding.py @@ -90,9 +90,13 @@ def test_cmake_static_compilation(csetstr: str): with open(cmake, "w") as f: f.write(CMAKELIST_SRC) testprog = os.path.join(tmpdir, "test.cc") - # SKBUILD_PROJECT_VERSION only includes major.minor.patch - # it also trims any prerelease suffixes - versionstr = ".".join(map(str, correctionlib.version.__version_tuple__[:3])) + + # SKBUILD_PROJECT_VERSION stores the normalized base version and trims + # any prerelease/dev suffixes, so mirror that behavior here. + from packaging.version import Version + + versionstr = Version(correctionlib.version.version).base_version + with open(testprog, "w") as f: f.write(TESTPROG_SRC % (versionstr, csetstr)) flags = ( From aafa4768f413f1b9373c4909fe3e3226139404ce Mon Sep 17 00:00:00 2001 From: sbein Date: Sun, 5 Apr 2026 13:45:46 +0200 Subject: [PATCH 8/9] Update lwtnn submodule for MSVC warning flags --- lwtnn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lwtnn b/lwtnn index 8243609..7056a15 160000 --- a/lwtnn +++ b/lwtnn @@ -1 +1 @@ -Subproject commit 82436098bf76f9784fd89e2c760355bc40cec35c +Subproject commit 7056a1524b07d97d5376f72c20030f831c0dffff From ef5026ab5c436b752285b6a6945c3b7530a7d583 Mon Sep 17 00:00:00 2001 From: sbein Date: Sun, 5 Apr 2026 13:47:35 +0200 Subject: [PATCH 9/9] Point lwtnn submodule to fork for MSVC fix validation --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 5083c4e..c755479 100644 --- a/.gitmodules +++ b/.gitmodules @@ -15,4 +15,4 @@ url = https://github.com/Cyan4973/xxHash.git [submodule "lwtnn"] path = lwtnn - url = https://github.com/lwtnn/lwtnn.git + url = https://github.com/sbein/lwtnn.git