Rather than duplicating these lines, you could just do:
```python
req_files ["requirements/edx/pre.txt", "requirements/edx/base.txt", "requirements/edx/post.txt", "requirements/private.txt"]
for req_file in req_files:
    if os.path.exists(req_file):
        sh("pip install -q -r {req_file}".format(req_file=req_file))
```