28 '\x1b[101mCRITICAL %s\x1b[0m'
30 'Cannot find package "%s".'
35 '\x1b[37mINFO %s\x1b[0m'
37 'Install it using "pip". Then try again.')
51def run(args: argparse.Namespace) -> int:
57 'Display "real_prefix" for a Python virtual environment version.'
64 except AttributeError:
72 if len(filtered_envs) > 0:
73 for env
in filtered_envs:
74 pl = env.split(os.sep)
75 for i
in range(len(pl)):
77 if item ==
'versions':
80 result += os.sep.join(pl[:i + 2])
83 log.warning(
'Cannot find virtual environments like "{}".'.format(args.name))
84 log.info(
'Try again with another filter by name. Wildcards are implemented.')
88 log.debug(
'Python executable: "{}".'.format(sys.executable))
89 pl = sys.executable.split(os.sep)
97 os.path.dirname(sys.executable),
105 for i
in range(len(pl)):
107 if item ==
'versions':
108 result = os.sep.join(pl[:i + 2])
111 log.error(
'Cannot determine Python version for this virtual environment.')
117 version = sys.version.split(
' ')[0]
118 log.warning(
"'pyenv-virtualenv': Python version {} is not a virtual environment.".format(version))
119 log.info(
'Executable: "{}".'.format(sys.executable))
120 log.info(
"Activate a virtual environment using the 'activate' command'. Then try again.")
148 parser = argparse.ArgumentParser(
150 prog=
'pyenv virtualenv-prefix',
151 description=
'Display "real_prefix" for a Python virtual environment version.'
154 return parser.parse_args(), rc
174 parser = argparse.ArgumentParser(
176 prog=
'pyenv virtualenv-prefix',
177 description=
'Display "real_prefix" for a Python virtual environment version.'
182 help=
'Short name of an installed Python virtual environment. Default: Empty string = analyze the CWD.'
185 return parser.parse_args(), rc
224 args_list = sys.argv.copy()
229 help_requested =
False
230 for i
in reversed(range(len(args_list))):
232 if arg
in [
'-h',
'--help']:
233 help_requested =
True
236 positional_count = len(args_list)
240 (positional_count
not in [0, 1])
243Usage: pyenv virtualenv-prefix [-h] [name]
245Display "real_prefix" for a Python virtual environment version.
247Positional arguments (can be omitted):
248 [name] Short name of an installed Python virtual environment.
249 Default: Empty string = analyze the CWD.
251 -h, --help Show this help message and exit
254 elif positional_count == 0:
257 elif positional_count == 1:
272 except Exception
as exc:
277 '\x1b[91mERROR: Unexpected error "%s".\x1b[0m'
285if __name__ ==
"__main__":
int auditPyEnv(str min_ver)
Check if "pyenv" version is greater or equal the given minimal version.
int auditGlobalPythonVersion(str min_ver)
Check if Python version is greater or equal the given minimal version.
int auditPlatform(str name)
Check if the program in running on the required platform.
list[str] getAllEnvs(str name=' *', bool as_paths=False)
Get list of installed virtual environments for a specific Python version in "pyenv".
debug((str, tuple) msg)
Log debug message colored to console only.
warning((str, tuple) msg)
Log warning message colored to console only.
verbose((str, tuple) msg)
Log verbose message colored to console only.
initLogging()
Initialize the logging.
info((str, tuple) msg)
Log info message colored to console only.
error((str, tuple) msg)
Log error message colored to console only.
int run(argparse.Namespace args)
Sub routine to run the application.
tuple[(argparse.Namespace, None), int] parseCliArguments1()
Parse CLI arguments for this application.
int main()
Main routine of the application.
tuple[(argparse.Namespace, None), int] parseCliArguments0()
Parse CLI arguments for this application.