diff options
| author | Steve Dower <steve.dower@microsoft.com> | 2022-09-01 21:33:53 +0100 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2022-09-24 12:18:01 -0400 |
| commit | ef78ba5de0acb557c3f8aecde9f8e2d8681b85b8 (patch) | |
| tree | 7e2bdf6b163ceb0c518370bb7fa32f47cea65e46 | |
| parent | 3f39e178279ca76f5d6090fb439000dcb3b4b2cd (diff) | |
| download | python-setuptools-git-ef78ba5de0acb557c3f8aecde9f8e2d8681b85b8.tar.gz | |
Add DISTUTILS_EXTRA_CONFIG option for passing setup.cfg overrides during build
| -rw-r--r-- | distutils/dist.py | 4 | ||||
| -rw-r--r-- | distutils/tests/test_dist.py | 21 | ||||
| -rw-r--r-- | docs/distutils/configfile.rst | 3 |
3 files changed, 27 insertions, 1 deletions
diff --git a/distutils/dist.py b/distutils/dist.py index 0406ab19..d854cd99 100644 --- a/distutils/dist.py +++ b/distutils/dist.py @@ -359,6 +359,10 @@ Common commands: (see '--help-commands' for more) if os.path.isfile(local_file): files.append(local_file) + extra_file = os.getenv("DISTUTILS_EXTRA_CONFIG") + if extra_file and os.path.isfile(extra_file): + files.append(extra_file) + if DEBUG: self.announce("using config files: %s" % ', '.join(files)) diff --git a/distutils/tests/test_dist.py b/distutils/tests/test_dist.py index 25056af5..e14d7da1 100644 --- a/distutils/tests/test_dist.py +++ b/distutils/tests/test_dist.py @@ -492,6 +492,27 @@ class TestMetadata(support.TempdirManager): finally: os.remove(user_filename) + def test_extra_pydistutils(self): + # make sure pydistutils.cfg is found + extra_filename = "overrides.cfg" + + temp_dir = self.mkdtemp() + extra_filename = os.path.join(temp_dir, extra_filename) + with open(extra_filename, 'w') as f: + f.write('.') + + # Testing will have been going terribly if this was set, but preserve + # it anyway (so it goes terribly but *consistently*) + old_extra_filename = os.environ.get("DISTUTILS_EXTRA_CONFIG") + os.environ["DISTUTILS_EXTRA_CONFIG"] = extra_filename + try: + dist = Distribution() + files = dist.find_config_files() + assert user_filename in files + finally: + os.remove(user_filename) + os.environ["DISTUTILS_EXTRA_CONFIG"] = old_extra_filename + def test_fix_help_options(self): help_tuples = [('a', 'b', 'c', 'd'), (1, 2, 3, 4)] fancy_options = fix_help_options(help_tuples) diff --git a/docs/distutils/configfile.rst b/docs/distutils/configfile.rst index 2a5c8329..e03d6d43 100644 --- a/docs/distutils/configfile.rst +++ b/docs/distutils/configfile.rst @@ -36,7 +36,8 @@ consequences: :file:`setup.py` * installers can override anything in :file:`setup.cfg` using the command-line - options to :file:`setup.py` + options to :file:`setup.py` or by pointing :envvar:`DISTUTILS_EXTRA_CONFIG` + to another configuration file The basic syntax of the configuration file is simple: |
