-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
72 lines (54 loc) · 1.91 KB
/
main.py
File metadata and controls
72 lines (54 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import argparse
import logging
import os
from src.utils.version import get_pvm_version
from src.scripts.store import Store
from src.scripts.arch import is_windows
from src.commands.list import list_command
from src.commands.install import install_command
from src.commands.uninstall import uninstall_command
from src.commands.use import use_command
from src.commands.link import link_command
from src.commands.update import update_command
# Use DEBUG in development, INFO in production builds
log_level = logging.DEBUG if os.getenv('PVM_DEV') == '1' else logging.INFO
VERSION = get_pvm_version()
logging.basicConfig(
level=log_level,
format='[%(asctime)s] [%(levelname)s] [%(name)s] - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S'
)
logger = logging.getLogger("pvm")
def cli():
if not is_windows():
logger.info("This tool is only supported for Windows.")
return
Store.init_store()
parser = argparse.ArgumentParser(
prog="pvm",
description="A lightweight Python version manager for Windows. Install, manage, and switch between multiple Python versions with ease. Downloads official embeddable Python distributions, maintains isolated installations, and uses shims for seamless version switching without modifying system settings or registry."
)
parser.add_argument(
'--version',
action='version',
version=f'pvm {VERSION}',
help='Shows the version of pvm installed'
)
subparsers = parser.add_subparsers(
title="commands",
dest="command",
metavar=""
)
list_command(subparsers)
install_command(subparsers)
uninstall_command(subparsers)
use_command(subparsers)
link_command(subparsers)
update_command(subparsers)
args = parser.parse_args()
if not hasattr(args, "func"):
parser.print_help()
return
args.func(args)
if __name__ == "__main__":
cli()