Author vstinner
Recipients Denis.Barmenkov, Jonathon Reinhart, Nicholas Brown, aikinci, antoine.pietri, arekm, bbi5291, christian.heimes, cinerar, eric.araujo, filippo, georg.brandl, grahamd, izbyshev, loewis, matrixise, nadeem.vawda, ned.deily, neologix, r.david.murray, serhiy.storchaka, surajd, tarek, vstinner, xuanji, yan12125, zaytsev
Date 2018-12-05.14:46:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1544021161.98.0.788709270274.issue10496@psf.upfronthosting.co.za>
In-reply-to
Content
> If I understood PR 10919 correctly, sysconfig.get_config_var('userbase') can now return unexpanded paths containing '~'. Is it intended despite the previous discussion starting with msg135047?

With my PR 10919, "python3 setup.py install" and  "python3 setup.py install --user" still fail with:

Traceback (most recent call last):
  File "setup.py", line 79, in <module>
    main()
  File "setup.py", line 75, in main
    setup(**options)
  File "/tmp/cpython/Lib/distutils/core.py", line 121, in setup
    dist.parse_config_files()
  File "/tmp/cpython/Lib/distutils/dist.py", line 397, in parse_config_files
    filenames = self.find_config_files()
  File "/tmp/cpython/Lib/distutils/dist.py", line 349, in find_config_files
    check_environ()
  File "/tmp/cpython/Lib/distutils/util.py", line 161, in check_environ
    os.environ['HOME'] = pwd.getpwuid(os.getuid())[5]
KeyError: 'getpwuid(): uid not found: 12345'

I suggest to open a new issue if you want to enhance the error message and/or handle getpwuid() failure in find_config_files().

I prefer to stick to the initial bug report which hasn't been fixed in 8 years:

> When Python cannot find the home directory of the user invoking it, it prints "'import site' failed; use -v for traceback".

IMHO PR 10919 fix is straighforward, it respects the contract (documentation) of posixpath.expanduser() ("If user or $HOME is unknown, do nothing."), and expanduser() already handles KeyError on getpwnam() (since the function has been created in 1992 by Guido van Rossum! commit 7ac4878773040158038031a85be122d9e7071afe).
History
Date User Action Args
2018-12-05 14:46:02vstinnersetrecipients: + vstinner, loewis, georg.brandl, arekm, christian.heimes, nadeem.vawda, tarek, ned.deily, eric.araujo, grahamd, r.david.murray, neologix, filippo, xuanji, bbi5291, Denis.Barmenkov, aikinci, serhiy.storchaka, matrixise, zaytsev, antoine.pietri, yan12125, Jonathon Reinhart, surajd, izbyshev, cinerar, Nicholas Brown
2018-12-05 14:46:01vstinnersetmessageid: <1544021161.98.0.788709270274.issue10496@psf.upfronthosting.co.za>
2018-12-05 14:46:01vstinnerlinkissue10496 messages
2018-12-05 14:46:01vstinnercreate