Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ jobs:
run: sudo apt install -y lcov

- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.6
uses: mozilla-actions/sccache-action@v0.0.9
with:
version: "v0.8.2"
version: "v0.10.0"

- name: Setup sccache environnement variables
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ jobs:
python -m pip install tox

- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.3
uses: mozilla-actions/sccache-action@v0.0.9
with:
version: "v0.5.4"
version: "v0.10.0"

- name: Setup sccache environnement variables
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/rust-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ jobs:
sudo apt-get install -y valgrind

- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.3
uses: mozilla-actions/sccache-action@v0.0.9
with:
version: "v0.5.4"
version: "v0.10.0"

- name: Setup sccache environnement variables
run: |
Expand Down Expand Up @@ -143,9 +143,9 @@ jobs:
toolchain: stable

- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.6
uses: mozilla-actions/sccache-action@v0.0.9
with:
version: "v0.8.2"
version: "v0.10.0"

- name: Setup sccache environnement variables
run: |
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/torch-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ concurrency:
jobs:
tests:
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} / Torch ${{ matrix.torch-version }}
name: ${{ matrix.os }} / Torch ${{ matrix.torch-version }}${{ matrix.extra-name }}
container: ${{ matrix.container }}
strategy:
matrix:
Expand All @@ -29,7 +29,7 @@ jobs:
cargo-test-flags: --release
do-valgrind: true

- os: ubuntu-20.04
- os: ubuntu-22.04
container: ubuntu:20.04
extra-name: ", cmake 3.16"
torch-version: "2.6"
Expand All @@ -53,7 +53,9 @@ jobs:
run: |
apt update
apt install -y software-properties-common
apt install -y cmake make gcc g++ git curl
add-apt-repository ppa:deadsnakes/ppa
apt install -y cmake make gcc g++ git curl python3.10 python3.10-venv
update-alternatives --install /usr/local/bin/python python /usr/bin/python3.10 1

- uses: actions/checkout@v4
with:
Expand All @@ -70,6 +72,7 @@ jobs:

# we get torch from pip to run the C++ test
- name: setup Python
if: matrix.container != 'ubuntu:20.04'
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
Expand All @@ -81,9 +84,9 @@ jobs:
sudo apt-get install -y valgrind

- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.6
uses: mozilla-actions/sccache-action@v0.0.9
with:
version: "v0.8.2"
version: "v0.10.0"

- name: Setup sccache environnement variables
run: |
Expand Down
2 changes: 1 addition & 1 deletion docs/featomic-json-schema/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ test = false

[dependencies]
featomic = {path = "../../featomic"}
schemars = "=1.0.0-alpha.15"
schemars = "=1.0.0-alpha.17"
serde_json = "1"
47 changes: 28 additions & 19 deletions docs/src/get-started/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,30 @@ Installation
============

You can install featomic in different ways depending on which language you plan
to use it from. In all cases you will need a Rust compiler, which you can
install using `rustup <https://rustup.rs/>`_ or your OS package manager.
to use it from.

.. _install-python-lib:

Installing the Python module
----------------------------

For building and using the Python package, clone the repository using `git
<https://git-scm.com>`_ and install featomic using `pip
<https://pip.pypa.io>`_.
Pre-compiled wheels
^^^^^^^^^^^^^^^^^^^

From source:
The easiest way to install featomic is to use `pip <https://pip.pypa.io>`_.

.. code-block:: bash

pip install --upgrade pip
pip install featomic


Building from source
^^^^^^^^^^^^^^^^^^^^

If you want to build the code from source, you'll need a Rust compiler, which
you can install using `rustup <https://rustup.rs/>`_ or your OS package manager;
and `git <https://git-scm.com>`_.

.. code-block:: bash

Expand All @@ -29,15 +40,6 @@ From source:
pip install git+https://github.com/metatensor/featomic


Featomic is also provided as prebuilt wheel which avoids the intermediate step
of building the package with a Rust compiler from the source code.

.. code-block:: bash

pip install --upgrade pip
pip install --extra-index-url https://luthaf.fr/nightly-wheels/ featomic


.. _install-c-lib:

Installing the C/C++ library
Expand Down Expand Up @@ -101,17 +103,24 @@ Installing the TorchScript bindings
For usage from Python
^^^^^^^^^^^^^^^^^^^^^

Building from source:
You can install the code with ``pip``:

.. code-block:: bash

pip install --upgrade pip
pip install featomic[torch]


You can also build the code from source

.. code-block:: bash

pip install --upgrade pip

git clone https://github.com/metatensor/featomic
cd featomic/python/featomic_torch
pip install .

# Make sure you are using the latest version of pip
pip install --upgrade pip

# alternatively, the same thing in a single command
pip install git+https://github.com/metatensor/featomic#subdirectory=python/featomic_torch

Expand Down
2 changes: 1 addition & 1 deletion featomic-torch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test = false
doctest = false

[dev-dependencies]
which = "5"
which = "7"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin)'] }
9 changes: 6 additions & 3 deletions featomic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,28 @@ time-graph = "0.3.0"

serde = { version = "1", features = ["derive"] }
serde_json = "1"
schemars = "=1.0.0-alpha.15"
schemars = "=1.0.0-alpha.17"

chemfiles = {version = "0.10", optional = true}

approx = "0.5"

[build-dependencies]
cbindgen = { version = "0.27", default-features = false }
cbindgen = { version = "0.28", default-features = false }
fs_extra = "1"
metatensor = "0.2"

[dev-dependencies]
criterion = "0.5"
which = "5"
which = "7"
glob = "0.3"
ndarray-npy = "0.9"
flate2 = "1.0.20"
time-graph = {version = "0.3.0", features = ["table", "json"]}

# Pin half to the last version supporting rustc 1.74
half = "=2.4.1"


[[bench]]
name = "spherical-harmonics"
Expand Down
2 changes: 1 addition & 1 deletion featomic/include/featomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ typedef struct featomic_pair_t {
* implement the rust `System` trait in C and other languages. Speaking in Rust
* terms, `user_data` contains a pointer (analog to `Box<Self>`) to the struct
* implementing the `System` trait; and then there is one function pointers
* (`Option<unsafe extern fn(XXX)>`) for each function in the `System` trait.
* (`Option<unsafe extern "C" fn(XXX)>`) for each function in the `System` trait.
*
* The `featomic_status_t` return value for the function is used to communicate
* error messages. It should be 0/`FEATOMIC_SUCCESS` in case of success, any
Expand Down
12 changes: 6 additions & 6 deletions featomic/src/c_api/calculator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl DerefMut for featomic_calculator_t {
/// to get the error message.
#[no_mangle]
#[allow(clippy::module_name_repetitions)]
pub unsafe extern fn featomic_calculator(name: *const c_char, parameters: *const c_char) -> *mut featomic_calculator_t {
pub unsafe extern "C" fn featomic_calculator(name: *const c_char, parameters: *const c_char) -> *mut featomic_calculator_t {
let mut raw = std::ptr::null_mut();
let unwind_wrapper = std::panic::AssertUnwindSafe(&mut raw);
let status = catch_unwind(move || {
Expand Down Expand Up @@ -84,7 +84,7 @@ pub unsafe extern fn featomic_calculator(name: *const c_char, parameters: *const
/// `FEATOMIC_SUCCESS`, you can use `featomic_last_error()` to get the
/// full error message.
#[no_mangle]
pub unsafe extern fn featomic_calculator_free(calculator: *mut featomic_calculator_t) -> featomic_status_t {
pub unsafe extern "C" fn featomic_calculator_free(calculator: *mut featomic_calculator_t) -> featomic_status_t {
catch_unwind(|| {
if !calculator.is_null() {
let boxed = Box::from_raw(calculator);
Expand All @@ -110,7 +110,7 @@ pub unsafe extern fn featomic_calculator_free(calculator: *mut featomic_calculat
/// `FEATOMIC_SUCCESS`, you can use `featomic_last_error()` to get the full
/// error message.
#[no_mangle]
pub unsafe extern fn featomic_calculator_name(
pub unsafe extern "C" fn featomic_calculator_name(
calculator: *const featomic_calculator_t,
name: *mut c_char,
bufflen: usize
Expand Down Expand Up @@ -138,7 +138,7 @@ pub unsafe extern fn featomic_calculator_name(
/// `FEATOMIC_SUCCESS`, you can use `featomic_last_error()` to get the full
/// error message.
#[no_mangle]
pub unsafe extern fn featomic_calculator_parameters(
pub unsafe extern "C" fn featomic_calculator_parameters(
calculator: *const featomic_calculator_t,
parameters: *mut c_char,
bufflen: usize
Expand Down Expand Up @@ -167,7 +167,7 @@ pub unsafe extern fn featomic_calculator_parameters(
/// `FEATOMIC_SUCCESS`, you can use `featomic_last_error()` to get the full
/// error message.
#[no_mangle]
pub unsafe extern fn featomic_calculator_cutoffs(
pub unsafe extern "C" fn featomic_calculator_cutoffs(
calculator: *const featomic_calculator_t,
cutoffs: *mut *const f64,
cutoffs_count: *mut usize
Expand Down Expand Up @@ -389,7 +389,7 @@ pub struct featomic_calculation_options_t {
/// `FEATOMIC_SUCCESS`, you can use `featomic_last_error()` to get the full
/// error message.
#[no_mangle]
pub unsafe extern fn featomic_calculator_compute(
pub unsafe extern "C" fn featomic_calculator_compute(
calculator: *mut featomic_calculator_t,
descriptor: *mut *mut mts_tensormap_t,
systems: *mut featomic_system_t,
Expand Down
4 changes: 2 additions & 2 deletions featomic/src/c_api/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub const FEATOMIC_LOG_LEVEL_TRACE: i32 = 5;
/// or `FEATOMIC_LOG_LEVEL_TRACE`. The second argument is a NULL-terminated string
/// containing the message associated with the log event.
#[allow(non_camel_case_types)]
pub type featomic_logging_callback_t = Option<unsafe extern fn(level: i32, message: *const std::os::raw::c_char)>;
pub type featomic_logging_callback_t = Option<unsafe extern "C" fn(level: i32, message: *const std::os::raw::c_char)>;

static GLOBAL_CALLBACK: Lazy<Mutex<featomic_logging_callback_t>> = Lazy::new(|| Mutex::new(None));

Expand All @@ -48,7 +48,7 @@ struct FeatomicLogger;
/// function will be called on all log events. If a logging callback was already
/// set, it is replaced by the new one.
#[no_mangle]
pub unsafe extern fn featomic_set_logging_callback(callback: featomic_logging_callback_t) -> featomic_status_t {
pub unsafe extern "C" fn featomic_set_logging_callback(callback: featomic_logging_callback_t) -> featomic_status_t {
catch_unwind(|| {
*GLOBAL_CALLBACK.lock().expect("mutex was poisoned") = callback;
// we allow multiple sets of logger, therefore the result will be ignored
Expand Down
6 changes: 3 additions & 3 deletions featomic/src/c_api/profiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use super::utils::copy_str_to_c;
/// `FEATOMIC_SUCCESS`, you can use `featomic_last_error()` to get the full
/// error message.
#[no_mangle]
pub extern fn featomic_profiling_clear() -> featomic_status_t {
pub extern "C" fn featomic_profiling_clear() -> featomic_status_t {
catch_unwind(|| {
time_graph::clear_collected_data();
Ok(())
Expand All @@ -39,7 +39,7 @@ pub 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 extern fn featomic_profiling_enable(enabled: bool) -> featomic_status_t {
pub extern "C" fn featomic_profiling_enable(enabled: bool) -> featomic_status_t {
catch_unwind(|| {
time_graph::enable_data_collection(enabled);
Ok(())
Expand All @@ -61,7 +61,7 @@ pub extern fn featomic_profiling_enable(enabled: bool) -> 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_get(
pub unsafe extern "C" fn featomic_profiling_get(
format: *const c_char,
buffer: *mut c_char,
bufflen: usize,
Expand Down
2 changes: 1 addition & 1 deletion featomic/src/c_api/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ macro_rules! check_pointers {
///
/// @returns the last error message, as a NULL-terminated string
#[no_mangle]
pub unsafe extern fn featomic_last_error() -> *const c_char {
pub unsafe extern "C" fn featomic_last_error() -> *const c_char {
let mut result = std::ptr::null();
let unwind_wrapper = std::panic::AssertUnwindSafe(&mut result);
let status = catch_unwind(move || {
Expand Down
Loading
Loading