diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index a56be1e71..b185ec9d3 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -56,13 +56,11 @@ jobs: echo "CMAKE_CXX_COMPILER_LAUNCHER=sccache" >> $GITHUB_ENV - name: collect rust and C/C++ coverage - # env: - # FEATOMIC_TEST_WITH_STATIC_LIB: "1" run: | cargo tarpaulin --all-features --workspace --engine=llvm --out=xml --output-dir=target/tarpaulin --objects target/debug/libfeatomic.so # cleanup C/C++ coverage lcov --directory . --capture --output-file coverage.info - lcov --remove coverage.info '/usr/*' "$(pwd)/featomic-c-api/tests/*" "$(pwd)/featomic-c-api/examples/*" --output-file coverage.info + lcov --remove coverage.info '/usr/*' "$(pwd)/featomic/tests/*" "$(pwd)/featomic/examples/*" --output-file coverage.info - name: collect Python coverage run: | diff --git a/.github/workflows/rust-tests.yml b/.github/workflows/rust-tests.yml index 758b356fc..97a4b5e33 100644 --- a/.github/workflows/rust-tests.yml +++ b/.github/workflows/rust-tests.yml @@ -123,7 +123,6 @@ jobs: FEATOMIC_TEST_WITH_STATIC_LIB: ${{ matrix.test-static-lib || 0 }} run: | cargo test --test "*" --package featomic --target ${{ matrix.rust-target }} ${{ matrix.cargo-build-flags }} - cargo test --test "*" --package featomic-c-api --target ${{ matrix.rust-target }} ${{ matrix.cargo-build-flags }} # second set of jobs checking that (non-test) code still compiles/run as expected prevent-bitrot: diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index db0b51c0b..f37ebc5dd 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -123,8 +123,7 @@ Github CI workflows. You can also run only a subset of tests with one of these commands: - ``cargo test`` runs everything -- ``cargo test --package=featomic`` to run the calculators tests; -- ``cargo test --package=featomic-c-api`` to run the C/C++ tests only; +- ``cargo test --package=featomic`` to run the main tests; - ``cargo test --test=run-cxx-tests`` will run the unit tests for the C/C++ API. If `valgrind`_ is installed, it will be used to check for memory diff --git a/Cargo.toml b/Cargo.toml index f3ad4de2d..37d528563 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,8 +3,7 @@ resolver = "2" members = [ "featomic", - "featomic-c-api", - "python", "featomic-torch", + "python", "docs/featomic-json-schema", ] diff --git a/MANIFEST.in b/MANIFEST.in index 2ba1df01a..c62e5dcf0 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,7 +4,6 @@ global-exclude .DS_Store prune docs recursive-include featomic * -recursive-include featomic-c-api * recursive-include docs/featomic-json-schema * # include the minimal crates from the Cargo workspace @@ -25,7 +24,4 @@ prune featomic/tests prune featomic/benches/data prune featomic/examples/data -prune featomic-c-api/tests -prune featomic-c-api/examples - exclude tox.ini diff --git a/docs/Doxyfile b/docs/Doxyfile index 1ef98d6fc..6d185548d 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -944,7 +944,7 @@ WARN_LOGFILE = # Note: If this tag is empty the current directory is searched. INPUT = \ - ../featomic-c-api/include/ \ + ../featomic/include/ \ ../featomic-torch/include/featomic \ ../featomic-torch/include/featomic/torch diff --git a/docs/src/conf.py b/docs/src/conf.py index ab29cafe8..daac36fe9 100644 --- a/docs/src/conf.py +++ b/docs/src/conf.py @@ -73,7 +73,7 @@ def extract_json_schema(): def build_doxygen_docs(): # we need to run a build to make sure the header is up to date - subprocess.run(["cargo", "build", "--package", "featomic-c-api"]) + subprocess.run(["cargo", "build", "--package", "featomic"]) subprocess.run(["doxygen", "Doxyfile"], cwd=os.path.join(ROOT, "docs")) diff --git a/docs/src/devdoc/explanations/architecture.rst b/docs/src/devdoc/explanations/architecture.rst index 988cc39a3..1fe63cc3f 100644 --- a/docs/src/devdoc/explanations/architecture.rst +++ b/docs/src/devdoc/explanations/architecture.rst @@ -5,10 +5,10 @@ The code is organized in three main products, each in a separate directory: - ``featomic/`` contains the main Rust implementation of all calculators, and the corresponding unit and regression tests; -- ``featomic-c-api/`` is a Rust crate containing the implementation of the - featomic C API; -- ``python/`` contains the Python interface to featomic, and the corresponding - tests +- ``featomic-torch/`` contains the TorchScript bindings to featomic, written in + C++; +- ``python/`` contains the Python interface to featomic and featomic-torch, and + the corresponding tests Finally, ``docs/`` contains the documentation for everything related to featomic. diff --git a/docs/src/devdoc/explanations/interfaces.rst b/docs/src/devdoc/explanations/interfaces.rst index 7a960d84e..f26d968f7 100644 --- a/docs/src/devdoc/explanations/interfaces.rst +++ b/docs/src/devdoc/explanations/interfaces.rst @@ -4,32 +4,32 @@ Python and C interface How is the C interface exported ------------------------------- -Featomic exports a C interface, defined in ``featomic-c-api``. This C -interface is created directly in Rust, without involving any C code. +Featomic exports a C interface, created directly in Rust without involving any C +code. This is done by marking functions as ``#[no_mangle] extern pub fn `` in -``featomic-c-api``, and only using types safe to send to C (mostly pointers and -basic values such as floats or integers). Of these markers, ``pub`` ensures that -the function is exported from the library (it should appear as a ``T`` symbol in -``nm`` output); ``extern`` forces the function to use the C calling convention -(a calling convention describes where in memory/CPU registers the caller should -put data that the function expects); and ``#[no_mangle]`` tells the compiler to -export the function under this exact name, instead of using a mangled named -containing the module path and functions parameters. +``featomic/src/c-api/*.rs``, and only using types safe to send to C (mostly +pointers and basic values such as floats or integers). Of these markers, ``pub`` +ensures that the function is exported from the library (it should appear as a +``T`` symbol in ``nm`` output); ``extern`` forces the function to use the C +calling convention (a calling convention describes where in memory/CPU registers +the caller should put data that the function expects); and ``#[no_mangle]`` +tells the compiler to export the function under this exact name, instead of +using a mangled named containing the module path and functions parameters. Additionally, the C interfaces expose C-compatible structs declared with ``#[repr(C)] pub struct {}``; where ``#[repr(C)]`` ensures that the compiler lays out the fields in the exact order they are declared, without re-organizing them. -``featomic-c-api`` is then compiled to a shared library (``libfeatomic.so`` / -``libfeatomic.dylib`` / ``libfeatomic.dll``), which can be used by any -language able to call C code to call the exported functions without ever -realizing it is speaking with Rust code. +``featomic`` is then compiled to a shared library (``libfeatomic.so`` / +``libfeatomic.dylib`` / ``libfeatomic.dll``), which can be used by any language +able to call C code to call the exported functions without ever realizing it is +speaking with Rust code. The list of exported functions, together with the types of the function's parameters, and struct definitions are extracted from the rust source code using -`cbindgen`_, which creates the ``featomic-c-api/featomic.h`` header file +`cbindgen`_, which creates the ``featomic/include/featomic.h`` header file containing all of this information in a C compatible syntax. All of the documentation is also reproduced using `doxygen`_ syntax. @@ -41,13 +41,13 @@ The Python interface used the `ctypes`_ module to call exported symbols from the shared library. For the Python code to be able to call exported function safely, it needs to know a few things. In particular, it needs to know the name of the function, the number and types of parameters and the return type of the -function. All this information is available in ``featomic-c-api/featomic.h``, +function. All this information is available in ``featomic/include/featomic.h``, but not in a way that is easily accessible from `ctypes`_. There is a script in ``python/scripts/generate-declaration.py`` which reads the header file using -`pycparser`_, and creates the `python/featomic/_featomic.py` file which +`pycparser`_, and creates the `python/featomic/_c_api.py` file which declares all functions in the way expected by the `ctypes`_ module. You will need to manually re-run this script if you modify any of the exported functions -in `featomic-c-api`. +in `featomic/src/c-api`. The schematic below describes all the relationships between the components involved in creating the Python interface. @@ -57,11 +57,11 @@ involved in creating the Python interface. :align: center Schematic representation of all components in the Python interface. The rust - crate ``featomic-c-api`` is compiled to a shared library - (``libfeatomic.so`` on Linux), and `cbindgen`_ is used to generate the - corresponding header. This header is then read with `pycparser`_ to create - ctypes' compatible declarations, used to ensure that Python and rust agree - fully on the parameters types, allowing Python to directly call Rust code. + crate ``featomic`` is compiled to a shared library (``libfeatomic.so`` on + Linux), and `cbindgen`_ is used to generate the corresponding header. This + header is then read with `pycparser`_ to create ctypes' compatible + declarations, used to ensure that Python and rust agree fully on the + parameters types, allowing Python to directly call Rust code. .. _ctypes: https://docs.python.org/3/library/ctypes.html .. _pycparser: https://github.com/eliben/pycparser diff --git a/docs/src/devdoc/how-to/profiling.rst b/docs/src/devdoc/how-to/profiling.rst index f76814c2b..3405da7fd 100644 --- a/docs/src/devdoc/how-to/profiling.rst +++ b/docs/src/devdoc/how-to/profiling.rst @@ -69,10 +69,10 @@ You can obtain a dataset for profiling from our :download:`website <../../../sta .. group-tab:: C++ - .. literalinclude:: ../../../../featomic-c-api/examples/profiling.cpp + .. literalinclude:: ../../../../featomic/examples/profiling.cpp :language: c++ .. group-tab:: C - .. literalinclude:: ../../../../featomic-c-api/examples/profiling.c + .. literalinclude:: ../../../../featomic/examples/profiling.c :language: c diff --git a/docs/src/get-started/installation.rst b/docs/src/get-started/installation.rst index 7ddba7471..f4c905fe8 100644 --- a/docs/src/get-started/installation.rst +++ b/docs/src/get-started/installation.rst @@ -49,7 +49,7 @@ well as CMake files that can be used with ``find_package(featomic)``. .. code-block:: bash git clone https://github.com/metatensor/featomic - cd featomic/featomic-c-api + cd featomic/featomic mkdir build cd build cmake .. diff --git a/docs/src/how-to/computing-soap.rst b/docs/src/how-to/computing-soap.rst index bd1e15d35..bbc63da97 100644 --- a/docs/src/how-to/computing-soap.rst +++ b/docs/src/how-to/computing-soap.rst @@ -41,10 +41,10 @@ You can obtain a testing dataset from our :download:`website <../../static/datas .. group-tab:: C++ - .. literalinclude:: ../../../featomic-c-api/examples/compute-soap.cpp + .. literalinclude:: ../../../featomic/examples/compute-soap.cpp :language: c++ .. group-tab:: C - .. literalinclude:: ../../../featomic-c-api/examples/compute-soap.c + .. literalinclude:: ../../../featomic/examples/compute-soap.c :language: c diff --git a/docs/src/references/api/c/index.rst b/docs/src/references/api/c/index.rst index 6a7cebb57..735e7994f 100644 --- a/docs/src/references/api/c/index.rst +++ b/docs/src/references/api/c/index.rst @@ -8,11 +8,11 @@ functions (in particular, this includes Python, Fortran with ``iso_c_env``, C++, and most languages used nowadays). Convenient wrappers of the C API are also provided for :ref:`Python ` users. -The C API is implemented in Rust, in the ``featomic-c-api`` crate. You can use -these functions in your own code by :ref:`installing the corresponding shared -library and header `, and then including ``featomic.h`` and -linking with ``-lfeatomic``. Alternatively, we provide a cmake package config -file, allowing you to do use featomic like this (after installation): +You can use these functions in your own code by :ref:`installing the +corresponding shared library and header `, and then including +``featomic.h`` and linking with ``-lfeatomic``. Alternatively, we provide a +cmake package config file, allowing you to do use featomic like this (after +installation): .. code-block:: cmake diff --git a/featomic-c-api/Cargo.toml b/featomic-c-api/Cargo.toml deleted file mode 100644 index fe6696812..000000000 --- a/featomic-c-api/Cargo.toml +++ /dev/null @@ -1,35 +0,0 @@ -[package] -name = "featomic-c-api" -version = "0.1.0" -authors = ["Guillaume Fraux "] -edition = "2021" -rust-version = "1.74" -publish = false - -[lib] -# when https://github.com/rust-lang/cargo/pull/8789 lands, use it here! -# until then, build all the crate-type we need -name = "featomic" -crate-type = ["cdylib", "staticlib"] -bench = false - -[dependencies] -featomic = {path = "../featomic", version = "0.1.0", default-features = false} -metatensor = "0.2" - -ndarray = "0.16" -log = { version = "0.4", features = ["std"] } -once_cell = "1" -time-graph = {version = "0.3.0", features = ["table", "json"]} -libc = "0.2" - -[build-dependencies] -cbindgen = { version = "0.27", default-features = false } -fs_extra = "1" -metatensor = "0.2" - -[dev-dependencies] -which = "5" - -[lints.rust] -unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin)'] } diff --git a/featomic-c-api/build.rs b/featomic-c-api/build.rs deleted file mode 100644 index 24acbcad6..000000000 --- a/featomic-c-api/build.rs +++ /dev/null @@ -1,45 +0,0 @@ -#![allow(clippy::field_reassign_with_default)] - -use std::path::PathBuf; - -fn main() { - let crate_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap(); - - let generated_comment = "\ -/* ============ Automatically generated file, DOT NOT EDIT. ============ * - * * - * This file is automatically generated from the featomic-c-api sources, * - * using cbindgen. If you want to make change to this file (including * - * documentation), make the corresponding changes in the rust sources. * - * =========================================================================== */"; - - let mut config: cbindgen::Config = Default::default(); - config.language = cbindgen::Language::C; - config.cpp_compat = true; - config.includes = vec!["metatensor.h".into()]; - config.include_guard = Some("FEATOMIC_H".into()); - config.include_version = false; - config.documentation = true; - config.documentation_style = cbindgen::DocumentationStyle::Doxy; - config.header = Some(generated_comment.into()); - - let result = cbindgen::Builder::new() - .with_crate(crate_dir) - .with_config(config) - .generate() - .map(|data| { - let mut path = PathBuf::from("include"); - path.push("featomic.h"); - data.write_to_file(&path); - }); - - if result.is_ok() { - println!("cargo:rerun-if-changed=src"); - } else { - // if featomic header generation failed, we always re-run the build script - } - - println!( - "cargo:rustc-env=TARGET={}", std::env::var("TARGET").expect("missing TARGET env variable") - ); -} diff --git a/featomic-torch/tests/CMakeLists.txt b/featomic-torch/tests/CMakeLists.txt index 135e44681..b0d9c11b9 100644 --- a/featomic-torch/tests/CMakeLists.txt +++ b/featomic-torch/tests/CMakeLists.txt @@ -1,5 +1,5 @@ -# re-use catch from featomic-c-api C++ tests -add_subdirectory(../../featomic-c-api/tests/catch catch) +# re-use catch from featomic C++ tests +add_subdirectory(../../featomic/tests/utils/catch catch) # make sure we compile catch with the flags that torch requires. In particular, # torch sets -D_GLIBCXX_USE_CXX11_ABI=0 on Linux, which changes some of the diff --git a/featomic-torch/tests/utils/mod.rs b/featomic-torch/tests/utils/mod.rs index abe79e8ff..8924e3b3e 100644 --- a/featomic-torch/tests/utils/mod.rs +++ b/featomic-torch/tests/utils/mod.rs @@ -7,7 +7,7 @@ use std::path::PathBuf; use std::process::Command; -#[path = "../../../featomic-c-api/tests/utils/mod.rs"] +#[path = "../../../featomic/tests/utils/mod.rs"] mod core_utils; pub use core_utils::cmake_build; @@ -114,7 +114,7 @@ pub fn setup_pytorch(build_dir: PathBuf) -> PathBuf { /// Build featomic in `build_dir`, and return the installation prefix pub fn setup_featomic(build_dir: PathBuf) -> PathBuf { let mut featomic_source_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap()); - featomic_source_dir.extend(["..", "featomic-c-api"]); + featomic_source_dir.extend(["..", "featomic"]); // configure cmake for featomic let mut cmake_config = cmake_config(&featomic_source_dir, &build_dir); diff --git a/featomic-c-api/CMakeLists.txt b/featomic/CMakeLists.txt similarity index 95% rename from featomic-c-api/CMakeLists.txt rename to featomic/CMakeLists.txt index c51f7826a..c8888715f 100644 --- a/featomic-c-api/CMakeLists.txt +++ b/featomic/CMakeLists.txt @@ -132,6 +132,7 @@ endif() set(CARGO_TARGET_DIR ${CMAKE_CURRENT_BINARY_DIR}/target) set(CARGO_BUILD_ARG "${CARGO_BUILD_ARG};--target-dir=${CARGO_TARGET_DIR}") +set(CARGO_BUILD_ARG "${CARGO_BUILD_ARG};--features=c-api") # Handle cross compilation with RUST_BUILD_TARGET if ("${RUST_BUILD_TARGET}" STREQUAL "") @@ -303,13 +304,26 @@ if (NOT "$ENV{RUSTC_WRAPPER}" STREQUAL "") list(APPEND CARGO_ENV "RUSTC_WRAPPER=$ENV{RUSTC_WRAPPER}") endif() +if (FEATOMIC_INSTALL_BOTH_STATIC_SHARED) + set(CARGO_BUILD_ARG "${CARGO_BUILD_ARG};--crate-type=cdylib;--crate-type=staticlib") + set(FILES_CREATED_BY_CARGO "${FEATOMIC_SHARED_LIB_NAME} and ${FEATOMIC_STATIC_LIB_NAME}") +else() + if (BUILD_SHARED_LIBS) + set(CARGO_BUILD_ARG "${CARGO_BUILD_ARG};--crate-type=cdylib") + set(FILES_CREATED_BY_CARGO "${FEATOMIC_SHARED_LIB_NAME}") + else() + set(CARGO_BUILD_ARG "${CARGO_BUILD_ARG};--crate-type=staticlib") + set(FILES_CREATED_BY_CARGO "${FEATOMIC_STATIC_LIB_NAME}") + endif() +endif() + add_custom_target(cargo-build-featomic ALL COMMAND ${CMAKE_COMMAND} -E env ${CARGO_ENV} cargo rustc ${CARGO_BUILD_ARG} -- ${CARGO_RUSTC_ARGS} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} DEPENDS ${ALL_RUST_SOURCES} - COMMENT "Building ${FEATOMIC_SHARED_LIB_NAME} and ${FEATOMIC_STATIC_LIB_NAME} with cargo" + COMMENT "Building ${FILES_CREATED_BY_CARGO} with cargo" BYPRODUCTS ${FEATOMIC_STATIC_LOCATION} ${FEATOMIC_SHARED_LOCATION} ${FEATOMIC_IMPLIB_LOCATION} ) diff --git a/featomic/Cargo.toml b/featomic/Cargo.toml index 6892c1dc2..14f0e6a3f 100644 --- a/featomic/Cargo.toml +++ b/featomic/Cargo.toml @@ -8,6 +8,16 @@ rust-version = "1.74" [lib] bench = false +[features] +default = [] +# Include the code for the featomic C API +c-api = ["time-graph/table", "time-graph/json", "log/std"] +# use a static library for metatensor instead of a shared one +metatensor-static = ["metatensor/static"] + +[package.metadata."docs.rs"] +all-features = true + [dependencies] metatensor = {version = "0.2", features = ["rayon"]} @@ -29,9 +39,14 @@ chemfiles = {version = "0.10", optional = true} approx = "0.5" +[build-dependencies] +cbindgen = { version = "0.27", default-features = false } +fs_extra = "1" +metatensor = "0.2" + [dev-dependencies] criterion = "0.5" - +which = "5" glob = "0.3" ndarray-npy = "0.9" flate2 = "1.0.20" @@ -64,3 +79,7 @@ required-features = ["chemfiles"] [[example]] name = "profiling" required-features = ["chemfiles"] + + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin)'] } diff --git a/featomic/build.rs b/featomic/build.rs new file mode 100644 index 000000000..355ffd84b --- /dev/null +++ b/featomic/build.rs @@ -0,0 +1,48 @@ +#![allow(clippy::field_reassign_with_default)] + +use std::path::PathBuf; + +fn main() { + if cfg!(feature = "c-api") { + let crate_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap(); + + let generated_comment = "\ +/* ============ Automatically generated file, DOT NOT EDIT. ============ * + * * + * This file is automatically generated from the featomic sources, * + * using cbindgen. If you want to make change to this file (including * + * documentation), make the corresponding changes in the rust sources * + * in `featomic/src/c_api/*.rs` * + * =========================================================================== */"; + + let mut config: cbindgen::Config = Default::default(); + config.language = cbindgen::Language::C; + config.cpp_compat = true; + config.includes = vec!["metatensor.h".into()]; + config.include_guard = Some("FEATOMIC_H".into()); + config.include_version = false; + config.documentation = true; + config.documentation_style = cbindgen::DocumentationStyle::Doxy; + config.header = Some(generated_comment.into()); + + let result = cbindgen::Builder::new() + .with_crate(crate_dir) + .with_config(config) + .generate() + .map(|data| { + let mut path = PathBuf::from("include"); + path.push("featomic.h"); + data.write_to_file(&path); + }); + + if result.is_ok() { + println!("cargo:rerun-if-changed=src/c_api"); + } else { + // if featomic header generation failed, we always re-run the build script + } + } + + println!( + "cargo:rustc-env=TARGET={}", std::env::var("TARGET").expect("missing TARGET env variable") + ); +} diff --git a/featomic-c-api/cmake/featomic-config-version.in.cmake b/featomic/cmake/featomic-config-version.in.cmake similarity index 100% rename from featomic-c-api/cmake/featomic-config-version.in.cmake rename to featomic/cmake/featomic-config-version.in.cmake diff --git a/featomic-c-api/cmake/featomic-config.in.cmake b/featomic/cmake/featomic-config.in.cmake similarity index 100% rename from featomic-c-api/cmake/featomic-config.in.cmake rename to featomic/cmake/featomic-config.in.cmake diff --git a/featomic-c-api/cmake/tempdir.cmake b/featomic/cmake/tempdir.cmake similarity index 100% rename from featomic-c-api/cmake/tempdir.cmake rename to featomic/cmake/tempdir.cmake diff --git a/featomic-c-api/examples/common/systems.c b/featomic/examples/common/systems.c similarity index 100% rename from featomic-c-api/examples/common/systems.c rename to featomic/examples/common/systems.c diff --git a/featomic-c-api/examples/common/systems.h b/featomic/examples/common/systems.h similarity index 100% rename from featomic-c-api/examples/common/systems.h rename to featomic/examples/common/systems.h diff --git a/featomic-c-api/examples/compute-soap.c b/featomic/examples/compute-soap.c similarity index 100% rename from featomic-c-api/examples/compute-soap.c rename to featomic/examples/compute-soap.c diff --git a/featomic-c-api/examples/compute-soap.cpp b/featomic/examples/compute-soap.cpp similarity index 100% rename from featomic-c-api/examples/compute-soap.cpp rename to featomic/examples/compute-soap.cpp diff --git a/featomic-c-api/examples/profiling.c b/featomic/examples/profiling.c similarity index 100% rename from featomic-c-api/examples/profiling.c rename to featomic/examples/profiling.c diff --git a/featomic-c-api/examples/profiling.cpp b/featomic/examples/profiling.cpp similarity index 100% rename from featomic-c-api/examples/profiling.cpp rename to featomic/examples/profiling.cpp diff --git a/featomic-c-api/include/featomic.h b/featomic/include/featomic.h similarity index 98% rename from featomic-c-api/include/featomic.h rename to featomic/include/featomic.h index e529ca03a..19c525f19 100644 --- a/featomic-c-api/include/featomic.h +++ b/featomic/include/featomic.h @@ -1,6 +1,6 @@ /* ============ Automatically generated file, DOT NOT EDIT. ============ * * * - * This file is automatically generated from the featomic-c-api sources, * + * This file is automatically generated from the featomic sources, * * using cbindgen. If you want to make change to this file (including * * documentation), make the corresponding changes in the rust sources. * * =========================================================================== */ @@ -14,6 +14,26 @@ #include #include "metatensor.h" +/** + * Euler's constant + */ +#define EULER 0.5772156649015329 + +/** + * Constant value for `ln(pi)` + */ +#define LN_PI 1.1447298858494002 + +/** + * Constant value for `2 * sqrt(e / pi)` + */ +#define TWO_SQRT_E_OVER_PI 1.8603827342052657 + +/** + * Constant value for `ln(2 * sqrt(e / pi))` + */ +#define LN_2_SQRT_E_OVER_PI 0.6207822376352452 + /** * Status code used when a function succeeded */ diff --git a/featomic-c-api/include/featomic.hpp b/featomic/include/featomic.hpp similarity index 100% rename from featomic-c-api/include/featomic.hpp rename to featomic/include/featomic.hpp diff --git a/featomic-c-api/src/calculator.rs b/featomic/src/c_api/calculator.rs similarity index 95% rename from featomic-c-api/src/calculator.rs rename to featomic/src/c_api/calculator.rs index f98418bee..8ad614310 100644 --- a/featomic-c-api/src/calculator.rs +++ b/featomic/src/c_api/calculator.rs @@ -4,7 +4,8 @@ use std::ops::{Deref, DerefMut}; use metatensor::{Labels, TensorMap}; use metatensor::c_api::{mts_tensormap_t, mts_labels_t}; -use featomic::{Calculator, System, CalculationOptions, LabelsSelection}; + +use crate::{CalculationOptions, Calculator, Error, LabelsSelection, System}; use super::utils::copy_str_to_c; use super::{catch_unwind, featomic_status_t}; @@ -212,7 +213,7 @@ pub struct featomic_labels_selection_t { predefined: *const mts_tensormap_t, } -fn c_labels_to_rust(mut labels: mts_labels_t) -> Result { +fn c_labels_to_rust(mut labels: mts_labels_t) -> Result { if labels.internal_ptr_.is_null() { // create new metatensor-core labels unsafe { @@ -222,29 +223,29 @@ fn c_labels_to_rust(mut labels: mts_labels_t) -> Result( selection: &'a featomic_labels_selection_t, labels: &'a mut Option, predefined: &'a mut Option, -) -> Result, featomic::Error> { +) -> Result, Error> { match (selection.subset.is_null(), selection.predefined.is_null()) { (true, true) => Ok(LabelsSelection::All), (false, true) => { @@ -269,21 +270,21 @@ fn convert_labels_selection<'a>( Err(e) => { // same as above let _ = TensorMap::into_raw(tensor); - return Err(featomic::Error::from(e)); + return Err(Error::from(e)); } } Ok(LabelsSelection::Predefined(predefined.as_ref().expect("just created it"))) } (false, false) => { - Err(featomic::Error::InvalidParameter( + Err(Error::InvalidParameter( "can not have both global and predefined non-NULL in featomic_labels_selection_t".into() )) } } } -fn key_selection(value: *const mts_labels_t, labels: &'_ mut Option) -> Result, featomic::Error> { +fn key_selection(value: *const mts_labels_t, labels: &'_ mut Option) -> Result, Error> { if value.is_null() { return Ok(None); } diff --git a/featomic-c-api/src/logging.rs b/featomic/src/c_api/logging.rs similarity index 98% rename from featomic-c-api/src/logging.rs rename to featomic/src/c_api/logging.rs index 978b18c2d..f2d0aac23 100644 --- a/featomic-c-api/src/logging.rs +++ b/featomic/src/c_api/logging.rs @@ -4,7 +4,7 @@ use std::sync::Mutex; use log::{Record, Metadata}; use once_cell::sync::Lazy; -use crate::status::{featomic_status_t, catch_unwind}; +use super::status::{featomic_status_t, catch_unwind}; /// The "error" level designates very serious errors pub const FEATOMIC_LOG_LEVEL_ERROR: i32 = 1; diff --git a/featomic-c-api/src/lib.rs b/featomic/src/c_api/mod.rs similarity index 61% rename from featomic-c-api/src/lib.rs rename to featomic/src/c_api/mod.rs index 8ecf61738..cf74e480e 100644 --- a/featomic-c-api/src/lib.rs +++ b/featomic/src/c_api/mod.rs @@ -1,10 +1,4 @@ -#![warn(clippy::all, clippy::pedantic)] - -// disable some style lints -#![allow(clippy::needless_return, clippy::redundant_field_names, clippy::upper_case_acronyms)] -#![allow(clippy::missing_errors_doc, clippy::missing_safety_doc, clippy::missing_panics_doc)] -#![allow(clippy::must_use_candidate, clippy::uninlined_format_args, clippy::redundant_else)] -#![allow(clippy::let_underscore_untyped, clippy::doc_markdown)] +#![allow(clippy::missing_safety_doc, clippy::doc_markdown)] mod utils; #[macro_use] diff --git a/featomic-c-api/src/profiling.rs b/featomic/src/c_api/profiling.rs similarity index 92% rename from featomic-c-api/src/profiling.rs rename to featomic/src/c_api/profiling.rs index f7931f616..4bd9b3c7a 100644 --- a/featomic-c-api/src/profiling.rs +++ b/featomic/src/c_api/profiling.rs @@ -1,10 +1,10 @@ use std::os::raw::c_char; use std::ffi::CStr; -use featomic::Error; +use crate::Error; -use crate::{catch_unwind, featomic_status_t}; -use crate::utils::copy_str_to_c; +use super::{catch_unwind, featomic_status_t}; +use super::utils::copy_str_to_c; /// Clear all collected profiling data /// @@ -14,7 +14,7 @@ use crate::utils::copy_str_to_c; /// `FEATOMIC_SUCCESS`, you can use `featomic_last_error()` to get the full /// error message. #[no_mangle] -pub unsafe extern fn featomic_profiling_clear() -> featomic_status_t { +pub extern fn featomic_profiling_clear() -> featomic_status_t { catch_unwind(|| { time_graph::clear_collected_data(); Ok(()) @@ -39,7 +39,7 @@ pub unsafe extern fn featomic_profiling_clear() -> featomic_status_t { /// `FEATOMIC_SUCCESS`, you can use `featomic_last_error()` to get the full /// error message. #[no_mangle] -pub unsafe extern fn featomic_profiling_enable(enabled: bool) -> featomic_status_t { +pub extern fn featomic_profiling_enable(enabled: bool) -> featomic_status_t { catch_unwind(|| { time_graph::enable_data_collection(enabled); Ok(()) diff --git a/featomic-c-api/src/status.rs b/featomic/src/c_api/status.rs similarity index 98% rename from featomic-c-api/src/status.rs rename to featomic/src/c_api/status.rs index c47a144ba..7a1c318f0 100644 --- a/featomic-c-api/src/status.rs +++ b/featomic/src/c_api/status.rs @@ -3,7 +3,7 @@ use std::cell::RefCell; use std::os::raw::c_char; use std::ffi::CString; -use featomic::Error; +use crate::Error; // Save the last error message in thread local storage. // @@ -92,7 +92,7 @@ pub fn catch_unwind(function: F) -> featomic_status_t where F: FnOnce() -> Re macro_rules! check_pointers { ($pointer: ident) => { if $pointer.is_null() { - return Err(featomic::Error::InvalidParameter( + return Err($crate::Error::InvalidParameter( format!( "got invalid NULL pointer for {} at {}:{}", stringify!($pointer), file!(), line!() diff --git a/featomic-c-api/src/system.rs b/featomic/src/c_api/system.rs similarity index 94% rename from featomic-c-api/src/system.rs rename to featomic/src/c_api/system.rs index ecc0532c1..162133258 100644 --- a/featomic-c-api/src/system.rs +++ b/featomic/src/c_api/system.rs @@ -1,10 +1,10 @@ use std::os::raw::c_void; -use featomic::types::{Vector3D, Matrix3}; -use featomic::systems::{SimpleSystem, Pair, UnitCell}; -use featomic::{Error, System}; +use crate::types::{Vector3D, Matrix3}; +use crate::systems::{SimpleSystem, Pair, UnitCell}; +use crate::{Error, System}; -use crate::FEATOMIC_SYSTEM_ERROR; +use super::FEATOMIC_SYSTEM_ERROR; use super::{catch_unwind, featomic_status_t}; @@ -160,10 +160,10 @@ impl<'a> System for &'a mut featomic_system_t { if size == 0 { return Ok(&[]) - } else { - unsafe { - return Ok(std::slice::from_raw_parts(ptr, self.size()?)); - } + } + + unsafe { + return Ok(std::slice::from_raw_parts(ptr, self.size()?)); } } @@ -194,10 +194,10 @@ impl<'a> System for &'a mut featomic_system_t { if size == 0 { return Ok(&[]) - } else { - unsafe { - return Ok(std::slice::from_raw_parts(ptr.cast(), self.size()?)); - } + } + + unsafe { + return Ok(std::slice::from_raw_parts(ptr.cast(), self.size()?)); } } @@ -272,11 +272,11 @@ impl<'a> System for &'a mut featomic_system_t { if count == 0 { return Ok(&[]) - } else { - unsafe { - // SAFETY: ptr is non null, and Pair / featomic_pair_t have the same layout - return Ok(std::slice::from_raw_parts(ptr.cast(), count)); - } + } + + unsafe { + // SAFETY: ptr is non null, and Pair / featomic_pair_t have the same layout + return Ok(std::slice::from_raw_parts(ptr.cast(), count)); } } @@ -308,11 +308,11 @@ impl<'a> System for &'a mut featomic_system_t { if count == 0 { return Ok(&[]) - } else { - unsafe { - // SAFETY: ptr is non null, and Pair / featomic_pair_t have the same layout - return Ok(std::slice::from_raw_parts(ptr.cast(), count)); - } + } + + unsafe { + // SAFETY: ptr is non null, and Pair / featomic_pair_t have the same layout + return Ok(std::slice::from_raw_parts(ptr.cast(), count)); } } } diff --git a/featomic-c-api/src/utils.rs b/featomic/src/c_api/utils.rs similarity index 96% rename from featomic-c-api/src/utils.rs rename to featomic/src/c_api/utils.rs index ec9f747d5..2987e7ef4 100644 --- a/featomic-c-api/src/utils.rs +++ b/featomic/src/c_api/utils.rs @@ -1,6 +1,6 @@ use std::os::raw::c_char; -use featomic::Error; +use crate::Error; pub unsafe fn copy_str_to_c(string: &str, buffer: *mut c_char, buflen: usize) -> Result<(), Error> { let size = std::cmp::min(string.len(), buflen - 1); diff --git a/featomic/src/lib.rs b/featomic/src/lib.rs index 41acd16dc..c97cb375e 100644 --- a/featomic/src/lib.rs +++ b/featomic/src/lib.rs @@ -20,6 +20,9 @@ pub use types::*; pub mod math; +#[cfg(feature="c-api")] +pub mod c_api; + mod errors; pub use self::errors::Error; diff --git a/featomic-c-api/tests/CMakeLists.txt b/featomic/tests/CMakeLists.txt similarity index 78% rename from featomic-c-api/tests/CMakeLists.txt rename to featomic/tests/CMakeLists.txt index d42cf292e..eeea3c98c 100644 --- a/featomic-c-api/tests/CMakeLists.txt +++ b/featomic/tests/CMakeLists.txt @@ -86,9 +86,10 @@ get_target_property(METATENSOR_LOCATION metatensor::shared IMPORTED_LOCATION) get_filename_component(METATENSOR_DIRECTORY "${METATENSOR_LOCATION}" DIRECTORY) set(CMAKE_BUILD_RPATH "${FEATOMIC_DIRECTORY};${METATENSOR_DIRECTORY}") -add_subdirectory(catch) +add_subdirectory(utils/catch) -add_library(tests_helpers STATIC helpers.cpp) +add_library(tests_helpers STATIC utils/helpers.cpp) +target_include_directories(tests_helpers PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/utils/) target_link_libraries(tests_helpers featomic::shared) @@ -106,48 +107,13 @@ else() set(TEST_COMMAND "") endif() -file(GLOB ALL_TESTS *.cpp) -list(REMOVE_ITEM ALL_TESTS "${CMAKE_CURRENT_SOURCE_DIR}/helpers.cpp") - # on windows, shared libraries are found in the PATH. This plays a similar role # to `CMAKE_BUILD_RPATH` above string(REPLACE ";" "\\;" PATH_STRING "$ENV{PATH}") set(WINDOWS_TEST_PATH "${PATH_STRING}\;${METATENSOR_DIRECTORY}\;${FEATOMIC_DIRECTORY}") -enable_testing() -foreach(_file_ ${ALL_TESTS}) - get_filename_component(_name_ ${_file_} NAME_WE) - add_executable(${_name_} ${_file_}) - target_link_libraries(${_name_} featomic::shared catch tests_helpers chemfiles) - add_test( - NAME ${_name_} - COMMAND ${TEST_COMMAND} $ - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - ) - - if(WIN32) - set_tests_properties(${_name_} PROPERTIES ENVIRONMENT "PATH=${WINDOWS_TEST_PATH}") - endif() -endforeach() - -# make sure example compile and run set(XYZ_EXAMPLE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../../featomic/examples/data/water.xyz) -file(GLOB EXAMPLES ../examples/*.c) -foreach(_file_ ${EXAMPLES}) - get_filename_component(_name_ ${_file_} NAME_WE) - set(_name_ example-c-${_name_}) - add_executable(${_name_} ${_file_}) - target_link_libraries(${_name_} featomic::shared chemfiles) - - add_test( - NAME ${_name_} - COMMAND ${TEST_COMMAND} $ ${XYZ_EXAMPLE_FILE} - ) - - if(WIN32) - set_tests_properties(${_name_} PROPERTIES ENVIRONMENT "PATH=${WINDOWS_TEST_PATH}") - endif() -endforeach() - +enable_testing() +add_subdirectory(c) add_subdirectory(cxx) diff --git a/featomic/tests/c/CMakeLists.txt b/featomic/tests/c/CMakeLists.txt new file mode 100644 index 000000000..45f62be91 --- /dev/null +++ b/featomic/tests/c/CMakeLists.txt @@ -0,0 +1,34 @@ +file(GLOB ALL_TESTS *.cpp) + +foreach(_file_ ${ALL_TESTS}) + get_filename_component(_name_ ${_file_} NAME_WE) + set(_name_ c-${_name_}) + add_executable(${_name_} ${_file_}) + target_link_libraries(${_name_} featomic::shared tests_helpers catch) + add_test( + NAME ${_name_} + COMMAND ${TEST_COMMAND} $ + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) + + if(WIN32) + set_tests_properties(${_name_} PROPERTIES ENVIRONMENT "PATH=${WINDOWS_TEST_PATH}") + endif() +endforeach() + +file(GLOB EXAMPLES ../../examples/*.c) +foreach(_file_ ${EXAMPLES}) + get_filename_component(_name_ ${_file_} NAME_WE) + set(_name_ example-c-${_name_}) + add_executable(${_name_} ${_file_}) + target_link_libraries(${_name_} featomic::shared chemfiles) + + add_test( + NAME ${_name_} + COMMAND ${TEST_COMMAND} $ ${XYZ_EXAMPLE_FILE} + ) + + if(WIN32) + set_tests_properties(${_name_} PROPERTIES ENVIRONMENT "PATH=${WINDOWS_TEST_PATH}") + endif() +endforeach() diff --git a/featomic-c-api/tests/calculator.cpp b/featomic/tests/c/calculator.cpp similarity index 100% rename from featomic-c-api/tests/calculator.cpp rename to featomic/tests/c/calculator.cpp diff --git a/featomic-c-api/tests/logging.cpp b/featomic/tests/c/logging.cpp similarity index 100% rename from featomic-c-api/tests/logging.cpp rename to featomic/tests/c/logging.cpp diff --git a/featomic-c-api/tests/systems.cpp b/featomic/tests/c/systems.cpp similarity index 100% rename from featomic-c-api/tests/systems.cpp rename to featomic/tests/c/systems.cpp diff --git a/featomic-c-api/tests/check-cxx-install.rs b/featomic/tests/check-cxx-install.rs similarity index 100% rename from featomic-c-api/tests/check-cxx-install.rs rename to featomic/tests/check-cxx-install.rs diff --git a/featomic-c-api/tests/cmake-project/CMakeLists.txt b/featomic/tests/cmake-project/CMakeLists.txt similarity index 100% rename from featomic-c-api/tests/cmake-project/CMakeLists.txt rename to featomic/tests/cmake-project/CMakeLists.txt diff --git a/featomic-c-api/tests/cmake-project/README.md b/featomic/tests/cmake-project/README.md similarity index 100% rename from featomic-c-api/tests/cmake-project/README.md rename to featomic/tests/cmake-project/README.md diff --git a/featomic-c-api/tests/cmake-project/src/main.c b/featomic/tests/cmake-project/src/main.c similarity index 100% rename from featomic-c-api/tests/cmake-project/src/main.c rename to featomic/tests/cmake-project/src/main.c diff --git a/featomic-c-api/tests/cmake-project/src/main.cpp b/featomic/tests/cmake-project/src/main.cpp similarity index 100% rename from featomic-c-api/tests/cmake-project/src/main.cpp rename to featomic/tests/cmake-project/src/main.cpp diff --git a/featomic-c-api/tests/cxx/CMakeLists.txt b/featomic/tests/cxx/CMakeLists.txt similarity index 100% rename from featomic-c-api/tests/cxx/CMakeLists.txt rename to featomic/tests/cxx/CMakeLists.txt diff --git a/featomic-c-api/tests/cxx/calculator.cpp b/featomic/tests/cxx/calculator.cpp similarity index 100% rename from featomic-c-api/tests/cxx/calculator.cpp rename to featomic/tests/cxx/calculator.cpp diff --git a/featomic-c-api/tests/cxx/systems.cpp b/featomic/tests/cxx/systems.cpp similarity index 100% rename from featomic-c-api/tests/cxx/systems.cpp rename to featomic/tests/cxx/systems.cpp diff --git a/featomic-c-api/tests/cxx/test_system.hpp b/featomic/tests/cxx/test_system.hpp similarity index 100% rename from featomic-c-api/tests/cxx/test_system.hpp rename to featomic/tests/cxx/test_system.hpp diff --git a/featomic-c-api/tests/run-cxx-tests.rs b/featomic/tests/run-cxx-tests.rs similarity index 100% rename from featomic-c-api/tests/run-cxx-tests.rs rename to featomic/tests/run-cxx-tests.rs diff --git a/featomic-c-api/tests/catch/.gitattributes b/featomic/tests/utils/catch/.gitattributes similarity index 100% rename from featomic-c-api/tests/catch/.gitattributes rename to featomic/tests/utils/catch/.gitattributes diff --git a/featomic-c-api/tests/catch/CMakeLists.txt b/featomic/tests/utils/catch/CMakeLists.txt similarity index 100% rename from featomic-c-api/tests/catch/CMakeLists.txt rename to featomic/tests/utils/catch/CMakeLists.txt diff --git a/featomic-c-api/tests/catch/catch.cpp b/featomic/tests/utils/catch/catch.cpp similarity index 100% rename from featomic-c-api/tests/catch/catch.cpp rename to featomic/tests/utils/catch/catch.cpp diff --git a/featomic-c-api/tests/catch/catch.hpp b/featomic/tests/utils/catch/catch.hpp similarity index 100% rename from featomic-c-api/tests/catch/catch.hpp rename to featomic/tests/utils/catch/catch.hpp diff --git a/featomic-c-api/tests/helpers.cpp b/featomic/tests/utils/helpers.cpp similarity index 100% rename from featomic-c-api/tests/helpers.cpp rename to featomic/tests/utils/helpers.cpp diff --git a/featomic-c-api/tests/helpers.hpp b/featomic/tests/utils/helpers.hpp similarity index 100% rename from featomic-c-api/tests/helpers.hpp rename to featomic/tests/utils/helpers.hpp diff --git a/featomic-c-api/tests/utils/mod.rs b/featomic/tests/utils/mod.rs similarity index 100% rename from featomic-c-api/tests/utils/mod.rs rename to featomic/tests/utils/mod.rs diff --git a/featomic-c-api/tests/valgrind.supp b/featomic/tests/utils/valgrind.supp similarity index 100% rename from featomic-c-api/tests/valgrind.supp rename to featomic/tests/utils/valgrind.supp diff --git a/python/featomic-torch/build-backend/backend.py b/python/featomic-torch/build-backend/backend.py index 75d2c614f..42a8267ae 100644 --- a/python/featomic-torch/build-backend/backend.py +++ b/python/featomic-torch/build-backend/backend.py @@ -8,14 +8,14 @@ ROOT = os.path.realpath(os.path.dirname(__file__)) -FEATOMIC = os.path.realpath(os.path.join(ROOT, "..", "..", "..")) -if os.path.exists(os.path.join(FEATOMIC, "featomic-c-api")): +FEATOMIC_SRC = os.path.realpath(os.path.join(ROOT, "..", "..", "..")) +if os.path.exists(os.path.join(FEATOMIC_SRC, "featomic")): # we are building from a git checkout # add a random uuid to the file url to prevent pip from using a cached # wheel for metatensor-core, and force it to re-build from scratch uuid = uuid.uuid4() - FEATOMIC_DEP = f"featomic @ file://{FEATOMIC}?{uuid}" + FEATOMIC_DEP = f"featomic @ file://{FEATOMIC_SRC}?{uuid}" else: # we are building from a sdist FEATOMIC_DEP = "featomic >=0.1.0.dev0,<0.2.0" diff --git a/python/featomic-torch/setup.py b/python/featomic-torch/setup.py index ce15fb2eb..25a673182 100644 --- a/python/featomic-torch/setup.py +++ b/python/featomic-torch/setup.py @@ -11,10 +11,10 @@ ROOT = os.path.realpath(os.path.dirname(__file__)) -FEATOMIC_C_API = os.path.join(ROOT, "..", "..", "featomic-c-api") +FEATOMIC_SRC = os.path.join(ROOT, "..", "..", "featomic") -FEATOMIC_TORCH = os.path.join(ROOT, "..", "..", "featomic-torch") -if not os.path.exists(FEATOMIC_TORCH): +FEATOMIC_TORCH_SRC = os.path.join(ROOT, "..", "..", "featomic-torch") +if not os.path.exists(FEATOMIC_TORCH_SRC): # we are building from a sdist, which should include metatensor-torch # sources as a tarball cxx_sources = os.path.join(ROOT, "featomic-torch.tar.gz") @@ -31,7 +31,7 @@ check=True, ) - FEATOMIC_TORCH = os.path.join(ROOT, "featomic-torch") + FEATOMIC_TORCH_SRC = os.path.join(ROOT, "featomic-torch") class cmake_ext(build_ext): @@ -44,7 +44,7 @@ def run(self): import featomic - source_dir = FEATOMIC_TORCH + source_dir = FEATOMIC_TORCH_SRC build_dir = os.path.join(ROOT, "build", "cmake-build") install_dir = os.path.join(os.path.realpath(self.build_lib), "featomic/torch") @@ -229,7 +229,7 @@ def git_extra_version(): else: extra_version = git_extra_version() - with open(os.path.join(FEATOMIC_TORCH, "VERSION")) as fd: + with open(os.path.join(FEATOMIC_TORCH_SRC, "VERSION")) as fd: version = fd.read().strip() version += extra_version @@ -245,7 +245,7 @@ def git_extra_version(): "torch >= 1.12", "metatensor-torch >=0.6.0,<0.7.0", ] - if os.path.exists(FEATOMIC_C_API): + if os.path.exists(FEATOMIC_SRC): # we are building from a git checkout featomic_path = os.path.realpath(os.path.join(ROOT, "..", "..")) diff --git a/python/scripts/generate-declarations.py b/python/scripts/generate-declarations.py index 61c251471..22f19da7d 100755 --- a/python/scripts/generate-declarations.py +++ b/python/scripts/generate-declarations.py @@ -11,7 +11,7 @@ metatensor.utils.cmake_prefix_path, "..", "..", "include" ) FEATOMIC_HEADER = os.path.relpath( - os.path.join(ROOT, "..", "..", "featomic-c-api", "include", "featomic.h") + os.path.join(ROOT, "..", "..", "featomic", "include", "featomic.h") ) diff --git a/setup.py b/setup.py index af66192e3..e99b08903 100644 --- a/setup.py +++ b/setup.py @@ -46,7 +46,7 @@ class cmake_ext(build_ext): def run(self): """Run cmake build and install the resulting library.""" - source_dir = os.path.join(ROOT, "featomic-c-api") + source_dir = os.path.join(ROOT, "featomic") build_dir = os.path.join(ROOT, "build", "cmake-build") install_dir = os.path.join(os.path.realpath(self.build_lib), "featomic") @@ -162,7 +162,7 @@ def run(self): def get_rust_version(): # read version from Cargo.toml - with open(os.path.join(ROOT, "featomic-c-api", "Cargo.toml")) as fd: + with open(os.path.join(ROOT, "featomic", "Cargo.toml")) as fd: for line in fd: if line.startswith("version"): _, version = line.split(" = ")