Skip to content

Commit

Permalink
Fix access to rascaline-torch cmake_prefix_path from Python
Browse files Browse the repository at this point in the history
  • Loading branch information
Luthaf committed Nov 3, 2023
1 parent fca103e commit 2851d47
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 27 deletions.
21 changes: 0 additions & 21 deletions python/rascaline-torch/rascaline/torch/utils.py

This file was deleted.

9 changes: 9 additions & 0 deletions python/rascaline-torch/rascaline/torch/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import os

from .power_spectrum import PowerSpectrum


_HERE = os.path.dirname(__file__)

cmake_prefix_path = os.path.realpath(os.path.join(_HERE, "..", "lib", "cmake"))
"""
Path containing the CMake configuration files for the underlying C library
"""

__all__ = ["PowerSpectrum"]
2 changes: 2 additions & 0 deletions python/rascaline-torch/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class cmake_ext(build_ext):
"""Build the native library using cmake"""

def run(self):
import metatensor
import metatensor.torch
import torch

Expand All @@ -52,6 +53,7 @@ def run(self):
# Tell CMake where to find rascaline & torch
cmake_prefix_path = [
rascaline.utils.cmake_prefix_path,
metatensor.utils.cmake_prefix_path,
metatensor.torch.utils.cmake_prefix_path,
torch.utils.cmake_prefix_path,
]
Expand Down
7 changes: 7 additions & 0 deletions python/rascaline-torch/tests/utils/cmake_prefix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import os

import rascaline.torch


def test_cmake_prefix():
assert os.path.exists(rascaline.torch.utils.cmake_prefix_path)
8 changes: 2 additions & 6 deletions python/rascaline/rascaline/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import os

import metatensor

from .power_spectrum import PowerSpectrum # noqa
from .splines import ( # noqa
AtomicDensityBase,
Expand All @@ -19,11 +17,9 @@
)


# path that can be used with cmake to access the rascaline library and headers
_HERE = os.path.realpath(os.path.dirname(__file__))
_HERE = os.path.dirname(__file__)

_rascaline_cmake_prefix = os.path.realpath(os.path.join(_HERE, "..", "lib", "cmake"))
cmake_prefix_path = f"{_rascaline_cmake_prefix};{metatensor.utils.cmake_prefix_path}"
cmake_prefix_path = os.path.realpath(os.path.join(_HERE, "..", "lib", "cmake"))
"""
Path containing the CMake configuration files for the underlying C library
"""

0 comments on commit 2851d47

Please sign in to comment.