-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy path_export_cmake.py
More file actions
20 lines (15 loc) · 880 Bytes
/
Copy path_export_cmake.py
File metadata and controls
20 lines (15 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from importlib.metadata import PackageNotFoundError, version
from pathlib import Path
def main():
# This trick is only necessary for the wheel distribution
try:
if "a" in version("ROOT"):
root_site_package = Path(__file__).resolve().parent
# Print a warning to stdout that eval will ignore but would be visible to user who accidentally runs raw command
print('# ERROR: You should eval the output of this command, not run it directly in your shell.\n# Use eval "$(export_cmake)"')
# Print the export commands to be eval'd by user's shell
print(f'export CMAKE_PREFIX_PATH="{root_site_package}"')
except PackageNotFoundError:
print("Setting CMAKE_PREFIX_PATH is only necessary when linking against ROOT's PyPI wheels. Please use thisroot.sh.")
if __name__ == "__main__":
main()