Skip to content

Instantly share code, notes, and snippets.

@msiemens
Created September 5, 2013 09:50
Show Gist options
  • Save msiemens/6448117 to your computer and use it in GitHub Desktop.
Save msiemens/6448117 to your computer and use it in GitHub Desktop.
setup.py: Load requires from requirements.txt
try:
from pip.req import parse_requirements
except ImportError:
def requirements(f):
reqs = open(f, 'r').read().splitlines()
reqs = [r for r in reqs if not r.strip().startswith('#')]
return reqs
else:
def requirements(f):
install_reqs = parse_requirements(f)
reqs = [str(r.req) for r in install_reqs]
return reqs
# ...
install_requires = requirements('requirements.txt')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment