pw_env_setup: Support requirements in JSON

Support requirements.txt files in env setup JSON. Leave out of docs
since we discourage using it.

Change-Id: I5de894f2e9dcd8468bdc27f48431c20cf41dc562
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/37240
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Reviewed-by: Armando Montanez <amontanez@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
diff --git a/pw_env_setup/docs.rst b/pw_env_setup/docs.rst
index 7832a9f..698a4c2 100644
--- a/pw_env_setup/docs.rst
+++ b/pw_env_setup/docs.rst
@@ -180,6 +180,13 @@
   only installing Pigweed Python packages, use the location of the Pigweed
   submodule.
 
+``virtualenv.requirements``
+  A ``requirements.txt`` file as written by ``pip-compile``, relative to
+  ``PW_PROJECT_ROOT``. Listing multiple files is supported but unlikely to
+  work because the same package may be pinned to two different versions. Best
+  practice is to include dependencies in ``setup.py`` files and not just in
+  ``requirements.txt``.
+
 An example of a config file is below.
 
 .. code-block:: json
@@ -194,6 +201,9 @@
       "gn_root": ".",
       "gn_targets": [
         ":python.install",
+      ],
+      "requirements": [
+        "tools/requirements.txt"
       ]
     }
   }
diff --git a/pw_env_setup/py/pw_env_setup/env_setup.py b/pw_env_setup/py/pw_env_setup/env_setup.py
index b3f1fdd..62a3ae5 100755
--- a/pw_env_setup/py/pw_env_setup/env_setup.py
+++ b/pw_env_setup/py/pw_env_setup/env_setup.py
@@ -254,6 +254,8 @@
 
         virtualenv = config.pop('virtualenv', {})
 
+        self._virtualenv_requirements = virtualenv.pop('requirements', [])
+
         if virtualenv.get('gn_root'):
             root = os.path.join(self._project_root, virtualenv.pop('gn_root'))
         else: