mirror of https://github.com/pypa/pip
Clean build dir if bdist_wheel fails
When pip tries to build a wheel but fails, setup.py install is run in the same directory. However, some build files are not compatible between 'install' and 'bdist_wheel', particularly scripts - the shebang lines are different. Pip now cleans the build dir after a failed bdist_wheel so that pip doesn't install broken scripts. Closes #3006
This commit is contained in:
parent
2bbb3be1ff
commit
7f58c07a25
23
pip/wheel.py
23
pip/wheel.py
|
@ -668,19 +668,24 @@ class WheelBuilder(object):
|
|||
logger.info('Stored in directory: %s', output_dir)
|
||||
return wheel_path
|
||||
except:
|
||||
return None
|
||||
pass
|
||||
# Ignore return, we can't do anything else useful.
|
||||
self._clean_one(req)
|
||||
return None
|
||||
finally:
|
||||
rmtree(tempd)
|
||||
|
||||
def __build_one(self, req, tempd):
|
||||
base_args = [
|
||||
def _base_setup_args(self, req):
|
||||
return [
|
||||
sys.executable, '-c',
|
||||
"import setuptools;__file__=%r;"
|
||||
"exec(compile(open(__file__).read().replace('\\r\\n', '\\n'), "
|
||||
"__file__, 'exec'))" % req.setup_py
|
||||
] + list(self.global_options)
|
||||
|
||||
def __build_one(self, req, tempd):
|
||||
base_args = self._base_setup_args(req)
|
||||
|
||||
logger.info('Running setup.py bdist_wheel for %s', req.name)
|
||||
logger.debug('Destination directory: %s', tempd)
|
||||
wheel_args = base_args + ['bdist_wheel', '-d', tempd] \
|
||||
|
@ -692,6 +697,18 @@ class WheelBuilder(object):
|
|||
logger.error('Failed building wheel for %s', req.name)
|
||||
return False
|
||||
|
||||
def _clean_one(self, req):
|
||||
base_args = self._base_setup_args(req)
|
||||
|
||||
logger.info('Running setup.py clean for %s', req.name)
|
||||
clean_args = base_args + ['clean', '--all']
|
||||
try:
|
||||
call_subprocess(clean_args, cwd=req.source_dir, show_stdout=False)
|
||||
return True
|
||||
except:
|
||||
logger.error('Failed cleaning build dir for %s', req.name)
|
||||
return False
|
||||
|
||||
def build(self, autobuilding=False):
|
||||
"""Build wheels.
|
||||
|
||||
|
|
Loading…
Reference in New Issue