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.'
61 version: str = args.name
63 except AttributeError:
71 if len(filtered_envs) > 0:
72 for env
in filtered_envs:
73 pl = env.split(os.sep)
74 for i
in range(len(pl)):
76 if item ==
'versions':
79 result += os.sep.join(pl[:i + 2])
82 log.warning(f
'Cannot find virtual environments like "{args.name}".')
83 log.info(
'Try again with another filter by name. Wildcards are implemented.')
87 log.debug(f
'Python executable: "{sys.executable}".')
88 pl = sys.executable.split(os.sep)
96 os.path.dirname(sys.executable),
104 for i
in range(len(pl)):
106 if item ==
'versions':
107 result = os.sep.join(pl[:i + 2])
110 log.error(
'Cannot determine Python version for this virtual environment.')
116 version = sys.version.split(
' ')[0]
117 log.warning(f
'"pyenv-virtualenv": Version`{version}` is not a virtual environment.')
145 parser = argparse.ArgumentParser(
147 prog=
'pyenv virtualenv-prefix',
148 description=
'Display "real_prefix" for a Python virtual environment version.'
151 return parser.parse_args(), rc
171 parser = argparse.ArgumentParser(
173 prog=
'pyenv virtualenv-prefix',
174 description=
'Display "real_prefix" for a Python virtual environment version.'
179 help=
'Short name of an installed Python virtual environment. Default: Empty string = analyze the CWD.'
182 return parser.parse_args(), rc
221 args_list = sys.argv.copy()
226 help_requested =
False
227 for i
in reversed(range(len(args_list))):
229 if arg
in [
'-h',
'--help']:
230 help_requested =
True
233 positional_count = len(args_list)
237 (positional_count
not in [0, 1])
240Usage: pyenv virtualenv-prefix [-h] [name]
242Display "real_prefix" for a Python virtual environment version.
244Positional arguments (can be omitted):
245 [name] Short name of an installed Python virtual environment.
246 Default: Empty string = analyze the CWD.
248 -h, --help Show this help message and exit
251 elif positional_count == 0:
254 elif positional_count == 1:
269 except Exception
as exc:
274 '\x1b[91mERROR: Unexpected error "%s".\x1b[0m'
282if __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.