#! /doesnotexist/python3
#
#  This interpreter will be replaced by the interpreter in the venv
#  during installation.  The "sage" script uses this script to
#  determine the correct SAGE_VENV.
#
#  By using a non-existing interpreter here in src/bin/sage-venv-config,
#  we make sure that it cannot be successfully executed accidentally,
#  which would give the wrong SAGE_VENV.
#
VERSION = 'unknown'

try:
    from sage_conf import *
except ImportError:
    pass

from sys import prefix as SAGE_VENV

try:
    from sage.version import version as VERSION
except ImportError:
    pass


try:
    import sage_wheels
except ImportError:
    pass
else:
    from glob import glob as _glob
    import os as _os
    SAGE_WHEELS_PATH = ':'.join(_os.path.join(_p, 'bin') for _p in sage_wheels.__path__)
    for _p in sage_wheels.__path__:
        for _dir in _glob(_os.path.join(_p, 'lib/ecl-*')):
            ECLDIR = _dir + '/'
            break


def _main():
    from argparse import ArgumentParser
    from sys import exit, stdout
    parser = ArgumentParser()
    parser.add_argument('--version', help="show version", action="version",
                       version='%(prog)s ' + VERSION)
    parser.add_argument("VARIABLE", nargs='?', help="output the value of VARIABLE")
    args = parser.parse_args()
    d = globals()
    if args.VARIABLE:
        stdout.write('{}\n'.format(d[args.VARIABLE]))
    else:
        for k, v in d.items():
            if not k.startswith('_'):
                stdout.write('{}={}\n'.format(k, v))

if __name__ == "__main__":
    _main()
