Last active
October 24, 2019 01:49
-
-
Save eyeseast/5700112 to your computer and use it in GitHub Desktop.
pip freeze > requirements.txt, excluding virtualenv clutter
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
from fabric.api import env, local | |
env.exclude_requirements = set([ | |
'wsgiref', 'readline', 'ipython', | |
'git-remote-helpers', | |
]) | |
def freeze(): | |
""" | |
pip freeze > requirements.txt, excluding virtualenv clutter | |
""" | |
reqs = local('pip freeze', capture=True).split('\n') | |
reqs = [r for r in reqs if r.split('==')[0] not in env.exclude_requirements] | |
reqs = '\n'.join(reqs) | |
with open('requirements.txt', 'wb') as f: | |
f.write(reqs) | |
print reqs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment