Skip to content

Instantly share code, notes, and snippets.

@rouge8
Last active August 29, 2015 14:13
Show Gist options
  • Save rouge8/9f3e7b05ad95875c0841 to your computer and use it in GitHub Desktop.
Save rouge8/9f3e7b05ad95875c0841 to your computer and use it in GitHub Desktop.
Check that a requirements.txt file is fully satisfied (including its dependencies) by the current environment. Useful for verifying installs done with `pip install --no-deps`
#!/usr/bin/env python
from argparse import ArgumentParser
import pkg_resources
def main():
parser = ArgumentParser('Check that a requirements.txt file is satisifed '
'by the current environment.')
parser.add_argument('filename')
args = parser.parse_args()
with open(args.filename) as f:
reqs = [line.strip() for line in f if not line.strip().startswith(('#', '--'))]
pkg_resources.require(reqs)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment