metatensor-core 0.2.4__tar.gz → 0.2.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/CMakeLists.txt +1 -1
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/PKG-INFO +1 -1
- metatensor_core-0.2.5/git_version_info +2 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor/_c_lib.py +60 -13
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor/io/_block.py +3 -2
- metatensor_core-0.2.5/metatensor-core-cxx-0.2.5.tar.gz +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor_core.egg-info/PKG-INFO +1 -1
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor_core.egg-info/SOURCES.txt +1 -1
- metatensor_core-0.2.4/git_version_info +0 -2
- metatensor_core-0.2.4/metatensor-core-cxx-0.2.4.tar.gz +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/AUTHORS +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/LICENSE +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/MANIFEST.in +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/README.rst +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor/__init__.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor/_block.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor/_c_api.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor/_data/__init__.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor/_data/_array.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor/_data/_extract.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor/_html.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor/_labels.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor/_status.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor/_tensor.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor/_version.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor/io/__init__.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor/io/_labels.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor/io/_tensor.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor/io/_utils.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor/learn.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor/operations.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor/torch.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor/utils.py +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor_core.egg-info/dependency_links.txt +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor_core.egg-info/not-zip-safe +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor_core.egg-info/requires.txt +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor_core.egg-info/top_level.txt +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/pyproject.toml +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/setup.cfg +0 -0
- {metatensor_core-0.2.4 → metatensor_core-0.2.5}/setup.py +0 -0
|
@@ -14,7 +14,7 @@ set(METATENSOR_CORE_SOURCE_DIR "" CACHE PATH "Path to the sources of metatensor-
|
|
|
14
14
|
|
|
15
15
|
file(REMOVE ${CMAKE_INSTALL_PREFIX}/_external.py)
|
|
16
16
|
|
|
17
|
-
set(REQUIRED_METATENSOR_VERSION "0.2.
|
|
17
|
+
set(REQUIRED_METATENSOR_VERSION "0.2.5")
|
|
18
18
|
if(${METATENSOR_CORE_PYTHON_USE_EXTERNAL_LIB})
|
|
19
19
|
# when building a source checkout, update version to include git information
|
|
20
20
|
# this will not apply when building a sdist
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: metatensor-core
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: Python bindings for metatensor
|
|
5
5
|
Author: Guillaume Fraux, Rohit Goswami, Philip Loche, Filippo Bigi, Joseph W. Abbott, Davide Tisi, Alexander Goscinski, Michele Ceriotti
|
|
6
6
|
License-Expression: BSD-3-Clause
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import ctypes
|
|
1
2
|
import os
|
|
2
3
|
import re
|
|
3
4
|
import sys
|
|
4
5
|
from collections import namedtuple
|
|
5
|
-
from ctypes import cdll
|
|
6
|
+
from ctypes import cdll, wintypes
|
|
6
7
|
|
|
7
8
|
from ._c_api import setup_functions
|
|
8
9
|
from ._data._extract import ExternalCpuArray, register_external_data_wrapper
|
|
@@ -43,8 +44,16 @@ class LibraryFinder(object):
|
|
|
43
44
|
|
|
44
45
|
def __call__(self):
|
|
45
46
|
if self._cached_dll is None:
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
# if the library is already loaded in the current process, use this one
|
|
48
|
+
# instead of loading a second, independent copy of it
|
|
49
|
+
dll = _already_loaded(_lib_name())
|
|
50
|
+
if dll is None:
|
|
51
|
+
path = _lib_path()
|
|
52
|
+
dll = cdll.LoadLibrary(path)
|
|
53
|
+
else:
|
|
54
|
+
path = "<already loaded in the current process>"
|
|
55
|
+
|
|
56
|
+
self._cached_dll = dll
|
|
48
57
|
setup_functions(self._cached_dll)
|
|
49
58
|
|
|
50
59
|
# initial setup, disable printing of the error in case of panic
|
|
@@ -66,6 +75,50 @@ class LibraryFinder(object):
|
|
|
66
75
|
return self._cached_dll
|
|
67
76
|
|
|
68
77
|
|
|
78
|
+
def _lib_name():
|
|
79
|
+
"""Name of the metatensor shared library on the current platform"""
|
|
80
|
+
if sys.platform.startswith("darwin"):
|
|
81
|
+
return "libmetatensor.dylib"
|
|
82
|
+
elif sys.platform.startswith("linux"):
|
|
83
|
+
return "libmetatensor.so"
|
|
84
|
+
elif sys.platform.startswith("win"):
|
|
85
|
+
return "metatensor.dll"
|
|
86
|
+
else:
|
|
87
|
+
raise ImportError("Unknown platform. Please edit this file")
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def _already_loaded(name):
|
|
91
|
+
"""
|
|
92
|
+
Check if the library with the given ``name`` is already loaded in the current
|
|
93
|
+
process, and return the corresponding ``CDLL`` if it is. This makes sure we share
|
|
94
|
+
the global state of the library (error buffers, registered data origins, ...) with
|
|
95
|
+
whoever loaded it first, instead of using a second, independent copy of the library.
|
|
96
|
+
|
|
97
|
+
Returns ``None`` if the library is not already loaded.
|
|
98
|
+
"""
|
|
99
|
+
if sys.platform.startswith("win"):
|
|
100
|
+
kernel32 = ctypes.WinDLL("kernel32", use_last_error=True)
|
|
101
|
+
kernel32.GetModuleHandleW.restype = wintypes.HMODULE
|
|
102
|
+
kernel32.GetModuleHandleW.argtypes = [wintypes.LPCWSTR]
|
|
103
|
+
|
|
104
|
+
handle = kernel32.GetModuleHandleW(name)
|
|
105
|
+
if not handle:
|
|
106
|
+
return None
|
|
107
|
+
|
|
108
|
+
return ctypes.CDLL(name, handle=handle)
|
|
109
|
+
else:
|
|
110
|
+
# RTLD_NOLOAD gives us a handle if the library is already loaded, and fails
|
|
111
|
+
# instead of loading it otherwise.
|
|
112
|
+
RTLD_NOLOAD = getattr(os, "RTLD_NOLOAD", None)
|
|
113
|
+
if RTLD_NOLOAD is None:
|
|
114
|
+
return None
|
|
115
|
+
|
|
116
|
+
try:
|
|
117
|
+
return ctypes.CDLL(name, mode=RTLD_NOLOAD | os.RTLD_LOCAL)
|
|
118
|
+
except OSError:
|
|
119
|
+
return None
|
|
120
|
+
|
|
121
|
+
|
|
69
122
|
def _lib_path():
|
|
70
123
|
try:
|
|
71
124
|
# check if we are using an externally-provided version of the shared library
|
|
@@ -76,17 +129,11 @@ def _lib_path():
|
|
|
76
129
|
pass
|
|
77
130
|
|
|
78
131
|
# otherwise load from the local installation
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
path = os.path.join(_HERE, "
|
|
82
|
-
elif sys.platform.startswith("linux"):
|
|
83
|
-
windows = False
|
|
84
|
-
path = os.path.join(_HERE, "lib", "libmetatensor.so")
|
|
85
|
-
elif sys.platform.startswith("win"):
|
|
86
|
-
windows = True
|
|
87
|
-
path = os.path.join(_HERE, "bin", "metatensor.dll")
|
|
132
|
+
windows = sys.platform.startswith("win")
|
|
133
|
+
if windows:
|
|
134
|
+
path = os.path.join(_HERE, "bin", _lib_name())
|
|
88
135
|
else:
|
|
89
|
-
|
|
136
|
+
path = os.path.join(_HERE, "lib", _lib_name())
|
|
90
137
|
|
|
91
138
|
if os.path.isfile(path):
|
|
92
139
|
if windows:
|
|
@@ -300,10 +300,11 @@ def _block_to_dict(block, prefix, is_gradient):
|
|
|
300
300
|
if not is_gradient:
|
|
301
301
|
result[f"{prefix}properties"] = _labels_to_mts(block.properties)
|
|
302
302
|
|
|
303
|
-
|
|
303
|
+
# sort the gradients to make sure the same file is generated every time
|
|
304
|
+
for parameter in sorted(block.gradients_list()):
|
|
304
305
|
result.update(
|
|
305
306
|
_block_to_dict(
|
|
306
|
-
gradient,
|
|
307
|
+
block.gradient(parameter),
|
|
307
308
|
f"{prefix}gradients/{parameter}/",
|
|
308
309
|
is_gradient=True,
|
|
309
310
|
)
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: metatensor-core
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: Python bindings for metatensor
|
|
5
5
|
Author: Guillaume Fraux, Rohit Goswami, Philip Loche, Filippo Bigi, Joseph W. Abbott, Davide Tisi, Alexander Goscinski, Michele Ceriotti
|
|
6
6
|
License-Expression: BSD-3-Clause
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{metatensor_core-0.2.4 → metatensor_core-0.2.5}/metatensor_core.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|