aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools
diff options
context:
space:
mode:
Diffstat (limited to 'setuptools')
-rw-r--r--setuptools/archive_util.py4
-rw-r--r--setuptools/command/easy_install.py14
-rw-r--r--setuptools/command/egg_info.py4
-rw-r--r--setuptools/command/rotate.py4
-rw-r--r--setuptools/config.py5
-rw-r--r--setuptools/dist.py38
-rw-r--r--setuptools/installer.py2
-rw-r--r--setuptools/msvc.py2
8 files changed, 41 insertions, 32 deletions
diff --git a/setuptools/archive_util.py b/setuptools/archive_util.py
index 64528ca7..0ce190b8 100644
--- a/setuptools/archive_util.py
+++ b/setuptools/archive_util.py
@@ -134,10 +134,10 @@ def unpack_tarfile(filename, extract_dir, progress_filter=default_filter):
"""
try:
tarobj = tarfile.open(filename)
- except tarfile.TarError:
+ except tarfile.TarError as e:
raise UnrecognizedFormat(
"%s is not a compressed or uncompressed tar file" % (filename,)
- )
+ ) from e
with contextlib.closing(tarobj):
# don't do any chowning!
tarobj.chown = lambda *args: None
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
index 27b4558b..8890ec88 100644
--- a/setuptools/command/easy_install.py
+++ b/setuptools/command/easy_install.py
@@ -356,8 +356,10 @@ class easy_install(Command):
self.optimize = int(self.optimize)
if not (0 <= self.optimize <= 2):
raise ValueError
- except ValueError:
- raise DistutilsOptionError("--optimize must be 0, 1, or 2")
+ except ValueError as e:
+ raise DistutilsOptionError(
+ "--optimize must be 0, 1, or 2"
+ ) from e
if self.editable and not self.build_directory:
raise DistutilsArgError(
@@ -765,9 +767,9 @@ class easy_install(Command):
[requirement], self.local_index, self.easy_install
)
except DistributionNotFound as e:
- raise DistutilsError(str(e))
+ raise DistutilsError(str(e)) from e
except VersionConflict as e:
- raise DistutilsError(e.report())
+ raise DistutilsError(e.report()) from e
if self.always_copy or self.always_copy_from:
# Force all the relevant distros to be copied or activated
for dist in distros:
@@ -1156,7 +1158,9 @@ class easy_install(Command):
try:
run_setup(setup_script, args)
except SystemExit as v:
- raise DistutilsError("Setup script exited with %s" % (v.args[0],))
+ raise DistutilsError(
+ "Setup script exited with %s" % (v.args[0],)
+ ) from v
def build_and_install(self, setup_script, setup_base):
args = ['bdist_egg', '--dist-dir']
diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py
index 7fa89541..0855207c 100644
--- a/setuptools/command/egg_info.py
+++ b/setuptools/command/egg_info.py
@@ -208,11 +208,11 @@ class egg_info(InfoCommon, Command):
list(
parse_requirements(spec % (self.egg_name, self.egg_version))
)
- except ValueError:
+ except ValueError as e:
raise distutils.errors.DistutilsOptionError(
"Invalid distribution name or version syntax: %s-%s" %
(self.egg_name, self.egg_version)
- )
+ ) from e
if self.egg_base is None:
dirs = self.distribution.package_dir
diff --git a/setuptools/command/rotate.py b/setuptools/command/rotate.py
index b89353f5..e398834f 100644
--- a/setuptools/command/rotate.py
+++ b/setuptools/command/rotate.py
@@ -36,8 +36,8 @@ class rotate(Command):
raise DistutilsOptionError("Must specify number of files to keep")
try:
self.keep = int(self.keep)
- except ValueError:
- raise DistutilsOptionError("--keep must be an integer")
+ except ValueError as e:
+ raise DistutilsOptionError("--keep must be an integer") from e
if isinstance(self.match, six.string_types):
self.match = [
convert_path(p.strip()) for p in self.match.split(',')
diff --git a/setuptools/config.py b/setuptools/config.py
index 45df2e3f..a8f8b6b0 100644
--- a/setuptools/config.py
+++ b/setuptools/config.py
@@ -42,9 +42,10 @@ class StaticModule:
for target in statement.targets
if isinstance(target, ast.Name) and target.id == attr
)
- except Exception:
+ except Exception as e:
raise AttributeError(
- "{self.name} has no attribute {attr}".format(**locals()))
+ "{self.name} has no attribute {attr}".format(**locals())
+ ) from e
@contextlib.contextmanager
diff --git a/setuptools/dist.py b/setuptools/dist.py
index fe64afa9..e813b11c 100644
--- a/setuptools/dist.py
+++ b/setuptools/dist.py
@@ -204,11 +204,11 @@ def check_importable(dist, attr, value):
try:
ep = pkg_resources.EntryPoint.parse('x=' + value)
assert not ep.extras
- except (TypeError, ValueError, AttributeError, AssertionError):
+ except (TypeError, ValueError, AttributeError, AssertionError) as e:
raise DistutilsSetupError(
"%r must be importable 'module:attrs' string (got %r)"
% (attr, value)
- )
+ ) from e
def assert_string_list(dist, attr, value):
@@ -219,10 +219,10 @@ def assert_string_list(dist, attr, value):
assert isinstance(value, (list, tuple))
# verify that elements of value are strings
assert ''.join(value) != value
- except (TypeError, ValueError, AttributeError, AssertionError):
+ except (TypeError, ValueError, AttributeError, AssertionError) as e:
raise DistutilsSetupError(
"%r must be a list of strings (got %r)" % (attr, value)
- )
+ ) from e
def check_nsp(dist, attr, value):
@@ -247,12 +247,12 @@ def check_extras(dist, attr, value):
"""Verify that extras_require mapping is valid"""
try:
list(itertools.starmap(_check_extra, value.items()))
- except (TypeError, ValueError, AttributeError):
+ except (TypeError, ValueError, AttributeError) as e:
raise DistutilsSetupError(
"'extras_require' must be a dictionary whose values are "
"strings or lists of strings containing valid project/version "
"requirement specifiers."
- )
+ ) from e
def _check_extra(extra, reqs):
@@ -280,7 +280,9 @@ def check_requirements(dist, attr, value):
"{attr!r} must be a string or list of strings "
"containing valid project/version requirement specifiers; {error}"
)
- raise DistutilsSetupError(tmpl.format(attr=attr, error=error))
+ raise DistutilsSetupError(
+ tmpl.format(attr=attr, error=error)
+ ) from error
def check_specifier(dist, attr, value):
@@ -292,7 +294,9 @@ def check_specifier(dist, attr, value):
"{attr!r} must be a string "
"containing valid version specifiers; {error}"
)
- raise DistutilsSetupError(tmpl.format(attr=attr, error=error))
+ raise DistutilsSetupError(
+ tmpl.format(attr=attr, error=error)
+ ) from error
def check_entry_points(dist, attr, value):
@@ -300,7 +304,7 @@ def check_entry_points(dist, attr, value):
try:
pkg_resources.EntryPoint.parse_map(value)
except ValueError as e:
- raise DistutilsSetupError(e)
+ raise DistutilsSetupError(e) from e
def check_test_suite(dist, attr, value):
@@ -609,8 +613,8 @@ class Distribution(_Distribution):
setattr(self, opt, strtobool(val))
else:
setattr(self, opt, val)
- except ValueError as msg:
- raise DistutilsOptionError(msg)
+ except ValueError as e:
+ raise DistutilsOptionError(e) from e
@staticmethod
def _try_str(val):
@@ -676,8 +680,8 @@ class Distribution(_Distribution):
raise DistutilsOptionError(
"error in %s: command '%s' has no such option '%s'"
% (source, command_name, option))
- except ValueError as msg:
- raise DistutilsOptionError(msg)
+ except ValueError as e:
+ raise DistutilsOptionError(e) from e
def parse_config_files(self, filenames=None, ignore_option_errors=False):
"""Parses configuration files from various levels
@@ -843,10 +847,10 @@ class Distribution(_Distribution):
)
try:
old = getattr(self, name)
- except AttributeError:
+ except AttributeError as e:
raise DistutilsSetupError(
"%s: No such distribution setting" % name
- )
+ ) from e
if old is not None and not isinstance(old, sequence):
raise DistutilsSetupError(
name + ": this setting cannot be changed via include/exclude"
@@ -863,10 +867,10 @@ class Distribution(_Distribution):
)
try:
old = getattr(self, name)
- except AttributeError:
+ except AttributeError as e:
raise DistutilsSetupError(
"%s: No such distribution setting" % name
- )
+ ) from e
if old is None:
setattr(self, name, value)
elif not isinstance(old, sequence):
diff --git a/setuptools/installer.py b/setuptools/installer.py
index 1f183bd9..e5acec27 100644
--- a/setuptools/installer.py
+++ b/setuptools/installer.py
@@ -127,7 +127,7 @@ def fetch_build_egg(dist, req):
try:
subprocess.check_call(cmd)
except subprocess.CalledProcessError as e:
- raise DistutilsError(str(e))
+ raise DistutilsError(str(e)) from e
wheel = Wheel(glob.glob(os.path.join(tmpdir, '*.whl'))[0])
dist_location = os.path.join(eggs_dir, wheel.egg_name())
wheel.install_as_egg(dist_location)
diff --git a/setuptools/msvc.py b/setuptools/msvc.py
index 213e39c9..72ba0d0c 100644
--- a/setuptools/msvc.py
+++ b/setuptools/msvc.py
@@ -277,7 +277,7 @@ def _msvc14_get_vc_env(plat_spec):
except subprocess.CalledProcessError as exc:
raise distutils.errors.DistutilsPlatformError(
"Error executing {}".format(exc.cmd)
- )
+ ) from exc
env = {
key.lower(): value