Allow to get prefix of base python interpreter

Change-Id: Ia56cd2002a790e941bdb4070978116609b7d7968
changes/37/713437/1
Federico Ressi 3 years ago
parent 76999d710e
commit b1815b45f8

@ -1,6 +1,25 @@
#!/usr/bin/env python
import argparse
import os
import sys
print(os.path.realpath(sys.prefix))
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--base",
action="store_true",
help="print Python base prefix")
args = parser.parse_args()
prefix = get_python_prefix(base=args.base)
sys.stdout.write(prefix + '\n')
def get_python_prefix(base=False):
prefix = base and getattr(sys, 'base_prefix', None) or sys.prefix
return os.path.realpath(prefix)
if __name__ == '__main__':
main()

Loading…
Cancel
Save