-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfind_python_env.py
More file actions
32 lines (24 loc) · 1.09 KB
/
find_python_env.py
File metadata and controls
32 lines (24 loc) · 1.09 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
import os
def find_folders_with_file(folder, filename):
folders_with_file = []
for root, dirs, files in os.walk(folder):
if filename in files:
folder_name = os.path.basename(root)
folder_path = os.path.abspath(root)
usage_env = os.path.join(folder_path, "bin", "activate")
folders_with_file.append((folder_name, folder_path, usage_env))
return folders_with_file
def main():
folder_place = input("Input folder you want (. is default): ")
if not folder_place:
folder_place = "."
filename = "pyvenv.cfg"
print("===============================")
print("List semua venv yang anda buat:")
print("===============================")
print("{:<4} {:<10} {:<40} {}".format("No", "Venv", "Path", "Usage"))
folders_with_file = find_folders_with_file(folder_place, filename)
for i, (folder_name, folder_path, usage_env) in enumerate(folders_with_file, start=1):
print("{:<4} {:<10} {:<40} {}".format(i, folder_name, folder_path, "source " + usage_env))
if __name__ == "__main__":
main()