forked from Komil-parmar/meta-learning-from-scratch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_package_versions.py
More file actions
48 lines (41 loc) · 1.14 KB
/
get_package_versions.py
File metadata and controls
48 lines (41 loc) · 1.14 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
#!/usr/bin/env python3
"""
Script to get versions of all packages used in the project
"""
import sys
# List of all packages identified from the project
packages = [
'torch',
'numpy',
'matplotlib',
'tqdm',
'Pillow', # PIL is imported from Pillow
]
def get_version(package_name):
"""Get the version of a package"""
try:
if package_name == 'Pillow':
# Special case for PIL
import PIL
return PIL.__version__
else:
module = __import__(package_name)
return getattr(module, '__version__', 'unknown')
except ImportError:
return 'not installed'
except Exception as e:
return f'error: {str(e)}'
def main():
print("=" * 60)
print("Package Versions for meta-learning-from-scratch")
print("=" * 60)
print()
for package in packages:
version = get_version(package)
# Handle the Pillow/PIL case for display
display_name = 'PIL (Pillow)' if package == 'Pillow' else package
print(f"{display_name:20s} : {version}")
print()
print("=" * 60)
if __name__ == '__main__':
main()