mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 07:31:38 +00:00 
			
		
		
		
	Merged revisions 75893 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r75893 | tarek.ziade | 2009-10-28 00:06:10 +0100 (Wed, 28 Oct 2009) | 1 line Fixed #1180: Option to ignore ~/.pydistutils.cfg in Distutils ........
This commit is contained in:
		
							parent
							
								
									70ec8ee2ed
								
							
						
					
					
						commit
						c7c71ff87c
					
				
					 7 changed files with 73 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -208,6 +208,7 @@ docs@python.org), and we'll be glad to correct the problem.
 | 
			
		|||
   * Mats Wichmann
 | 
			
		||||
   * Gerry Wiener
 | 
			
		||||
   * Timothy Wild
 | 
			
		||||
   * Paul Winkler
 | 
			
		||||
   * Collin Winter
 | 
			
		||||
   * Blake Winton
 | 
			
		||||
   * Dan Wolfe
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -241,7 +241,8 @@ tedious and error-prone, so it's usually best to put them in the setup
 | 
			
		|||
configuration file, :file:`setup.cfg`\ ---see section :ref:`setup-config`.  If
 | 
			
		||||
you distribute or package many Python module distributions, you might want to
 | 
			
		||||
put options that apply to all of them in your personal Distutils configuration
 | 
			
		||||
file (:file:`~/.pydistutils.cfg`).
 | 
			
		||||
file (:file:`~/.pydistutils.cfg`).  If you want to temporarily disable
 | 
			
		||||
this file, you can pass the --no-user-cfg option to setup.py.
 | 
			
		||||
 | 
			
		||||
There are three steps to building a binary RPM package, all of which are
 | 
			
		||||
handled automatically by the Distutils:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -691,6 +691,9 @@ And on Windows, the configuration files are:
 | 
			
		|||
| local        | :file:`setup.cfg`                               | \(3)  |
 | 
			
		||||
+--------------+-------------------------------------------------+-------+
 | 
			
		||||
 | 
			
		||||
On all platforms, the "personal" file can be temporarily disabled by
 | 
			
		||||
passing the `--no-user-cfg` option.
 | 
			
		||||
 | 
			
		||||
Notes:
 | 
			
		||||
 | 
			
		||||
(1)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -129,8 +129,9 @@ class found in 'cmdclass' is used in place of the default, which is
 | 
			
		|||
    if _setup_stop_after == "config":
 | 
			
		||||
        return dist
 | 
			
		||||
 | 
			
		||||
    # Parse the command line; any command-line errors are the end user's
 | 
			
		||||
    # fault, so turn them into SystemExit to suppress tracebacks.
 | 
			
		||||
    # Parse the command line and override config files; any
 | 
			
		||||
    # command-line errors are the end user's fault, so turn them into
 | 
			
		||||
    # SystemExit to suppress tracebacks.
 | 
			
		||||
    try:
 | 
			
		||||
        ok = dist.parse_command_line()
 | 
			
		||||
    except DistutilsArgError as msg:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -53,6 +53,8 @@ class Distribution:
 | 
			
		|||
                      ('quiet', 'q', "run quietly (turns verbosity off)"),
 | 
			
		||||
                      ('dry-run', 'n', "don't actually do anything"),
 | 
			
		||||
                      ('help', 'h', "show detailed help message"),
 | 
			
		||||
                      ('no-user-cfg', None,
 | 
			
		||||
                       'ignore pydistutils.cfg in your home directory'),
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
    # 'common_usage' is a short (2-3 line) string describing the common
 | 
			
		||||
| 
						 | 
				
			
			@ -260,6 +262,22 @@ def __init__ (self, attrs=None):
 | 
			
		|||
                    else:
 | 
			
		||||
                        sys.stderr.write(msg + "\n")
 | 
			
		||||
 | 
			
		||||
        # no-user-cfg is handled before other command line args
 | 
			
		||||
        # because other args override the config files, and this
 | 
			
		||||
        # one is needed before we can load the config files.
 | 
			
		||||
        # If attrs['script_args'] wasn't passed, assume false.
 | 
			
		||||
        #
 | 
			
		||||
        # This also make sure we just look at the global options
 | 
			
		||||
        self.want_user_cfg = True
 | 
			
		||||
 | 
			
		||||
        if self.script_args is not None:
 | 
			
		||||
            for arg in self.script_args:
 | 
			
		||||
                if not arg.startswith('-'):
 | 
			
		||||
                    break
 | 
			
		||||
                if arg == '--no-user-cfg':
 | 
			
		||||
                    self.want_user_cfg = False
 | 
			
		||||
                    break
 | 
			
		||||
 | 
			
		||||
        self.finalize_options()
 | 
			
		||||
 | 
			
		||||
    def get_option_dict(self, command):
 | 
			
		||||
| 
						 | 
				
			
			@ -311,7 +329,10 @@ def find_config_files(self):
 | 
			
		|||
        Distutils installation directory (ie. where the top-level
 | 
			
		||||
        Distutils __inst__.py file lives), a file in the user's home
 | 
			
		||||
        directory named .pydistutils.cfg on Unix and pydistutils.cfg
 | 
			
		||||
        on Windows/Mac, and setup.cfg in the current directory.
 | 
			
		||||
        on Windows/Mac; and setup.cfg in the current directory.
 | 
			
		||||
 | 
			
		||||
        The file in the user's home directory can be disabled with the
 | 
			
		||||
        --no-user-cfg option.
 | 
			
		||||
        """
 | 
			
		||||
        files = []
 | 
			
		||||
        check_environ()
 | 
			
		||||
| 
						 | 
				
			
			@ -331,6 +352,7 @@ def find_config_files(self):
 | 
			
		|||
            user_filename = "pydistutils.cfg"
 | 
			
		||||
 | 
			
		||||
        # And look for the user config file
 | 
			
		||||
        if self.want_user_cfg:
 | 
			
		||||
            user_file = os.path.join(os.path.expanduser('~'), user_filename)
 | 
			
		||||
            if os.path.isfile(user_file):
 | 
			
		||||
                files.append(user_file)
 | 
			
		||||
| 
						 | 
				
			
			@ -340,6 +362,9 @@ def find_config_files(self):
 | 
			
		|||
        if os.path.isfile(local_file):
 | 
			
		||||
            files.append(local_file)
 | 
			
		||||
 | 
			
		||||
        if DEBUG:
 | 
			
		||||
            self.announce("using config files: %s" % ', '.join(files))
 | 
			
		||||
 | 
			
		||||
        return files
 | 
			
		||||
 | 
			
		||||
    def parse_config_files(self, filenames=None):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,7 +37,8 @@ def find_config_files(self):
 | 
			
		|||
        return self._config_files
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DistributionTestCase(support.LoggingSilencer,
 | 
			
		||||
class DistributionTestCase(support.TempdirManager,
 | 
			
		||||
                           support.LoggingSilencer,
 | 
			
		||||
                           support.EnvironGuard,
 | 
			
		||||
                           unittest.TestCase):
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -180,6 +181,35 @@ def test_announce(self):
 | 
			
		|||
        kwargs = {'level': 'ok2'}
 | 
			
		||||
        self.assertRaises(ValueError, dist.announce, args, kwargs)
 | 
			
		||||
 | 
			
		||||
    def test_find_config_files_disable(self):
 | 
			
		||||
        # Ticket #1180: Allow user to disable their home config file.
 | 
			
		||||
        temp_home = self.mkdtemp()
 | 
			
		||||
        if os.name == 'posix':
 | 
			
		||||
            user_filename = os.path.join(temp_home, ".pydistutils.cfg")
 | 
			
		||||
        else:
 | 
			
		||||
            user_filename = os.path.join(temp_home, "pydistutils.cfg")
 | 
			
		||||
 | 
			
		||||
        with open(user_filename, 'w') as f:
 | 
			
		||||
            f.write('[distutils]\n')
 | 
			
		||||
 | 
			
		||||
        def _expander(path):
 | 
			
		||||
            return temp_home
 | 
			
		||||
 | 
			
		||||
        old_expander = os.path.expanduser
 | 
			
		||||
        os.path.expanduser = _expander
 | 
			
		||||
        try:
 | 
			
		||||
            d = distutils.dist.Distribution()
 | 
			
		||||
            all_files = d.find_config_files()
 | 
			
		||||
 | 
			
		||||
            d = distutils.dist.Distribution(attrs={'script_args':
 | 
			
		||||
                                            ['--no-user-cfg']})
 | 
			
		||||
            files = d.find_config_files()
 | 
			
		||||
        finally:
 | 
			
		||||
            os.path.expanduser = old_expander
 | 
			
		||||
 | 
			
		||||
        # make sure --no-user-cfg disables the user cfg file
 | 
			
		||||
        self.assertEquals(len(all_files)-1, len(files))
 | 
			
		||||
 | 
			
		||||
class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
 | 
			
		||||
                       unittest.TestCase):
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -117,6 +117,9 @@ C-API
 | 
			
		|||
Library
 | 
			
		||||
-------
 | 
			
		||||
 | 
			
		||||
- Issue #1180: Added a new global option to ignore ~/.pydistutils.cfg in
 | 
			
		||||
  Distutils.
 | 
			
		||||
 | 
			
		||||
- Issue #7218: Fix test_site for win32, the directory comparison was done with
 | 
			
		||||
  an uppercase.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue