Skip to content

Instantly share code, notes, and snippets.

@eyeseast
Last active October 24, 2019 01:49
Show Gist options
  • Save eyeseast/5700112 to your computer and use it in GitHub Desktop.
Save eyeseast/5700112 to your computer and use it in GitHub Desktop.
pip freeze > requirements.txt, excluding virtualenv clutter
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