Created
August 7, 2016 04:01
-
-
Save makiftasova/dd3b987b140487d5440ef932e0134056 to your computer and use it in GitHub Desktop.
A Python script to upgrade all installed pip packages.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
"""pip-upgrade.py: A Python script to upgrade all installed pip packages.""" | |
__author__ = "Mehmet Akif TAŞOVA" | |
__email__ = "[email protected]" | |
__license__ = "GPLv3+" | |
__version__ = "1.0.0" | |
import os, sys, pip | |
from subprocess import call | |
def check_root() : | |
euid = os.geteuid() | |
if euid != 0: | |
print("Script not started as root. Running sudo..") | |
args = ['sudo', sys.executable] + sys.argv + [os.environ] | |
os.execlpe('sudo', *args) | |
def main(): | |
check_root() | |
for dist in pip.get_installed_distributions(): | |
call("pip install --upgrade " + dist.project_name, shell=True) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment