-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
31 lines (20 loc) · 829 Bytes
/
main.py
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
import pip
import requests, os, bs4
import unicodedata
from download import download_package
def get_installed_packages():
installed_packages = pip.get_installed_distributions()
installed_packages_list = sorted(["%s==%s" % (i.key, i.version) for i in installed_packages])
print(installed_packages_list)
return installed_packages_list
if __name__ == '__main__':
installed_packages_list = get_installed_packages()
for package in installed_packages_list:
# download all packages to an backup folder
name = package[:package.find('=')]
version = package[package.find('=')+2:]
if 'dev' in version:
version = version[:version.find('dev')]
url = 'https://pypi.python.org/pypi/' + name + '/' + version
print(url)
download_package(url)