Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 358859

Summary: pygtk and pygobject cannot find Python.h during build
Product: Gentoo Linux Reporter: Chris <chris.kcat>
Component: [OLD] UnspecifiedAssignee: Gentoo Linux Gnome Desktop Team <gnome>
Status: RESOLVED INVALID    
Severity: normal CC: python
Priority: Normal    
Version: unspecified   
Hardware: x86   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: pygtk config.log

Description Chris 2011-03-14 12:15:31 UTC
Emerging pygtk (happens with pygobject, too) fails during configure, giving:

checking for headers required to compile python extensions... not found
configure: error: could not find Python headers

Checking the config.log, it appears the test is failing because Python.h is not found. Indeed, there is no Python.h in /usr/include, but there is in /usr/include/python2.6 and /usr/include/python3.1.

Running 'eselect python list' shows python2.6 as the active interpreter, next to python3.1. I've already tried running 'eselect python set python2.6', but it does not help.

Reproducible: Always

Steps to Reproduce:
1. emerge pygtk or pygobject
2.
3.
Actual Results:  
configure fails, unable to find Python.h

Expected Results:  
configure should succeed

Portage 2.1.9.25 (default/linux/x86/10.0/desktop, gcc-4.4.5, glibc-2.11.2-r3, 2.6.36-gentoo-r5 i686)
=================================================================
System uname: Linux-2.6.36-gentoo-r5-i686-AMD_Athlon-tm-_64_X2_Dual_Core_Processor_4200+-with-gentoo-1.12.14
Timestamp of tree: Mon, 14 Mar 2011 09:30:01 +0000
ccache version 2.4 [disabled]
app-shells/bash:     4.1_p9
dev-java/java-config: 2.1.11-r3
dev-lang/python:     2.6.6-r2, 3.1.3-r1
dev-util/ccache:     2.4-r9
dev-util/cmake:      2.8.1-r2
sys-apps/baselayout: 1.12.14-r1
sys-apps/sandbox:    2.4
sys-devel/autoconf:  2.13, 2.65-r1
sys-devel/automake:  1.7.9-r2, 1.8.5-r3::<unknown repository>, 1.9.6-r2::<unknown repository>, 1.10.3, 1.11.1
sys-devel/binutils:  2.20.1-r1
sys-devel/gcc:       4.4.5
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.2.10
sys-devel/make:      3.81-r2
virtual/os-headers:  2.6.36.1 (sys-kernel/linux-headers)
ACCEPT_KEYWORDS="x86"
ACCEPT_LICENSE="* -@EULA"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -march=i686 -pipe -march=athlon-tbird -O2 -fweb -funswitch-loops"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/php/apache2-php5.3/ext-active/ /etc/php/cgi-php5.3/ext-active/ /etc/php/cli-php5.3/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -march=i686 -pipe -march=athlon-tbird -O2 -fweb -funswitch-loops -O2 -march=i686 -pipe -fpermissive"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests binpkg-logs distlocks fixlafiles fixpackages news nostrip parallel-fetch protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox"
GENTOO_MIRRORS="http://gentoo.mirrors.hoobly.com/ ftp://gentoo.netnitco.net/pub/mirrors/gentoo/source/ http://gentoo.mirrors.easynews.com/linux/gentoo/ http://chi-10g-1-mirror.fastsoft.net/pub/linux/gentoo/gentoo-distfiles/ http://gentoo.netnitco.net"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-O1 -Wl,--enable-new-dtags -Wl,--sort-common -Wl,-z,combreloc"
LINGUAS="en"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_EXTRA_OPTS="--exclude-from=/etc/portage/rsync_excludes --compress-level=0"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/gamerlay /usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="3dnow 3dnowex 3dnowext X a52 aac acl acpi aiglx alsa anthy aotuv asf asm audiofile berkdb bidi bluetooth branding bzip2 cairo canna cdda cddb cdinstall cdio cdr cjk cli consolekit cracklib crypt css cups curl cxx dbus dedicated devil dga dirac divx4linux djbfft dri dts dvd dvdr dvdread emboss encode exif expat fam ffmpeg fftw firefox flac font-server fontconfig freetype gd gdbm gdu gif gimp git glitz glut gmp gnutls gpm gstreamer gtk httpd iconv idn imagemagick immqt-bc ipv6 jack jikes jpeg jpeg2k kate kde kdehiddenvisibility kipi lcms ldap libnotify libsamplerate lm_sensors logrotate mad md5sum midi mikmod mmap mmx mmxext mng modplug modules mp3 mp4 mpeg mplayer mudflap musicbrainz ncurses network networkmanager nls nodrm nptl nptlonly objc objc++ objc-gc offensive ogg openal openexr opengl openmp oscar pam pango pcre pdf perl physfs pic plasma png policykit ppds pppd pulseaudio python qt qt3support qt4 quotas readline rtc ruby samba sasl scanner schroedinger sdk sdl semantic-desktop session slang slp sndfile speex spell sse sse2 ssl startup-notification stream subversion svg sysfs tcltk tcpd theora tiff timidity truetype udev unicode usb userlocales utf8 v4l v4l2 vcd vdpau visualization vlm vorbis webdav webkit win32codecs winbind wxwindows x264 x86 xcb xchattext xcomposite xine xml xorg xosd xscreensaver xulrunner xv xvid xvmc yp yv12 zip zlib zvbi" ALSA_CARDS="emu10k1 hda-intel" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en" PHP_TARGETS="php5-3" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" 
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LC_ALL, MAKEOPTS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS
Comment 1 Gilles Dartiguelongue (RETIRED) gentoo-dev 2011-03-14 12:51:47 UTC
please attach full config.log as instricted by portage.
Comment 2 Chris 2011-03-14 12:58:08 UTC
Created attachment 265817 [details]
pygtk config.log
Comment 3 Pacho Ramos gentoo-dev 2011-03-16 09:11:45 UTC
That config.log is from old pygtk-2.17 instead of 2.22. Do you have your system fully updated?
Comment 4 Chris 2011-03-16 11:14:37 UTC
As of a couple days ago, I updated everything I could. If I try to update to pygtk-2.22.0-r1, it says it requires >=dev-python/pygobject-2.21.3:2 (current version is 2.20.0). The only pygobject versions available for that are 2.21.5, 2.26.0, and 2.26.0-r1, and all exhibit the same problem and won't build.
Comment 5 Pacho Ramos gentoo-dev 2011-03-17 10:23:48 UTC
Apart of your aggressive CFLAGS and CXXFLAGS I don't know what could be causing this problem to you :-( (maybe python team will know where could it be)
Comment 6 Pacho Ramos gentoo-dev 2011-04-02 17:15:02 UTC
Do you still suffer this problem with python-2.7 after running python-updater?
Comment 7 Chris 2011-04-03 08:50:36 UTC
(In reply to comment #6)
> Do you still suffer this problem with python-2.7 after running python-updater?

Yup. Unmasked and installed python-2.7.1-r1, ran python-updater and let it finish, ran 'eselect python set python2.7', then tried to emerge pygobject and it failed in the same way.
Comment 8 Pacho Ramos gentoo-dev 2011-04-03 09:35:40 UTC
Looks like nobody can reproduce, I am not sure if your aggressive CFLAGS and LDFLAGS could cause problems like this :-/, maybe you should use safer values for them and "emerge -e world"
Comment 9 Pacho Ramos gentoo-dev 2011-04-20 13:17:51 UTC
Try rebuilding your python installations with safer *FLAGS
Comment 10 Chris 2011-04-20 15:03:16 UTC
Still fails. Emptied CFLAGS, rebuilt python-2.6.6-r2 and 3.1.3-r1, then tried to build pygobject again, and it failed during configure in the same way.

It seems pygobject/pygtk's configure checks are only looking for Python.h in the standard include paths, not in /usr/include/python2.6 or /usr/include/python3.1, where they are.
Comment 11 Pacho Ramos gentoo-dev 2011-04-20 15:53:36 UTC
The problem is that you are the only one suffering this, then, we need to know what is wrong on your setup.

You should only have python-2.7 now after updating and running python-updater (not python-2.6), then, try to have only python3.1 and python2.7
Comment 12 Pacho Ramos gentoo-dev 2011-04-20 15:56:17 UTC
My working setup has the following files:

$ ls -l $(locate Python.h)
-rw-r--r-- 1 root root 4329 mar 24 22:22 /usr/include/python2.7/Python.h
-rw-r--r-- 1 root root 3502 mar  3 14:52 /usr/include/python3.1/Python.h
Comment 13 Chris 2011-04-21 22:09:22 UTC
Installed python:2.7, ran python-updater, selected python 2.7, uninstalled python:2.6.

# ls -l $(find /usr/include -name Python.h)
-rw-r--r-- 1 root root 4329 Apr 20 09:30 /usr/include/python2.7/Python.h
-rw-r--r-- 1 root root 3502 Apr 20 22:55 /usr/include/python3.1/Python.h

pygobject still fails during configure.
Comment 14 Chris 2011-04-22 02:40:33 UTC
I found the issue, but I don't know what the real cause is. It seems the /usr/bin/python-config script (generated by eselect python set ...) is broken and always errors. So I guess the configure script runs `python-config --cflags` or something to get compiler switches, which errors and returns an empty string. Since the proper cflags are never added, the -I switch is never specified to point to the python header directory, causing the failure.

This is the file as generated by eselect:
#!/usr/bin/env bash
# Gentoo python-config wrapper script

[[ "${EPYTHON}" =~ (/|^python$) ]] && EPYTHON="python2.7"
python_config="${EPYTHON/python/python-config-}"
"${0%/*}/${python_config:-python-config-2.7}" "$@"

I have to modify the line like this to make it work:
[[ "${EPYTHON}" =~ \(/\|^python$\) ]] && EPYTHON="python2.7"

With that change, pygobject and pygtk will build. However, this doesn't seem like a proper fix if eselect python is just going to generate a broken wrapper script again next time...
Comment 15 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2011-04-22 03:35:35 UTC
(In reply to comment #14)

What is printed by the following commands:
[[ "python" =~ (/|^python$) ]]; echo $?
[[ "python2.7" =~ (/|^python$) ]]; echo $?
[[ "python" =~ \(/\|^python$\) ]]; echo $?
[[ "python2.7" =~ \(/\|^python$\) ]]; echo $?
Comment 16 Chris 2011-04-22 03:55:04 UTC
# [[ "python" =~ (/|^python$) ]]; echo $?
0
# [[ "python2.7" =~ (/|^python$) ]]; echo $?
1
# [[ "python" =~ \(/\|^python$\) ]]; echo $?
1
# [[ "python2.7" =~ \(/\|^python$\) ]]; echo $?
1

When I run python-config (unmodified), however, I get:
# python-config
/usr/bin/python-config: line 4: unexpected argument `(' to conditional binary operator
/usr/bin/python-config: line 4: syntax error near `(/'
/usr/bin/python-config: line 4: `[[ "${EPYTHON}" =~ (/|^python$) ]] && EPYTHON="python2.7"'
Comment 17 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2011-04-22 04:08:42 UTC
You probably have an old bash in PATH.
Comment 18 Chris 2011-04-22 05:16:56 UTC
Hmm...

app-shells/bash:     4.1_p9

# bash --version
GNU bash, version 3.1.16(1)-release (i686-pc-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
# equery b `which bash`
[ Searching for file(s) /usr/bin/bash in *... ]
# 

Is it supposed to be in /usr/bin/bash? /var/db/pkg/app-shells/bash-4.1_p9/CONTENTS lists /bin/bash, but I don't want to just delete /usr/bin/bash without being sure it doesn't belong somewhere.
Comment 19 Gilles Dartiguelongue (RETIRED) gentoo-dev 2011-04-22 07:19:02 UTC
bash belongs to /bin, you can check if the files in /usr/bin belong to another package by running qfile:

# qfile /bin/bash
app-shells/bash (/bin/bash)

If the file doesn't belong to a package it probably is an error to have it here and you should clean it up. If you have other "strange" bugs like this, I suggest you start checking your system has no left-over files like that.

I'll leave this bug open to let Arfrever decide if he wants to support old bash.
Comment 20 Chris 2011-04-22 07:39:09 UTC
It seems at least eselect expects /usr/bin/bash for its interpreter, however neither qfile or equery b show /usr/bin/bash as belonging to anything. Is it supposed to be somehow generated?
Comment 21 Pacho Ramos gentoo-dev 2011-04-22 09:54:07 UTC
In my case I only have:

$ whereis bash
bash: /bin/bash /etc/bash /usr/share/man/man1/bash.1.bz2

$ equery b /bin/bash
* Searching for /bin/bash ... 
app-shells/bash-4.1_p9 (/bin/bash)

Then, I would remove (or move to your home if you want to be safer) that extra "bash" that you have in other places than /bin
Comment 22 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2011-04-22 16:26:45 UTC
You probably manually (without using package manager) built and installed another copy of bash long time ago.

We support only versions >=3.2 present in the main tree.
Comment 23 Chris 2011-04-23 04:38:40 UTC
Thanks, all of you. I cleaned out /usr/bin/bash, rebuilt some packages that had come to rely on it as its interpreter (including eselect and glibc), and things seem to be working now. :)

As an aside, is there some way to look for files in /usr/bin or /usr/lib and such (not /usr/local) that don't belong to a package, to help me avoid problems like this again?
Comment 24 Pacho Ramos gentoo-dev 2011-04-23 12:47:09 UTC
Probably running "qfile -o ..." or similar :-/