This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Option to ignore or substitute ~/.pydistutils.cfg
Type: enhancement Stage: patch review
Components: Distutils Versions: Python 3.4
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: jaraco Nosy List: akitada, akuchling, amcnabb, hoffman, jaraco, loewis, ncoghlan, ned.deily, pfein, pje, python-dev, slinkp, tarek
Priority: normal Keywords: easy, needs review, patch

Created on 2007-09-19 19:58 by hoffman, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
python_distutils_1180.patch slinkp, 2008-04-27 17:54 patch with monkeypatches in setup/teardown
python_distutils_1180_2.patch slinkp, 2008-04-27 17:55 patch using dependency injection
python_distutils_1180_3.patch slinkp, 2008-04-28 14:33 patch w/ monkeypatches in setup, simplified
3.4-patch.txt akuchling, 2013-11-10 23:11 review
Messages (29)
msg56044 - (view) Author: Michael Hoffman (hoffman) Date: 2007-09-19 20:00
It would be useful if instances had an option to ignore
~/.pydistutils.cfg or substitute it with another file. For example, this
would be highly useful to people who maintain a system site-packages
directory along with one in their own home directory.
msg63685 - (view) Author: Paul Winkler (slinkp) * Date: 2008-03-17 17:29
I'm working on this (at the pycon sprint).
msg64041 - (view) Author: Paul Winkler (slinkp) * Date: 2008-03-19 05:16
The attached patch implements a command-line option to disable loading
of $HOME/.pydistutils.cfg.

After talking to Martin Loewis, I decided not to implement the override
part, because if it's a one-time thing you can just pass the settings on
the command line; and if you have two configurations you want to use
frequently, you can just use two user accounts.

The hard part was writing tests, since the existing code was untested
and is environment-sensitive. See the comments in the patch re. what I
still don't like about it. I would like to have a less evil test setup
and teardown, but I'm going on vacation tomorrow so I won't be able to
look at this again until April.
msg64047 - (view) Author: Michael Hoffman (hoffman) Date: 2008-03-19 07:39
That is up to you of course, and being able to ignore is better than
nothing. But creating a new account is not really an option for
everyone. On the system I would like to use this feature the most, I am
not a system administrator, so I cannot create new user accounts. I
maintain a directory for production use of people in my workgroup. I
also maintain my own for testing and development.

Thanks for your work on this patch. At least being able to use
--no-user-cfg will be very helpful.
msg64054 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2008-03-19 13:12
We thought that the added value for specifying another configuration 
file is relatively minor: if you have to set command line options 
anyway, just put anything you want to specify on the command line, 
rather than into the other configuration file.

Out of curiosity: what kinds of settings do you put into the 
configuration file?
msg64056 - (view) Author: Michael Hoffman (hoffman) Date: 2008-03-19 14:06
Here's an example of a configuration file I use:

include_dirs = /nfs/acari/mh5/include/python2.5:/nfs/acari/mh5/include

prefix = ~
exec_prefix = ~/arch/$ARCH
install_platlib = $platbase/lib/python$py_version_short
install_purelib = $base/lib/python$py_version_short
install_scripts = $platbase/bin

install_dir = $platbase/lib/python$py_version_short
script_dir = $platbase/bin

I am installing software on a filesystem that is shared between
different architectures (i386 and x86_64), so I must have separate
directories for extensions on each platform. Because of this, using
--home=~ doesn't cut it.

I don't want to be a pain, if the --no-user-cfg can go in sooner, that
would be very helpful.
msg65783 - (view) Author: Paul Winkler (slinkp) * Date: 2008-04-25 14:16
Here's an alternate patch that uses a bit of dependency injection to
avoid the need for monkeypatches in setup/teardown. This means some
trivial changes to Distribution.__init__().  I slightly prefer this
approach, but some might argue it's an example of "test logic in

I also added a line about the new option in Doc/install/index.rst.

Since I don't have checkin privileges, I will stop here. Can somebody
upstream (Martin?) please take one of these patches and apply it? Or
suggest further changes to either of these patches?  Or ... ?
msg65854 - (view) Author: PJ Eby (pje) * (Python committer) Date: 2008-04-26 21:09
Both versions of the patch have a problem, in that the Distribution
object is looking for an option directly in sys.argv.  At the very
least, this should be looking at the 'script_args' attribute of the
Distribution instead (if not actually parsing the command line enough to
find the option).
msg65886 - (view) Author: Paul Winkler (slinkp) * Date: 2008-04-27 17:53
Phillip, thanks, I missed that script_args is always passed by
core.setup(). I'm replacing the patches with two new versions that check
self.script_args instead of sys.argv (and assumes false if for some
reason script_args isn't passed).

We can't check for it in Distribution.parse_command_line() because that
doesn't get called until after loading the config files.
msg65887 - (view) Author: Paul Winkler (slinkp) * Date: 2008-04-27 17:55
and here's the revised version of the dependency-injection approach.
msg65891 - (view) Author: PJ Eby (pje) * (Python committer) Date: 2008-04-27 18:25
I much prefer the simpler of the two patches - better to monkeypatch in
the tests than adding complications to the already over-complicated
distutils.dist.  I don't find monkeypatching in tests to be horrible at
all, but if it really bothers you, just create a temporary directory for
HOME to point to, and test a Distribution subclass with an overridden

By the way, the patch could be simpler if you just made the "if 'HOME'
in os.environ" read "if not self.no_user_cfg and 'HOME' in os.environ",
rather than reworking the entire code region.  On the other hand, if
you'd rather have ultra-clean unit tests, you could split the
functionality of find_config_files() into two methods: one that creates
the candidate list and the other that filters it by existence.

Personally, my vote is to keep the monkeypatching in the tests and make
the barest minimal changes to the Distribution class though.
msg65920 - (view) Author: Paul Winkler (slinkp) * Date: 2008-04-28 14:33
Phillip, here's another revision of the monkeypatch-in-setUp() approach,
simplified per your suggestions.
msg65921 - (view) Author: PJ Eby (pje) * (Python committer) Date: 2008-04-28 15:49
It looks like you can drop the change to distutils.core, too, since 
it's just a change in the comment, and the changed comment is 
inaccurate, AFAICT.  Apart from that, it looks good.
msg65955 - (view) Author: Paul Winkler (slinkp) * Date: 2008-04-29 04:06
In what way is the comment in inaccurate? I only added the
phrase "and override config files", which is an important side effect of
msg65967 - (view) Author: PJ Eby (pje) * (Python committer) Date: 2008-04-29 13:58
Oh, I thought you meant that it overrides *which* config files -- 
i.e., implied that it was handling --no-user-config.
msg68739 - (view) Author: Peter Fein (pfein) Date: 2008-06-25 17:47
Is this going to make the 2.6 release?  The lack of this option causes 
grief on MacPorts.  Just wondering if there's anything I could do to move 
this along, as a cursory reading shows everyone to be happy...
msg68755 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2008-06-25 20:29
Formally, the beta deadline has passed, so no new features can be
admitted. If pje is now happy with the code as it stands (not clear from
the last message), I can ask for permission to commit it, anyway.
msg68761 - (view) Author: PJ Eby (pje) * (Python committer) Date: 2008-06-25 21:56
I'm good with it; the issue with the comment in was my only 
remaining objection.
msg77386 - (view) Author: Paul Winkler (slinkp) * Date: 2008-12-09 02:12
Whatever happened with this? I don't see it mentioned in the NEWS file
for the 2.6 line.
msg77466 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2008-12-09 22:35
Unfortunately, it missed the deadlines (i.e. nobody checked it in in
time). I'll look into it.
msg80655 - (view) Author: Akira Kitada (akitada) * Date: 2009-01-27 16:31
Any update?
Is this patch going to be included in 2.6.x/3.0.x in near future?
msg87645 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-05-12 17:22
I am taking over this issue (I am figuring out you are OK with this
Martin) and put it in my work pile so it goes in 2.7
msg94585 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-10-27 23:15
I've simplified the tests so they just check that [.]pydistutils.cfg is
taken or not taken, depending if the option is used.

I've also made sure the option is just looked in the global options,
because the patch was implying that a command local option with the same
name could work.

Done in r75893 and r75895.

Thanks a lot Paul !
msg176439 - (view) Author: Andrew McNabb (amcnabb) Date: 2012-11-26 19:05
The --no-user-cfg option works for me in Python 2.7, but it does not seem to be in Python 3.2 or 3.3:

    error: option --no-user-cfg not recognized

Am I doing something wrong, or was this feature only added to Python 2.7?
msg178376 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-12-28 09:29
Andrew, comments to closed issues are usually ignored.  I suggest you open a new issue about this.  A quick glance suggests that the code for this feature is not in Python 3.  It may be that it was lost when, during the 2.7 development cycle, it was decided to not allow new features to Distutils and a number of changes were reverted.  There have been some other cases of Distutils changes that were lost in Python 3.2+ because of this.
msg202577 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2013-11-10 21:50
Confirmed - and to be included in issue19544.
msg202583 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2013-11-10 23:11
Here's a patch to restore the --no-user-cfg switch to 3.4.  If someone will take a quick look at the patch for sanity, I can apply it.
msg202947 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2013-11-15 12:37
Patch looks good to me.
msg202980 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-11-15 23:57
New changeset c35311fcc967 by Andrew Kuchling in branch 'default':
Issue #19544 and Issue #1180: Restore global option to ignore  ~/.pydistutils.cfg in Distutils, accidentally removed in backout of distutils2 changes.
Date User Action Args
2022-04-11 14:56:27adminsetgithub: 45521
2013-11-16 00:00:20jaracosetstatus: open -> closed
2013-11-15 23:57:08python-devsetnosy: + python-dev
messages: + msg202980
2013-11-15 18:08:37jaracosetassignee: akuchling -> jaraco
2013-11-15 12:37:09ncoghlansetnosy: + ncoghlan
messages: + msg202947
2013-11-10 23:11:07akuchlingsetfiles: + 3.4-patch.txt
versions: + Python 3.4, - Python 3.1, Python 2.7, Python 3.2
messages: + msg202583

keywords: + needs review
resolution: fixed ->
stage: patch review
2013-11-10 22:56:06jaracosetstatus: closed -> open
2013-11-10 22:55:39jaracosetassignee: tarek -> akuchling

nosy: + akuchling
2013-11-10 21:50:54jaracosetnosy: + jaraco
messages: + msg202577
2012-12-28 09:29:02ned.deilysetnosy: + ned.deily
messages: + msg178376
2012-11-26 19:05:09amcnabbsetnosy: + amcnabb
messages: + msg176439
2009-10-27 23:15:33tareksetstatus: open -> closed
resolution: accepted -> fixed
messages: + msg94585
2009-09-17 11:09:57tareksetpriority: critical -> normal
2009-09-17 11:09:30tareksetresolution: accepted
versions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6
2009-05-12 17:22:26tareksetassignee: loewis -> tarek
messages: + msg87645
2009-01-27 16:31:34akitadasetnosy: + tarek
messages: + msg80655
2009-01-04 20:24:09akitadasetnosy: + akitada
2008-12-09 22:35:50loewissetpriority: normal -> critical
assignee: loewis
messages: + msg77466
2008-12-09 02:12:18slinkpsetmessages: + msg77386
2008-06-25 21:56:42pjesetmessages: + msg68761
2008-06-25 20:29:31loewissetmessages: + msg68755
2008-06-25 17:47:41pfeinsetnosy: + pfein
messages: + msg68739
2008-04-29 13:58:13pjesetmessages: + msg65967
2008-04-29 04:06:12slinkpsetmessages: + msg65955
2008-04-28 15:49:50pjesetmessages: + msg65921
2008-04-28 14:33:32slinkpsetfiles: + python_distutils_1180_3.patch
messages: + msg65920
2008-04-27 18:25:43pjesetmessages: + msg65891
2008-04-27 17:55:35slinkpsetfiles: + python_distutils_1180_2.patch
messages: + msg65887
2008-04-27 17:54:42slinkpsetfiles: - python_distutils_1180.patch
2008-04-27 17:54:25slinkpsetfiles: + python_distutils_1180.patch
messages: + msg65886
2008-04-27 17:15:34slinkpsetfiles: - python_distutils_1180_2.patch
2008-04-26 21:09:38pjesetnosy: + pje
messages: + msg65854
2008-04-25 14:16:56slinkpsetfiles: + python_distutils_1180_2.patch
messages: + msg65783
2008-03-19 14:06:55hoffmansetmessages: + msg64056
2008-03-19 13:12:28loewissetmessages: + msg64054
2008-03-19 07:39:32hoffmansetmessages: + msg64047
2008-03-19 05:20:09slinkpsetfiles: + python_distutils_1180.patch
2008-03-19 05:19:28slinkpsetfiles: - python_distutils_1180.patch
2008-03-19 05:16:36slinkpsetfiles: + python_distutils_1180.patch
keywords: + patch
messages: + msg64041
2008-03-18 16:45:48slinkpsetnosy: + loewis
2008-03-17 17:29:14slinkpsetnosy: + slinkp
messages: + msg63685
2008-01-12 01:58:10christian.heimessetkeywords: + easy
2007-09-19 20:14:03jafosetpriority: normal
2007-09-19 20:00:26hoffmansettitle: Option to ignore ~/.pydistutils.cfg -> Option to ignore or substitute ~/.pydistutils.cfg
2007-09-19 20:00:08hoffmansetnosy: + hoffman
messages: + msg56044
2007-09-19 19:58:22hoffmancreate