-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_7_pyenv_pipenv.py
More file actions
97 lines (75 loc) · 3.29 KB
/
_7_pyenv_pipenv.py
File metadata and controls
97 lines (75 loc) · 3.29 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import random
from rich.tree import Tree
from rich.console import Console
from helpers import create_source_output_table
console = Console()
print = console.print
version_strings = ["3.7.10", "3.9.5", "3.8.10"]
def add_standard_environment(branch: Tree, version: str, abbreviate: bool = False):
version = ".".join(version.split(".")[:2])
binaries = branch.add("[blue]bin[/blue] (executables)")
lib = branch.add("[blue]lib[/blue] (standard library, etc.)")
site_packages = None
if not abbreviate:
binaries.add(f"[cyan]python -> python{version}[/cyan] (python.exe)")
binaries.add(f"[cyan]python3 -> python{version}[/cyan] (python3.exe)")
binaries.add(f"[green]python{version}[/green] (python{version}.exe)")
binaries.add("[green]pip[/green] (pip.exe)")
binaries.add("...binaries bundled installed related by pip packages")
lib_version = lib.add(f'[blue]python{version}[/blue]')
site_packages = lib_version.add("[blue]site-packages[/blue]")
site_packages.add("...everything you install with [green]pip[/green]")
return [binaries, lib, site_packages]
def python_standard_environment():
tree = Tree("standard python environment")
add_standard_environment(tree, "3.9.5")
print(tree)
def pyenv_version_management():
tree = Tree("pyenv version management")
versions = tree.add("versions")
for version in version_strings:
version_tree = versions.add(version)
add_standard_environment(version_tree, version)
global_versions = tree.add("system versions")
global_version = global_versions.add("3.9.5")
add_standard_environment(global_version, "3.9.5")
print(tree)
def pipenv_virtualenv():
tree = Tree("pipenv virtualenv")
virtualenv = tree.add("virtualenv")
[binaries, _, site_packages] = add_standard_environment(virtualenv, "3.9.5")
binaries.add("[green]pipenv[/green] (pipenv.exe)")
site_packages.add("[blue]pipenv[/blue]")
print(tree)
def pyenv_pipenv_version_management():
tree = Tree("pyenv version management")
versions = tree.add("versions")
version_strings = ["3.9.5", "3.8.10", "3.7.10"]
for version in version_strings:
version_tree = versions.add(version)
add_standard_environment(version_tree, version, abbreviate=True)
global_versions = tree.add("system versions")
version = random.choice(version_strings)
version_tree = global_versions.add(version)
add_standard_environment(version_tree, version, abbreviate=True)
projects = tree.add("projects")
project_strings = ["project1", "project2", "project3"]
for project in project_strings:
project_tree = projects.add(project)
version = random.choice(version_strings)
version_tree = project_tree.add(version)
add_standard_environment(version_tree, version, abbreviate=True)
print(tree)
examples = [
python_standard_environment,
pyenv_version_management,
pipenv_virtualenv,
pyenv_pipenv_version_management
]
if __name__ == "__main__":
for example in examples:
console.clear()
print(create_source_output_table(example, console, print_source=False))
is_not_last_item = example != examples[-1]
if is_not_last_item:
input("Press Enter to continue to the next example...")