Skip to content

Commit d8c24d8

Browse files
committed
fixup! Update install_path interface to match CADET-Process
1 parent 21eaa9a commit d8c24d8

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

cadet/cadet.py

+19-20
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,25 @@ def is_dll(path: os.PathLike) -> bool:
2929
return suffix in {'.so', '.dll'}
3030

3131

32-
def install_path_to_cadet_paths(install_path: Optional[os.PathLike]) -> (None, None, None, None):
32+
def install_path_to_cadet_paths(
33+
install_path: Optional[os.PathLike],
34+
) -> tuple[Optional[Path], Optional[Path], Optional[Path], Optional[Path]]:
3335
"""
3436
Get the correct paths (root_path, cadet_cli_path, cadet_dll_path, cadet_create_lwe_path)
3537
from the installation path of CADET. This is extracted into a function to be used
3638
in both the meta class and the cadet class itself.
3739
3840
Parameters
3941
----------
40-
install_path : Path | os.PathLike | None
42+
install_path : Optional[os.PathLike]
4143
Path to the root of the CADET installation or the executable file 'cadet-cli'.
4244
If a file path is provided, the root directory will be inferred.
4345
4446
Returns
4547
-------
46-
47-
root_path : Path | os.PathLike | None
48-
Path to the root of the CADET installation.
49-
50-
cadet_cli_path : Path | os.PathLike | None
51-
Path to the executable file `cadet-cli`
52-
53-
cadet_dll_path : Path | os.PathLike | None
54-
Path to the library file `cadet.dll` or `cadet.so`
55-
56-
cadet_create_lwe_path : Path | os.PathLike | None
57-
Path to the executable file `createLWE`
48+
tuple[Optional[Path], Optional[Path], Optional[Path], Optional[Path]]
49+
Tuple with CADET installation paths
50+
(root_path, cadet_cli_path, cadet_dll_path, cadet_create_lwe_path)
5851
"""
5952
if install_path is None:
6053
return None, None, None, None
@@ -95,8 +88,8 @@ def install_path_to_cadet_paths(install_path: Optional[os.PathLike]) -> (None, N
9588
dll_path = cadet_root / 'bin' / 'cadet.dll'
9689
dll_debug_path = cadet_root / 'bin' / 'cadet_d.dll'
9790
else:
98-
dll_path = cadet_root / 'lib' / 'lib_cadet.so'
99-
dll_debug_path = cadet_root / 'lib' / 'lib_cadet_d.so'
91+
dll_path = cadet_root / 'lib' / 'libcadet.so'
92+
dll_debug_path = cadet_root / 'lib' / 'libcadet_d.so'
10093

10194
# Look for debug dll if dll is not found.
10295
if not dll_path.is_file() and dll_debug_path.is_file():
@@ -192,7 +185,11 @@ def cadet_path(cls, cadet_path: os.PathLike) -> None:
192185
"""
193186
cadet_path = Path(cadet_path)
194187

195-
warnings.warn("Deprecation warning: Support for setting cadet.cadet_path will be removed in a future version.")
188+
warnings.warn(
189+
"Support for setting cadet.cadet_path will be removed in a future version. "
190+
"TODO: What alternative should be used?",
191+
DeprecationWarning
192+
)
196193

197194
cls.use_dll = cadet_path.suffix in [".dll", ".so"]
198195

@@ -306,7 +303,7 @@ def install_path(self, install_path: Optional[os.PathLike]) -> None:
306303
307304
Parameters
308305
----------
309-
install_path : Path | os.PathLike | None
306+
install_path : Optional[os.PathLike]
310307
Path to the root of the CADET installation or the executable file 'cadet-cli'.
311308
If a file path is provided, the root directory will be inferred.
312309
"""
@@ -324,8 +321,10 @@ def install_path(self, install_path: Optional[os.PathLike]) -> None:
324321
self.cadet_dll_path = cadet_dll_path
325322
self.cadet_create_lwe_path = create_lwe_path
326323

327-
self._cadet_dll_runner = CadetDLLRunner(self.cadet_dll_path)
328-
self._cadet_cli_runner = CadetCLIRunner(self.cadet_cli_path)
324+
if self.cadet_cli_path is not None:
325+
self._cadet_cli_runner = CadetCLIRunner(self.cadet_cli_path)
326+
if self.cadet_dll_path is not None:
327+
self._cadet_dll_runner = CadetDLLRunner(self.cadet_dll_path)
329328

330329

331330
@property

0 commit comments

Comments
 (0)