summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2019-11-16 12:06:47 -0500
committerJason R. Coombs <jaraco@jaraco.com>2019-11-16 12:06:47 -0500
commit6b210c65938527a4bbcea34942fe43971be3c014 (patch)
treec63634150f4f971344649f3232ee255080570a7c
parent4c22a6ca57753d3b5604a90b61a0c6c5efe53a1d (diff)
downloadpython-setuptools-git-6b210c65938527a4bbcea34942fe43971be3c014.tar.gz
Move all finalization of distribution options into hooks. Allow hooks to specify an index for ordering.
-rwxr-xr-xsetup.py7
-rw-r--r--setuptools/dist.py24
2 files changed, 25 insertions, 6 deletions
diff --git a/setup.py b/setup.py
index f5030dd6..ac56a1b0 100755
--- a/setup.py
+++ b/setup.py
@@ -89,6 +89,13 @@ setup_params = dict(
"%(cmd)s = setuptools.command.%(cmd)s:%(cmd)s" % locals()
for cmd in read_commands()
],
+ "setuptools.finalize_distribution_options": [
+ "parent_finalize = setuptools.dist:_Distribution.finalize_options",
+ "features = setuptools.dist:Distribution._finalize_feature_opts",
+ "keywords = setuptools.dist:Distribution._finalize_setup_keywords",
+ "2to3_doctests = "
+ "setuptools.dist:Distribution._finalize_2to3_doctests",
+ ],
"distutils.setup_keywords": [
"eager_resources = setuptools.dist:assert_string_list",
"namespace_packages = setuptools.dist:check_nsp",
diff --git a/setuptools/dist.py b/setuptools/dist.py
index 987d684e..44990431 100644
--- a/setuptools/dist.py
+++ b/setuptools/dist.py
@@ -724,19 +724,28 @@ class Distribution(_Distribution):
return resolved_dists
def finalize_options(self):
- _Distribution.finalize_options(self)
- if self.features:
- self._set_global_opts_from_features()
-
+ """
+ Allow plugins to apply arbitrary operations to the
+ distribution. Each hook may optionally define a 'order'
+ to influence the order of execution. Smaller numbers
+ go first and the default is 0.
+ """
hook_key = 'setuptools.finalize_distribution_options'
- for ep in pkg_resources.iter_entry_points(hook_key):
+
+ def by_order(hook):
+ return getattr(hook, 'order', 0)
+ eps = pkg_resources.iter_entry_points(hook_key)
+ for ep in sorted(eps, key=by_order):
ep.load()(self)
+ def _finalize_setup_keywords(self):
for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'):
value = getattr(self, ep.name, None)
if value is not None:
ep.require(installer=self.fetch_build_egg)
ep.load()(self, ep.name, value)
+
+ def _finalize_2to3_doctests(self):
if getattr(self, 'convert_2to3_doctests', None):
# XXX may convert to set here when we can rely on set being builtin
self.convert_2to3_doctests = [
@@ -790,9 +799,12 @@ class Distribution(_Distribution):
cmd.ensure_finalized()
return cmd.easy_install(req)
- def _set_global_opts_from_features(self):
+ def _finalize_feature_opts(self):
"""Add --with-X/--without-X options based on optional features"""
+ if not self.features:
+ return
+
go = []
no = self.negative_opt.copy()