diff options
author | 2020-03-09 23:45:59 +0100 | |
---|---|---|
committer | 2020-03-09 23:45:59 +0100 | |
commit | addaaaa946855ad59c8f5c698aa0891d7e44f018 (patch) | |
tree | 0de7ede6cf1117055d6a45120a73d3c866e3f0bb /setup.py | |
parent | bpo-19466: Py_Finalize() clears daemon threads earlier (GH-18848) (diff) | |
download | cpython-addaaaa946855ad59c8f5c698aa0891d7e44f018.tar.gz cpython-addaaaa946855ad59c8f5c698aa0891d7e44f018.tar.bz2 cpython-addaaaa946855ad59c8f5c698aa0891d7e44f018.zip |
bpo-39763: Add _bootsubprocess to build Python on AIX (GH-18872)
Add _bootsubprocess module to bootstrap Python: subprocess
implementation which only uses the os module.
On AIX, distutils.util uses _aix_support which calls
subprocess.check_output(), before the _posixsubprocess module is
built. Implement check_output() with os.system() in _bootsubprocess.
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 46 |
1 files changed, 5 insertions, 41 deletions
@@ -16,53 +16,17 @@ try: del subprocess SUBPROCESS_BOOTSTRAP = False except ImportError: - SUBPROCESS_BOOTSTRAP = True - # Bootstrap Python: distutils.spawn uses subprocess to build C extensions, # subprocess requires C extensions built by setup.py like _posixsubprocess. # - # Basic subprocess implementation for POSIX (setup.py is not used on - # Windows) which only uses os functions. Only implement features required - # by distutils.spawn. + # Use _bootsubprocess which only uses the os module. # # It is dropped from sys.modules as soon as all C extension modules # are built. - class Popen: - def __init__(self, cmd, env=None): - self._cmd = cmd - self._env = env - self.returncode = None - - def wait(self): - pid = os.fork() - if pid == 0: - # Child process - try: - if self._env is not None: - os.execve(self._cmd[0], self._cmd, self._env) - else: - os.execv(self._cmd[0], self._cmd) - finally: - os._exit(1) - else: - # Parent process - pid, status = os.waitpid(pid, 0) - if os.WIFSIGNALED(status): - self.returncode = -os.WTERMSIG(status) - elif os.WIFEXITED(status): - self.returncode = os.WEXITSTATUS(status) - elif os.WIFSTOPPED(status): - self.returncode = -os.WSTOPSIG(status) - else: - # Should never happen - raise Exception("Unknown child exit status!") - - return self.returncode - - mod = type(sys)('subprocess') - mod.Popen = Popen - sys.modules['subprocess'] = mod - del mod + import _bootsubprocess + sys.modules['subprocess'] = _bootsubprocess + del _bootsubprocess + SUBPROCESS_BOOTSTRAP = True from distutils import log |