(venv_dir)
| 2529 | # and returns the paths to the venv directory and the python executable |
| 2530 | @contextlib.contextmanager |
| 2531 | def setup_venv_with_pip_setuptools(venv_dir): |
| 2532 | import subprocess |
| 2533 | from .os_helper import temp_cwd |
| 2534 | |
| 2535 | def run_command(cmd): |
| 2536 | if verbose: |
| 2537 | import shlex |
| 2538 | print() |
| 2539 | print('Run:', ' '.join(map(shlex.quote, cmd))) |
| 2540 | subprocess.run(cmd, check=True) |
| 2541 | else: |
| 2542 | subprocess.run(cmd, |
| 2543 | stdout=subprocess.PIPE, |
| 2544 | stderr=subprocess.STDOUT, |
| 2545 | check=True) |
| 2546 | |
| 2547 | with temp_cwd() as temp_dir: |
| 2548 | # Create virtual environment to get setuptools |
| 2549 | cmd = [sys.executable, '-X', 'dev', '-m', 'venv', venv_dir] |
| 2550 | run_command(cmd) |
| 2551 | |
| 2552 | venv = os.path.join(temp_dir, venv_dir) |
| 2553 | |
| 2554 | # Get the Python executable of the venv |
| 2555 | python_exe = os.path.basename(sys.executable) |
| 2556 | if sys.platform == 'win32': |
| 2557 | python = os.path.join(venv, 'Scripts', python_exe) |
| 2558 | else: |
| 2559 | python = os.path.join(venv, 'bin', python_exe) |
| 2560 | |
| 2561 | cmd = (python, '-X', 'dev', |
| 2562 | '-m', 'pip', 'install', |
| 2563 | _findwheel('setuptools'), |
| 2564 | ) |
| 2565 | run_command(cmd) |
| 2566 | |
| 2567 | yield python |
| 2568 | |
| 2569 | |
| 2570 | # True if Python is built with the Py_DEBUG macro defined: if |
nothing calls this directly
no test coverage detected