Check if the requirements from the given file are installed in the virtualenv by looking for a matching requirements file in the root directory of the virtualenv.
(venv_dir, reqs_path)
| 378 | |
| 379 | |
| 380 | def reqs_are_installed(venv_dir, reqs_path): |
| 381 | '''Check if the requirements from the given file are installed in the virtualenv by |
| 382 | looking for a matching requirements file in the root directory of the virtualenv.''' |
| 383 | installed_reqs_path = os.path.join(venv_dir, os.path.basename(reqs_path)) |
| 384 | if not os.path.exists(installed_reqs_path): |
| 385 | return False |
| 386 | installed_reqs_file = open(installed_reqs_path) |
| 387 | try: |
| 388 | reqs_file = open(reqs_path) |
| 389 | try: |
| 390 | if reqs_file.read() == installed_reqs_file.read(): |
| 391 | return True |
| 392 | else: |
| 393 | LOG.debug("Virtualenv upgrade needed") |
| 394 | return False |
| 395 | finally: |
| 396 | reqs_file.close() |
| 397 | finally: |
| 398 | installed_reqs_file.close() |
| 399 | |
| 400 | |
| 401 | def setup_virtualenv_if_not_exists(venv_dir): |
no test coverage detected