NetBSD Problem Report #48068

From www@NetBSD.org  Fri Jul 19 16:06:24 2013
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 8840A71E28
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 19 Jul 2013 16:06:24 +0000 (UTC)
Message-Id: <20130719160622.F191771E2A@mollari.NetBSD.org>
Date: Fri, 19 Jul 2013 16:06:22 +0000 (UTC)
From: slitvinov@gmail.com
Reply-To: slitvinov@gmail.com
To: gnats-bugs@NetBSD.org
Subject: lang/python27 fails to build with `ImportError: No module named _sysconfigdata'
X-Send-Pr-Version: www-1.0

>Number:         48068
>Category:       pkg
>Synopsis:       lang/python27 fails to build with `ImportError: No module named _sysconfigdata'
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jul 19 16:10:00 +0000 2013
>Originator:     LItvinov Sergey
>Release:        Ubuntu Linux
>Organization:
>Environment:
Linux acer 3.8.0-26-generic #38-Ubuntu SMP Mon Jun 17 21:43:33 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
>Description:
`bmake build' fails with the following error

===> Building for python27-2.7.5
--- sharedmods ---
Traceback (most recent call last):
  File "/home/vital303/pkgsrc/lang/python27/work/Python-2.7.5/Lib/site.py", line 548, in <module>
    main()
  File "/home/vital303/pkgsrc/lang/python27/work/Python-2.7.5/Lib/site.py", line 530, in main
    known_paths = addusersitepackages(known_paths)
  File "/home/vital303/pkgsrc/lang/python27/work/Python-2.7.5/Lib/site.py", line 266, in addusersitepackages
    user_site = getusersitepackages()
  File "/home/vital303/pkgsrc/lang/python27/work/Python-2.7.5/Lib/site.py", line 241, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/home/vital303/pkgsrc/lang/python27/work/Python-2.7.5/Lib/site.py", line 231, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/home/vital303/pkgsrc/lang/python27/work/Python-2.7.5/Lib/sysconfig.py", line 516, in get_config_var
    return get_config_vars().get(name)
  File "/home/vital303/pkgsrc/lang/python27/work/Python-2.7.5/Lib/sysconfig.py", line 468, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/home/vital303/pkgsrc/lang/python27/work/Python-2.7.5/Lib/sysconfig.py", line 352, in _init_posix
    from _sysconfigdata import build_time_vars
ImportError: No module named _sysconfigdata
*** [sharedmods] Error code 1

bmake: stopped in /home/vital303/pkgsrc/lang/python27/work/Python-2.7.5
1 error

I think those reports are relevant (_sysconfigdata.py was backported
to python2 from python3):
[Python 3.3] Most of Python's startup time is sysconfig
http://bugs.python.org/issue13150
[Python 3.3] _sysconfigdata.py doesn't support multiple build configurations
http://bugs.python.org/issue14774
[Python 3.3, 3.4] _sysconfigdata is generated in srcdir, not builddir
http://bugs.python.org/issue15298

I copied 
cp ./work/Python-2.7.5/build/lib.linux-x86_64-2.7/_sysconfigdata.py ./work/Python-2.7.5/Lib/
and did
bmake build

The build goes further but fails with the following error during installation

#+BEGIN_EXAMPLE
/usr/bin/install -c -o vital303 -g vital303 -m 755 ./Lib/plat-linux2/regen /home/vital303/netbsd/lib/python2.7/plat-linux2
/usr/bin/install -c -o vital303 -g vital303 -m 644 ./LICENSE /home/vital303/pkgsrc/lang/python27/work/.destdir/home/vital303/netbsd/lib/python2.7/LICENSE.txt
if test -d /home/vital303/pkgsrc/lang/python27/work/.destdir/home/vital303/netbsd/lib/python2.7/distutils/tests; then  /usr/bin/install -c -o vital303 -g vital303 -m 644 ./Modules/xxmodule.c  /home/vital303/pkgsrc/lang/python27/work/.destdir/home/vital303/netbsd/lib/python2.7/distutils/tests ;  fi
PYTHONPATH=/home/vital303/pkgsrc/lang/python27/work/.destdir/home/vital303/netbsd/lib/python2.7  LD_LIBRARY_PATH=/home/vital303/pkgsrc/lang/python27/work/Python-2.7.5:  ./python -E -Wi -tt /home/vital303/pkgsrc/lang/python27/work/.destdir/home/vital303/netbsd/lib/python2.7/compileall.py  -d /home/vital303/netbsd/lib/python2.7 -f  -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data'  /home/vital303/pkgsrc/lang/python27/work/.destdir/home/vital303/netbsd/lib/python2.7
Traceback (most recent call last):
  File "/home/vital303/pkgsrc/lang/python27/work/.destdir/home/vital303/netbsd/lib/python2.7/compileall.py", line 16, in <module>
    import struct
  File "/home/vital303/pkgsrc/lang/python27/work/.destdir/home/vital303/netbsd/lib/python2.7/struct.py", line 1, in <module>
    from _struct import *
ImportError: No module named _struct
*** Error code 1
#+END_EXAMPLE

I found the following bug report
[Python 2.7] make install error: ImportError: No module named _struct
http://bugs.python.org/issue15066

I can get the same error message if I do
./work/Python-2.7.5/python -c "import struct"
ImportError: No module named _struct

But if I copy python binary to another directory:
cp ./work/Python-2.7.5/python .
./python -c "import struct"
gives no error

If I revert `lang/python27' to python 2.7.4 installation goes without
errors.

>How-To-Repeat:
`bmake build' in lang/python27
>Fix:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.