Show More
@@ -3571,16 +3571,18 class TestRunner(object): | |||
|
3571 | 3571 | def _usecorrectpython(self): |
|
3572 | 3572 | """Configure the environment to use the appropriate Python in tests.""" |
|
3573 | 3573 | # Tests must use the same interpreter as us or bad things will happen. |
|
3574 | if sys.platform == 'win32': | |
|
3574 | if WINDOWS and PYTHON3: | |
|
3575 | pyexe_names = [b'python', b'python3', b'python.exe'] | |
|
3576 | elif WINDOWS: | |
|
3575 | 3577 | pyexe_names = [b'python', b'python.exe'] |
|
3576 | elif sys.version_info[0] < 3: | |
|
3578 | elif PYTHON3: | |
|
3579 | pyexe_names = [b'python', b'python3'] | |
|
3580 | else: | |
|
3577 | 3581 | pyexe_names = [b'python', b'python2'] |
|
3578 | else: | |
|
3579 | pyexe_names = [b'python', b'python3'] | |
|
3580 | 3582 | |
|
3581 | 3583 | # os.symlink() is a thing with py3 on Windows, but it requires |
|
3582 | 3584 | # Administrator rights. |
|
3583 |
if getattr(os, 'symlink', None) |
|
|
3585 | if not WINDOWS and getattr(os, 'symlink', None): | |
|
3584 | 3586 | msg = "# Making python executable in test path a symlink to '%s'" |
|
3585 | 3587 | msg %= sysexecutable |
|
3586 | 3588 | vlog(msg) |
@@ -3601,57 +3603,50 class TestRunner(object): | |||
|
3601 | 3603 | # child processes may race, which is harmless |
|
3602 | 3604 | if err.errno != errno.EEXIST: |
|
3603 | 3605 | raise |
|
3606 | elif WINDOWS and not os.getenv('MSYSTEM'): | |
|
3607 | raise AssertionError('cannot run test on Windows without MSYSTEM') | |
|
3604 | 3608 | else: |
|
3605 | # Windows doesn't have `python3.exe`, and MSYS cannot understand the | |
|
3606 | # reparse point with that name provided by Microsoft. Create a | |
|
3607 | # simple script on PATH with that name that delegates to the py3 | |
|
3608 | # launcher so the shebang lines work. | |
|
3609 | if os.getenv('MSYSTEM'): | |
|
3609 | # Generate explicit file instead of symlink | |
|
3610 | # | |
|
3611 | # This is especially important as Windows doesn't have | |
|
3612 | # `python3.exe`, and MSYS cannot understand the reparse point with | |
|
3613 | # that name provided by Microsoft. Create a simple script on PATH | |
|
3614 | # with that name that delegates to the py3 launcher so the shebang | |
|
3615 | # lines work. | |
|
3616 | esc_executable = _sys2bytes(shellquote(sysexecutable)) | |
|
3617 | for pyexename in pyexe_names: | |
|
3618 | stub_exec_path = os.path.join(self._custom_bin_dir, pyexename) | |
|
3619 | with open(stub_exec_path, 'wb') as f: | |
|
3620 | f.write(b'#!/bin/sh\n') | |
|
3621 | f.write(b'%s "$@"\n' % esc_executable) | |
|
3622 | ||
|
3623 | if WINDOWS: | |
|
3624 | if not PYTHON3: | |
|
3625 | # lets try to build a valid python3 executable for the | |
|
3626 | # scrip that requires it. | |
|
3610 | 3627 | py3exe_name = os.path.join(self._custom_bin_dir, b'python3') |
|
3611 | 3628 | with open(py3exe_name, 'wb') as f: |
|
3612 | 3629 | f.write(b'#!/bin/sh\n') |
|
3613 |
f.write(b'py -3 |
|
|
3614 | ||
|
3615 | pyexe_name = os.path.join(self._custom_bin_dir, b'python') | |
|
3616 | with open(pyexe_name, 'wb') as f: | |
|
3617 | f.write(b'#!/bin/sh\n') | |
|
3618 | f.write(b'py -%d.%d "$@"\n' % sys.version_info[0:2]) | |
|
3619 | ||
|
3620 | exedir, exename = os.path.split(sysexecutable) | |
|
3621 | for pyexename in pyexe_names: | |
|
3622 | msg = "# Modifying search path to find %s as %s in '%s'" | |
|
3623 | msg %= (exename, pyexename, exedir) | |
|
3624 | vlog(msg) | |
|
3630 | f.write(b'py -3 "$@"\n') | |
|
3631 | ||
|
3632 | # adjust the path to make sur the main python finds it own dll | |
|
3625 | 3633 | path = os.environ['PATH'].split(os.pathsep) |
|
3626 | while exedir in path: | |
|
3627 | path.remove(exedir) | |
|
3634 | main_exec_dir = os.path.dirname(sysexecutable) | |
|
3635 | extra_paths = [_bytes2sys(self._custom_bin_dir), main_exec_dir] | |
|
3628 | 3636 | |
|
3629 | 3637 | # Binaries installed by pip into the user area like pylint.exe may |
|
3630 | 3638 | # not be in PATH by default. |
|
3631 | extra_paths = [exedir] | |
|
3639 | appdata = os.environ.get('APPDATA') | |
|
3632 | 3640 | vi = sys.version_info |
|
3633 | appdata = os.environ.get('APPDATA') | |
|
3634 | 3641 | if appdata is not None: |
|
3635 | scripts_dir = os.path.join( | |
|
3636 | appdata, | |
|
3637 |
|
|
|
3638 | 'Python%d%d' % (vi[0], vi[1]), | |
|
3639 | 'Scripts', | |
|
3640 | ) | |
|
3641 | ||
|
3642 | if vi.major == 2: | |
|
3643 | scripts_dir = os.path.join( | |
|
3644 | appdata, | |
|
3645 | 'Python', | |
|
3646 | 'Scripts', | |
|
3647 | ) | |
|
3648 | ||
|
3642 | python_dir = 'Python%d%d' % (vi[0], vi[1]) | |
|
3643 | scripts_path = [appdata, 'Python', python_dir, 'Scripts'] | |
|
3644 | if not PYTHON3: | |
|
3645 | scripts_path = [appdata, 'Python', 'Scripts'] | |
|
3646 | scripts_dir = os.path.join(*scripts_path) | |
|
3649 | 3647 | extra_paths.append(scripts_dir) |
|
3650 | 3648 | |
|
3651 | 3649 | os.environ['PATH'] = os.pathsep.join(extra_paths + path) |
|
3652 | for pyexename in pyexe_names: | |
|
3653 | if not self._findprogram(pyexename): | |
|
3654 | print("WARNING: Cannot find %s in search path" % pyexename) | |
|
3655 | 3650 | |
|
3656 | 3651 | def _use_correct_mercurial(self): |
|
3657 | 3652 | target_exec = os.path.join(self._custom_bin_dir, b'hg') |
General Comments 0
You need to be logged in to leave comments.
Login now