diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2020-07-05 16:54:26 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-05 16:54:26 -0400 |
commit | aff64ae89e00e25fb3868bf528a14c18e7af0cf4 (patch) | |
tree | 96b44ccbccd4f80707de28b3262effa90b53c4fa | |
parent | 5e179ffca0a6ed5f3369139baaea61094df38524 (diff) | |
parent | d61166f01d3198a6d227acad616e0415108c9a0c (diff) | |
download | python-setuptools-git-aff64ae89e00e25fb3868bf528a14c18e7af0cf4.tar.gz |
Merge pull request #2236 from pypa/bugfix/2228-spawn-missing
Restore support for spawn when compiler is missing
-rw-r--r-- | CHANGES.rst | 6 | ||||
-rw-r--r-- | setuptools/_distutils/spawn.py | 12 | ||||
-rw-r--r-- | setuptools/_distutils/tests/test_spawn.py | 5 |
3 files changed, 20 insertions, 3 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index 95dd2d24..f00482e3 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,9 @@ +v49.0.1 +------- + +* #2228: Applied fix for pypa/distutils#3, restoring expectation that spawn will raise a DistutilsExecError when attempting to execute a missing file. + + v49.1.0 ------- diff --git a/setuptools/_distutils/spawn.py b/setuptools/_distutils/spawn.py index aad277b0..0d1bd039 100644 --- a/setuptools/_distutils/spawn.py +++ b/setuptools/_distutils/spawn.py @@ -71,9 +71,15 @@ def spawn(cmd, search_path=1, verbose=0, dry_run=0): env = dict(os.environ, MACOSX_DEPLOYMENT_TARGET=cur_target) - proc = subprocess.Popen(cmd, env=env) - proc.wait() - exitcode = proc.returncode + try: + proc = subprocess.Popen(cmd, env=env) + proc.wait() + exitcode = proc.returncode + except OSError as exc: + if not DEBUG: + cmd = cmd[0] + raise DistutilsExecError( + "command %r failed: %s" % (cmd, exc.args[-1])) from exc if exitcode: if not DEBUG: diff --git a/setuptools/_distutils/tests/test_spawn.py b/setuptools/_distutils/tests/test_spawn.py index 919d0ad9..704019a1 100644 --- a/setuptools/_distutils/tests/test_spawn.py +++ b/setuptools/_distutils/tests/test_spawn.py @@ -126,6 +126,11 @@ class SpawnTestCase(support.TempdirManager, rv = find_executable(program) self.assertEqual(rv, filename) + def test_spawn_missing_exe(self): + with self.assertRaises(DistutilsExecError) as ctx: + spawn(['does-not-exist']) + assert 'command does-no-exist failed' in str(ctx) + def test_suite(): return unittest.makeSuite(SpawnTestCase) |