Skip to content

Commit

Permalink
provide an alternate way to set liboqs path (#95)
Browse files Browse the repository at this point in the history
Also check lib64 directory for liboqs

Signed-off-by: Vysakh P Pillai <[email protected]>
Signed-off-by: Vysakh Pillai <[email protected]>
  • Loading branch information
vppillai authored Jan 14, 2025
1 parent 7a1c2f6 commit 921e5ad
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ an alternative path, e.g., `C:\liboqs`, by passing the
cmake -S liboqs -B liboqs/build -DCMAKE_INSTALL_PREFIX="C:\liboqs" -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE -DBUILD_SHARED_LIBS=ON
```

Alternatively you can set the `OQS_INSTALL_PATH` environment variable to point to the installation directory, e.g., on a UNIX-like system execute:

```shell
export OQS_INSTALL_PATH=/path/to/liboqs
```

### Let liboqs-python install liboqs automatically

If liboqs is not detected at runtime by liboqs-python, it will be downloaded,
Expand Down
15 changes: 12 additions & 3 deletions oqs/oqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,24 @@ def _install_liboqs(target_directory, oqs_version=None):


def _load_liboqs():
home_dir = os.path.expanduser("~")
oqs_install_dir = os.path.abspath(home_dir + os.path.sep + "_oqs") # $HOME/_oqs
if "OQS_INSTALL_PATH" in os.environ:
oqs_install_dir = os.path.abspath(os.environ["OQS_INSTALL_PATH"])
else:
home_dir = os.path.expanduser("~")
oqs_install_dir = os.path.abspath(home_dir + os.path.sep + "_oqs") # $HOME/_oqs

oqs_lib_dir = (
os.path.abspath(oqs_install_dir + os.path.sep + "bin") # $HOME/_oqs/bin
if platform.system() == "Windows"
else os.path.abspath(oqs_install_dir + os.path.sep + "lib") # $HOME/_oqs/lib
)
oqs_lib64_dir = (
os.path.abspath(oqs_install_dir + os.path.sep + "bin") # $HOME/_oqs/bin
if platform.system() == "Windows"
else os.path.abspath(oqs_install_dir + os.path.sep + "lib64") # $HOME/_oqs/lib64
)
try:
_liboqs = _load_shared_obj(name="oqs", additional_searching_paths=[oqs_lib_dir])
_liboqs = _load_shared_obj(name="oqs", additional_searching_paths=[oqs_lib_dir, oqs_lib64_dir])
assert _liboqs
except RuntimeError:
# We don't have liboqs, so we try to install it automatically
Expand Down

0 comments on commit 921e5ad

Please sign in to comment.