| 43 | def execute_colors_pex(tmpdir): |
| 44 | # type: (Any) -> ExecuteColorsPex |
| 45 | def execute(colors_pex, extra_env): |
| 46 | pex_root = os.path.join(str(tmpdir), "pex_root") |
| 47 | env = os.environ.copy() |
| 48 | env.update(extra_env) |
| 49 | env["PEX_ROOT"] = pex_root |
| 50 | args = [colors_pex] if os.path.isfile(colors_pex) else [sys.executable, colors_pex] |
| 51 | output = subprocess.check_output( |
| 52 | args=args + ["-c", "import colors; print(colors.__file__)"], env=env |
| 53 | ) |
| 54 | return output.strip().decode("utf-8"), pex_root |
| 55 | |
| 56 | return execute |
| 57 | |