-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add convenience for printing info about the library and getting the p…
…dal-plugin-path
- Loading branch information
Showing
2 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import sys | ||
import os | ||
import pathlib | ||
|
||
import distutils.ccompiler | ||
so_ext = distutils.ccompiler.new_compiler().shared_lib_extension | ||
import sysconfig | ||
|
||
import argparse | ||
|
||
import pdal | ||
|
||
from . import __version__ | ||
|
||
__all__ = ["main"] | ||
|
||
|
||
def __dir__() -> list[str]: | ||
return __all__ | ||
|
||
|
||
def print_driver_path(args): | ||
print (os.environ['PDAL_DRIVER_PATH']) | ||
|
||
def print_plugin_path(args): | ||
purelib = sysconfig.get_paths()["purelib"]+os.path.sep+"pdal" | ||
|
||
if sys.platform == "linux" or sys.platform == "linux2": | ||
suffix = 'so' | ||
purelib = purelib + os.path.sep + "pdal" | ||
elif sys.platform == "darwin": | ||
suffix = 'dylib' | ||
purelib = purelib + os.path.sep + "pdal" | ||
elif sys.platform == "win32": | ||
suffix = 'dll' | ||
purelib = purelib + os.path.sep + "bin" | ||
|
||
for f in pathlib.Path(purelib).glob(f'*.{suffix}'): | ||
if 'pdal' in str(f.name): | ||
if 'numpy' in str(f.name) or 'python' in str(f.name): | ||
print (purelib) | ||
return # we are done | ||
|
||
def print_version(args): | ||
info = pdal.drivers.libpdalpython.getInfo() | ||
pdal_version = info.version | ||
plugin = info.plugin | ||
debug = info.debug | ||
|
||
line = '----------------------------------------------------------------------------------------------------------------------------\n' | ||
version = f'PDAL version {pdal_version}\nPython bindings version {__version__}\n' | ||
plugin = f"Environment-set PDAL_DRIVER_PATH: {os.environ['PDAL_DRIVER_PATH']}" | ||
output = f'{line}{version}{plugin}\n{line}\n{debug}' | ||
print (output) | ||
|
||
|
||
def main() -> None: | ||
header = f"PDAL Python bindings {__version__} on Python {sys.version}" | ||
|
||
parser = argparse.ArgumentParser(description=header) | ||
parser.add_argument('--pdal-driver-path', action='store_true', | ||
help='print PDAL_DRIVER_PATH including Python plugin locations') | ||
parser.add_argument('--pdal-plugin-path', action='store_true', | ||
help='print location of PDAL Python plugins') | ||
|
||
args = parser.parse_args() | ||
|
||
if args.pdal_driver_path: | ||
print_driver_path(args) | ||
elif args.pdal_plugin_path: | ||
print_plugin_path(args) | ||
else: | ||
print_version(args) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |