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.

classification
Title: Can't build Python on POSIX w/o $HOME
Type: behavior Stage: resolved
Components: Build, Distutils, Extension Modules Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: tarek Nosy List: ajaksu2, barry, eric.araujo, georg.brandl, jhein-sf, loewis, tarek
Priority: normal Keywords:

Created on 2004-05-24 17:16 by barry, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (12)
msg20870 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2004-05-24 17:16
If you're building Python on os.name == 'posix' but
when there is no $HOME defined in your environment, you
cannot build Python.  This is because in the bowels of
distutils, you end up in check_environ(), which has
these lines:

    if os.name == 'posix' and not
os.environ.has_key('HOME'):
        import pwd
        os.environ['HOME'] = pwd.getpwuid(os.getuid())[5]

However, in a from-scratch build, the pwd module isn't
built by the time you get here.  I found this when
using SCons to build Python, since by default the
enclosing environment isn't passed to subprocesses.

I can work around this in my builds but Python's
setup.py should probably synthesize a $HOME if one
doesn't exist.  (Or maybe someone has a better idea for
a workaround).
msg20871 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-09-22 07:19
Logged In: YES 
user_id=1188172

Seems that the pwdmodule entry in Modules/Setup.dist must be
uncommented.
msg20872 - (view) Author: John Hein (jhein-sf) Date: 2005-09-29 19:14
Logged In: YES 
user_id=59465

I had this problem, too.
The fix proposed by birkenfeld on 9/22 works for me.
msg20873 - (view) Author: John Hein (jhein-sf) Date: 2005-09-29 19:28
Logged In: YES 
user_id=59465

Let me revise that last comment.  There are some build
differences when this is done.

Uncommenting pwd in Setup.dist allows python to build, but
the 'pwd' extension (and pwd.so) does not get built.

And pwdmodule.o is ar'd into libpython2.4.a (& linked into
libpython2.4.so)
msg20874 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-09-29 20:04
Logged In: YES 
user_id=1188172

Well, pwd will be built-in then, if that's a problem.

Assigning to loewis to look over it.
msg20875 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2005-10-02 08:57
Logged In: YES 
user_id=21627

Making pwd builtin is fine with me. Make sure you move the
line to the other builtin modules, and add a comment telling
why it is need (i.e. when HOME isn't set).
msg20876 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-12-27 17:37
Logged In: YES 
user_id=1188172

I made the suggested change in revision 41834/41835.
msg20877 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-01-02 22:09
Logged In: YES 
user_id=1188172

Guido said:
"""
Hm. Methinks that the distutils code should have been patched to
survive the possibility of "import pwd" failing (or
pwd.getpwuid()
failing!) rather than hiding the problem by forcing pwd to
be built.
The latter seems a much less robust solution.
"""

Who is responsible for distutils?
msg20878 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2006-01-02 22:11
Logged In: YES 
user_id=21627

There isn't a specific maintainer for distutils; it's nearly
unmaintained.
msg20879 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-01-02 22:15
Logged In: YES 
user_id=1188172

Okay, so I think I'll leave the fix in for the time being.
msg82050 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-02-14 13:55
Fixed by 41834. Please leave open if reverting the fix and patching
distutils is still a option, close if not.
msg112238 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-08-01 00:37
It seems too late to make the fix Guido suggested, since there have been a number of releases with pwd as built-in module now. Closing soon if there are no comments.
History
Date User Action Args
2022-04-11 14:56:04adminsetgithub: 40285
2010-09-02 18:36:01eric.araujosetstatus: pending -> closed
stage: test needed -> resolved
2010-08-01 00:37:59eric.araujosetstatus: open -> pending
nosy: + eric.araujo
messages: + msg112238

2009-02-14 13:55:22ajaksu2setnosy: + ajaksu2, tarek
messages: + msg82050
assignee: tarek
components: + Distutils, Extension Modules
type: behavior
stage: test needed
2004-05-24 17:16:56barrycreate