Skip to content

Commit

Permalink
Merge branch 'pothosware:master' into dev/cmake_dest_fix_2
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniovazquezblanco authored Apr 22, 2024
2 parents e474d2e + 6c96090 commit f50be11
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/Modules.in.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ std::string SoapySDR::loadModule(const std::string &path)
getModuleLoading().clear();
if (handle == NULL) return "LoadLibrary() failed: " + GetLastErrorMessage();
#else
void *handle = dlopen(path.c_str(), RTLD_LAZY);
void *handle = dlopen(path.c_str(), RTLD_LAZY | RTLD_LOCAL);
getModuleLoading().clear();
if (handle == NULL) return "dlopen() failed: " + std::string(dlerror());
#endif
Expand Down
36 changes: 25 additions & 11 deletions swig/python/get_python_lib.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
import os
import pathlib
import sys
import site
from distutils.sysconfig import get_python_lib
import sysconfig

if __name__ == '__main__':
prefix = sys.argv[1]
prefix = pathlib.Path(sys.argv[1]).resolve()

#ask distutils where to install the python module
install_dir = get_python_lib(plat_specific=True, prefix=prefix)
# default install dir for the running Python interpreter
default_install_dir = pathlib.Path(sysconfig.get_path('platlib')).resolve()

#use sites when the prefix is already recognized
# if default falls under the desired prefix, we're done
try:
paths = [p for p in site.getsitepackages() if p.startswith(prefix)]
if len(paths) == 1: install_dir = paths[0]
except AttributeError: pass
relative_install_dir = default_install_dir.relative_to(prefix)
except ValueError:
# get install dir for the specified prefix
# can't use the default scheme because distributions modify it
# newer Python versions have 'venv' scheme, use for all OSs.
if 'venv' in sysconfig.get_scheme_names():
scheme = 'venv'
elif os.name == 'nt':
scheme = 'nt'
else:
scheme = 'posix_prefix'
prefix_install_dir = pathlib.Path(sysconfig.get_path(
'platlib',
scheme=scheme,
vars={'base': prefix, 'platbase': prefix},
)).resolve()
relative_install_dir = prefix_install_dir.relative_to(prefix)

#strip the prefix to return a relative path
print(os.path.relpath(install_dir, prefix))
# want a relative path for use in the build system
print(relative_install_dir)

0 comments on commit f50be11

Please sign in to comment.