Skip to content
Open
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
14 changes: 9 additions & 5 deletions buildhelp/cyclone_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,22 @@ def good_directory(directory: Path):
if not include_path.exists() or not bindir.exists():
return

# Define the libraries directory based on where the CycloneDDS library
# has been installed. That is required because CMake overrides the libraries
# directory definition 'lib' with 'lib64' depending on the operating system.
libdir = dir / 'lib'
if not libdir.exists():
libdir = dir / 'lib64'
if not libdir.exists():
return None

if platform.system() == 'Windows':
ddsc_library = bindir / "ddsc.dll"
elif platform.system() == 'Darwin':
ddsc_library = libdir / "libddsc.dylib"
else:
ddsc_library = libdir / "libddsc.so"
if not ddsc_library.exists():
libdir = dir / 'lib64'
ddsc_library = libdir / "libddsc.so"

if not libdir.exists():
return None

if not ddsc_library.exists():
return None
Expand Down
10 changes: 6 additions & 4 deletions cyclonedds/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ def _loader_cyclonedds_home_gen(name):
If CYCLONEDDS_HOME is set it is required to be valid and must be used to load.
"""
def _loader_cyclonedds_home():
if "CYCLONEDDS_HOME" not in os.environ:
return None

return _load(os.path.join(os.environ["CYCLONEDDS_HOME"], name))
if "CYCLONEDDS_HOME" in os.environ:
path = os.path.join(os.environ["CYCLONEDDS_HOME"], name)
if os.path.exists(path):
return _load(path)
return None
return _loader_cyclonedds_home


Expand Down Expand Up @@ -93,6 +94,7 @@ def _loader_install_path():
_loaders_per_system = {
"Linux": [
_loader_wheel_gen(["..", "cyclonedds.libs"], ".so"),
_loader_cyclonedds_home_gen(f"lib64{os.sep}libddsc.so"),
_loader_cyclonedds_home_gen(f"lib{os.sep}libddsc.so"),
_loader_on_path_gen("libddsc.so"),
_loader_install_path
Expand Down
2 changes: 2 additions & 0 deletions tests/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def common_mocks(mocker: MockerFixture, platform: str, ext: str):
mocker.patch("cyclonedds.internal._load", new=gen_test_loader(loadlist))
mocker.patch("platform.system", new=lambda: platform)
mocker.patch("os.environ", new={"CYCLONEDDS_HOME": "env_canary", "PATH": ""})
mocker.patch("os.path.exists", new_callable=mocker.PropertyMock, return_value=True)
return loadlist


Expand All @@ -39,6 +40,7 @@ def test_loading_linux(mocker: MockerFixture):
pass

assert paths == [
f"env_canary{os.sep}lib64{os.sep}libddsc.so",
f"env_canary{os.sep}lib{os.sep}libddsc.so",
"libddsc.so",
library_path
Expand Down
Loading