From e154c8de3ed3922cece8f5ebcdb71da409f924ef Mon Sep 17 00:00:00 2001 From: Guillaume Fraux Date: Thu, 28 May 2026 13:22:48 +0200 Subject: [PATCH] Re-enable Windows Rust tests --- .github/workflows/rust-tests.yml | 30 ++++++++++++++-------------- metatomic-core/Cargo.toml | 2 +- metatomic-core/src/system.rs | 12 +++++------ metatomic-core/tests/CMakeLists.txt | 18 +++++++++++++---- metatomic-core/tests/utils/mod.rs | 4 ++-- python/metatomic_core/pyproject.toml | 2 +- python/metatomic_core/setup.py | 2 +- 7 files changed, 40 insertions(+), 30 deletions(-) diff --git a/.github/workflows/rust-tests.yml b/.github/workflows/rust-tests.yml index 77ac78387..9a29bf23b 100644 --- a/.github/workflows/rust-tests.yml +++ b/.github/workflows/rust-tests.yml @@ -51,21 +51,21 @@ jobs: cc: clang cmake-generator: Unix Makefiles - # - os: windows-2022 - # rust-version: stable - # rust-target: x86_64-pc-windows-msvc - # extra-name: " / MSVC" - # cxx: cl.exe - # cc: cl.exe - # cmake-generator: Visual Studio 17 2022 - - # - os: windows-2022 - # rust-version: stable - # rust-target: x86_64-pc-windows-gnu - # extra-name: " / MinGW" - # cxx: g++.exe - # cc: gcc.exe - # cmake-generator: MinGW Makefiles + - os: windows-2022 + rust-version: stable + rust-target: x86_64-pc-windows-msvc + extra-name: " / MSVC" + cxx: cl.exe + cc: cl.exe + cmake-generator: Visual Studio 17 2022 + + - os: windows-2022 + rust-version: stable + rust-target: x86_64-pc-windows-gnu + extra-name: " / MinGW" + cxx: g++.exe + cc: gcc.exe + cmake-generator: MinGW Makefiles steps: - name: install dependencies in container if: matrix.container == 'ubuntu:22.04' diff --git a/metatomic-core/Cargo.toml b/metatomic-core/Cargo.toml index b88a91cda..4693e30dd 100644 --- a/metatomic-core/Cargo.toml +++ b/metatomic-core/Cargo.toml @@ -14,7 +14,7 @@ name = "metatomic" bench = false [dependencies] -metatensor = { version = "0.3.0" } +metatensor = { version = "0.4.1" } once_cell = "1" dlpk = { version = "0.3", features = ["ndarray"]} json = "0.12" diff --git a/metatomic-core/src/system.rs b/metatomic-core/src/system.rs index d30dccce4..d014fcc80 100644 --- a/metatomic-core/src/system.rs +++ b/metatomic-core/src/system.rs @@ -440,10 +440,10 @@ use ndarray::{Array1, Array2}; fn valid_pair_block(dtype: &str) -> TensorBlock { let samples = Labels::new( ["first_atom", "second_atom", "cell_shift_a", "cell_shift_b", "cell_shift_c"], - &[[0i32, 1, 0, 0, 0]], + [[0i32, 1, 0, 0, 0]], ); - let components = vec![Labels::new(["xyz"], &[[0i32], [1], [2]])]; - let properties = Labels::new(["distance"], &[[0i32]]); + let components = vec![Labels::new(["xyz"], [[0i32], [1], [2]])]; + let properties = Labels::new(["distance"], [[0i32]]); match dtype { "f32" => { @@ -459,9 +459,9 @@ use ndarray::{Array1, Array2}; } fn valid_custom_data(dtype: &str) -> TensorMap { - let keys = Labels::new(["key"], &[[0i32]]); - let samples = Labels::new(["sample"], &[[0i32]]); - let properties = Labels::new(["property"], &[[0i32]]); + let keys = Labels::new(["key"], [[0i32]]); + let samples = Labels::new(["sample"], [[0i32]]); + let properties = Labels::new(["property"], [[0i32]]); let block = match dtype { "f32" => { diff --git a/metatomic-core/tests/CMakeLists.txt b/metatomic-core/tests/CMakeLists.txt index 77e251ddc..29d432132 100644 --- a/metatomic-core/tests/CMakeLists.txt +++ b/metatomic-core/tests/CMakeLists.txt @@ -55,6 +55,16 @@ endif() enable_testing() add_subdirectory(test-plugins) +if (TARGET metatensor::shared) + get_target_property(METATENSOR_LOCATION metatensor::shared IMPORTED_LOCATION) + get_filename_component(METATENSOR_DIR ${METATENSOR_LOCATION} DIRECTORY) +elseif (TARGET metatensor) + get_target_property(METATENSOR_LOCATION metatensor LOCATION) + get_filename_component(METATENSOR_DIR ${METATENSOR_LOCATION} DIRECTORY) +else() + set(METATENSOR_DIR "") +endif() + file(GLOB ALL_TESTS *.cpp) foreach(_file_ ${ALL_TESTS}) get_filename_component(_name_ ${_file_} NAME_WE) @@ -71,7 +81,7 @@ foreach(_file_ ${ALL_TESTS}) NO_SYSTEM_FROM_IMPORTED ON ) - target_compile_definitions(${_name_} PRIVATE PLUGIN_DIR="${CMAKE_CURRENT_BINARY_DIR}/test-plugins") + target_compile_definitions(${_name_} PRIVATE PLUGIN_DIR="$") add_test( NAME ${_name_} @@ -79,11 +89,11 @@ foreach(_file_ ${ALL_TESTS}) ) if(WIN32) - # We need to set the path to allow access to metatomic.dll - # this does a similar job to the BUILD_RPATH above + # We need to set the path to allow access to metatomic.dll and + # metatensor.dll. This does a similar job to the BUILD_RPATH above. STRING(REPLACE ";" "\\;" PATH_STRING "$ENV{PATH}") set_tests_properties(${_name_} PROPERTIES - ENVIRONMENT "PATH=${PATH_STRING}\;$" + ENVIRONMENT "PATH=${PATH_STRING}\;$\;${METATENSOR_DIR}" ) endif() endforeach() diff --git a/metatomic-core/tests/utils/mod.rs b/metatomic-core/tests/utils/mod.rs index e12e6897c..a4b0e9dbf 100644 --- a/metatomic-core/tests/utils/mod.rs +++ b/metatomic-core/tests/utils/mod.rs @@ -255,7 +255,7 @@ pub fn setup_torch_pip(python: &Path) -> PathBuf { /// Install metatensor in a Python virtualenv with pip, and return the /// CMAKE_PREFIX_PATH for the installed libmetatensor. pub fn setup_metatensor_pip(python: &Path) -> PathBuf { - pip_install(python, &["metatensor-core >=0.2.0,<0.3"], PipInstallOptions::default()); + pip_install(python, &["metatensor-core >=0.2.2,<0.3"], PipInstallOptions::default()); let mut cmd = Command::new(python); cmd.arg("-c"); @@ -275,7 +275,7 @@ pub fn setup_metatensor_pip(python: &Path) -> PathBuf { /// Install metatensor-torch in a Python virtualenv with pip, and return the /// CMAKE_PREFIX_PATH for the installed libmetatensor_torch. pub fn setup_metatensor_torch_pip(python: &Path) -> PathBuf { - pip_install(python, &["metatensor-torch >=0.9.0,<0.10"], PipInstallOptions::default()); + pip_install(python, &["metatensor-torch >=0.10.0,<0.11"], PipInstallOptions::default()); let mut cmd = Command::new(python); cmd.arg("-c"); diff --git a/python/metatomic_core/pyproject.toml b/python/metatomic_core/pyproject.toml index 9107f6805..62e501ba9 100644 --- a/python/metatomic_core/pyproject.toml +++ b/python/metatomic_core/pyproject.toml @@ -36,7 +36,7 @@ requires = [ "setuptools >=77", "packaging >=26", "cmake", - "metatensor-core >=0.2.0,<0.3", + "metatensor-core >=0.2.2,<0.3", ] build-backend = "setuptools.build_meta" diff --git a/python/metatomic_core/setup.py b/python/metatomic_core/setup.py index 35a2ef16c..905fb5c23 100644 --- a/python/metatomic_core/setup.py +++ b/python/metatomic_core/setup.py @@ -133,7 +133,7 @@ def create_version_number(version): authors = fd.read().splitlines() install_requires = [ - "metatensor-core >=0.2.0,<0.3", + "metatensor-core >=0.2.2,<0.3", ] setup(