Last active
December 18, 2017 19:15
-
-
Save Diapolo10/cc0eb3a15bee5099a206b9caa361bf2c to your computer and use it in GitHub Desktop.
This file contains 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
@echo off | |
rem Define a (local) name for the temporary file | |
setlocal | |
set temp="tmp.txt" | |
rem Copy the list of outdated modules to a text file | |
call pip list --outdated > %temp% | |
rem Process the text file to only contain module names | |
call python -c "m='\n'.join(map(lambda x: x.split()[0], open('%temp%', 'r').readlines())); open('%temp%', 'w').write(m)" | |
rem Pipe the file back to pip and install the modules | |
call pip install --upgrade -r %temp% | |
rem Delete the text file | |
del %temp% | |
rem Free the now-unnecessary variable for the filename | |
endlocal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist basically uses pip's ability to list whatever libraries are out-of-date, saves this to a file, modifies the file to only contain the module names, uses this new file to install the up-to-date versions and then finally removes the temporary file.
Even if the file wouldn't be deleted, the script doesn't break. That being said, it will only work as long as pip's output syntax doesn't change drastically.
Also, never use Python one-liners like this one. My script is just an example.