| 1077 | |
| 1078 | |
| 1079 | def get_env_dir(args): |
| 1080 | if args.python_virtualenv: |
| 1081 | if hasattr(sys, 'real_prefix'): |
| 1082 | res = sys.prefix |
| 1083 | elif hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix: |
| 1084 | res = sys.prefix |
| 1085 | elif 'CONDA_PREFIX' in os.environ: |
| 1086 | res = sys.prefix |
| 1087 | elif 'VIRTUAL_ENV' in os.environ: |
| 1088 | res = os.environ['VIRTUAL_ENV'] |
| 1089 | else: |
| 1090 | logger.error('No python virtualenv is available') |
| 1091 | sys.exit(2) |
| 1092 | else: |
| 1093 | res = args.env_dir |
| 1094 | return to_utf8(res) |
| 1095 | |
| 1096 | |
| 1097 | # noinspection PyProtectedMember |