Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 424627 - setools failing to compile because of bad Python environment
Summary: setools failing to compile because of bad Python environment
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: SELinux (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Sven Vermeulen (RETIRED)
Whiteboard: selinux-utils
Depends on:
Reported: 2012-07-03 17:03 UTC by J.C. Wren
Modified: 2012-12-30 15:29 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---

build.log from emerge -q setools (build.log,10.55 KB, text/plain)
2012-07-03 17:05 UTC, J.C. Wren
config.log from emerge -q setools (config.log,107.41 KB, text/plain)
2012-07-03 20:08 UTC, J.C. Wren
configure script from /var/tmp/portage/app-admin/setools-3.3.7-r3/work/setools-3.3.7 (configure,711.16 KB, text/plain)
2012-07-16 18:13 UTC, J.C. Wren
Updated ebuild (setools-3.3.7-r4.ebuild,4.92 KB, text/plain)
2012-07-17 17:42 UTC, Sven Vermeulen (RETIRED)
Updated ebuild (setools-3.3.7-r4.ebuild,4.79 KB, text/plain)
2012-08-15 13:19 UTC, Sven Vermeulen (RETIRED)

Note You need to log in before you can comment on or make changes to this bug.
Description J.C. Wren 2012-07-03 17:03:58 UTC
setools is failing to build, claiming it can't link a test program to Python

Reproducible: Always

Steps to Reproduce:
1.emerge -q setools
Actual Results:  
checking for python... /usr/bin/python
checking for the distutils Python package... yes
checking for Python include path... -I/usr/include/python2.7
checking for Python library path... ('-L/usr/lib/python2.7', '-lpython2.7')
checking for Python site-packages path... /usr/lib/python2.7/site-packages
checking python extra libraries... ('', '-lpthread -ldl  -lutil')
checking python extra linking flags... -Xlinker -export-dynamic
checking consistency of all components of python development environment... no
configure: error:
  Could not link test program to Python. Maybe the main Python library has been
  installed in some non-standard library path. If so, pass it to configure,
  via the LDFLAGS environment variable.
  Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib"
   You probably have to install the development version of the Python package
   for your distribution.  The exact name of this package varies among them.

Expected Results:  
Successful compile

I'm not aware of a separate Python development library, and looking through 'emerge -s python', I didn't see anything I considered a candidate. If setools needs this to build, shouldn't it be in the dependency list?
Comment 1 J.C. Wren 2012-07-03 17:04:46 UTC
# emerge --info '=app-admin/setools-3.3.7-r3'
Portage (hardened/linux/x86/selinux, gcc-4.6.3, glibc-2.15-r2, 3.4.3-hardened-r1-raid i686)
                        System Settings
System uname: Linux-3.4.3-hardened-r1-raid-i686-Intel-R-_Pentium-R-_4_CPU_2.80GHz-with-gentoo-2.1
Timestamp of tree: Tue, 03 Jul 2012 04:45:01 +0000
app-shells/bash:          4.2_p29
dev-java/java-config:     2.1.12
dev-lang/python:          2.7.3-r2
dev-util/cmake:           2.8.8-r3
dev-util/pkgconfig:       0.26
sys-apps/baselayout:      2.1-r1
sys-apps/openrc:          0.10.4
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.69
sys-devel/automake:       1.11.5, 1.12.1
sys-devel/binutils:       2.22-r1
sys-devel/gcc:            4.6.3
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4.2
sys-devel/make:           3.82-r3
sys-kernel/linux-headers: 3.4 (virtual/os-headers)
sys-libs/glibc:           2.15-r2
Repositories: gentoo hardened-dev x-portage
CFLAGS="-O2 -march=pentium4 -pipe -fomit-frame-pointer"
CONFIG_PROTECT="/etc /var/bind"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/init.d /etc/php/apache2-php5.3/ext-active/ /etc/php/apache2-php5.4/ext-active/ /etc/php/cgi-php5.3/ext-active/ /etc/php/cgi-php5.4/ext-active/ /etc/php/cli-php5.3/ext-active/ /etc/php/cli-php5.4/ext-active/ /etc/rc.d /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -march=pentium4 -pipe -fomit-frame-pointer"
FCFLAGS="-march=i686 -O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles news parallel-fetch parse-eapi-ebuild-head protect-owned sandbox selinux sesandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS="-march=i686 -O2 -pipe"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTDIR_OVERLAY="/var/lib/layman/hardened-development /usr/local/portage"
USE="aac apache2 berkdb bzip2 caps cli cracklib crypt ctype cups curl cxx dlz dri enscript gd gdbm hardened iconv imagemagick jbig jpeg jpeg2k lame mailwrapper mime modules mp3 mpm-prefork mudflap mysql mysqli ncurses netboot nfsv3 nls nptl nptlonly ogg open_perms openmp pam pax_kernel pcre perl php pic png readline rle sasl selinux sendmail sensord server session ssl subversion svnserve tcpd threads tiff truetype twolame unicode unzip urandom usb vhosts vim-syntax vorbis webdav x86 xml xmlreader xpm zip zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" 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 auth_digest authn_anon authn_dbd authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi dav dav_fs dav_lock dbd deflate dir disk_cache env expires ext_filter file_cache filter headers ident imagemap include info log_config logio mem_cache mime mime_magic negotiation proxy proxy_ajp proxy_balancer proxy_connect proxy_http rewrite setenvif so speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump" 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" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" PHP_TARGETS="php5-3 php5-4" PYTHON_TARGETS="python3_2 python2_7" RUBY_TARGETS="ruby18 ruby19" USERLAND="GNU" VIDEO_CARDS="apm ark chips cirrus cyrix dummy fbdev glint i128 i740 intel mach64 mga neomagic nsc nv r128 radeon rendition s3 s3virge savage siliconmotion sis sisusb tdfx tga trident tseng v4l vesa via vmware nouveau" 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"
Comment 2 J.C. Wren 2012-07-03 17:05:10 UTC
Created attachment 317053 [details]
build.log from emerge -q setools
Comment 3 J.C. Wren 2012-07-03 17:05:40 UTC
# emerge -pqv '=app-admin/setools-3.3.7-r3'
[ebuild     U ] app-admin/setools-3.3.7-r3 [3.3.7-r1] USE="python -X -debug -java"
Comment 4 Sven Vermeulen (RETIRED) gentoo-dev 2012-07-03 19:31:03 UTC
Do you happen to have the configure.log file in /var/tmp/portage/app-admin/setools somewhere? As this is a configure check failure, this log file might give a clue why it is happening.

I don't have this on arch nor ~arch here for the moment.
Comment 5 J.C. Wren 2012-07-03 20:08:41 UTC
Created attachment 317061 [details]
config.log from emerge -q setools

There wasn't a configure.log, but config.log does exist (and this is it)
Comment 6 Jory A. Pratt gentoo-dev 2012-07-04 16:58:04 UTC
configure:17519: checking for python
configure:17537: found /usr/bin/python
configure:17549: result: /usr/bin/python

configure:17583: checking for Python include path
configure:17593: result: -I/usr/include/python2.7
configure:17600: checking for Python library path
configure:17620: result: ('-L/usr/lib/python2.7', '-lpython2.7')
configure:17627: checking for Python site-packages path
configure:17633: result: /usr/lib/python2.7/site-packages
configure:17640: checking python extra libraries
configure:17647: result: ('', '-lpthread -ldl  -lutil')

configure:17694: i686-pc-linux-gnu-gcc -std=gnu99 -o conftest -O2 -march=pentium4 -pipe -fomit-frame-pointer  -I/usr/include/python2.7 -Wl,-O1 -Wl,--as-needed conftest.c  ('-L/usr/lib/python2.7', '-lpython2.7') >&5
i686-pc-linux-gnu-gcc: error: ('-L/usr/lib/python2.7',: No such file or directory
i686-pc-linux-gnu-gcc: error: '-lpython2.7'): No such file or directory

This is rather odd, please re-emerge python:2.7 and retest, also verify that the path is actually valid i.e /usr/lib/python2.7.
Comment 7 J.C. Wren 2012-07-06 22:41:14 UTC
Re-emerge'd python, same thing. 

What's it trying to find, specifically? /usr/lib/python2.7 exists. There's a bunch of .so files in /usr/lib/python2.7/lib-dynload and /usr/lib/python2.7/site-packages.

I have two systems that this is occurring on. There's only one version of python installed.

# eselect python list
Available Python interpreters:
  [1]   python2.7 *

# locate libpython

# locate libdl  

# locate libpthread 
Comment 8 Sven Vermeulen (RETIRED) gentoo-dev 2012-07-11 17:02:35 UTC
locate doesn't show what you have on your system, only what was on your system the moment the database was created. What is the output of "ls -lZ /usr/lib*/libpython*" ?
Comment 9 J.C. Wren 2012-07-11 17:23:03 UTC
Actually, 'locate' *does* show you what you have on your system if you run 'updatedb' prior to using it. Which I did.

At any rate, the output for "ls -lZ /usr/lib*/libpython*" is

# ls -lZ /usr/lib*/libpython*
-rw-r--r-- 1 root root ? 2371710 Jul  1 22:28 /usr/lib/libpython2.7.a
lrwxrwxrwx 1 root root ?      19 Jul  1 22:28 /usr/lib/ ->
-r-xr-xr-x 1 root root ? 1592176 Jul  1 22:28 /usr/lib/
Comment 10 Sven Vermeulen (RETIRED) gentoo-dev 2012-07-12 18:45:17 UTC
Is SELinux already enabled on your system (sestatus)?

If so, then it might be a permission issue. In your output, the "?" means that there is no label assigned to the files (yet). If SELinux is enabled, then portage would not have access to read those files. In that case, relabel your file system and retry (rlpkg -a -r).
Comment 11 J.C. Wren 2012-07-16 14:13:43 UTC
# sestatus -v
SELinux status:                 disabled

Should I try relabeling anyway? I'm not sure what the implications of that might be.
Comment 12 Sven Vermeulen (RETIRED) gentoo-dev 2012-07-16 17:36:16 UTC
No, relabeling won't help if SELinux wasn't active yet... but it seems I was looking in the wrong direction.

configure:17694: i686-pc-linux-gnu-gcc -std=gnu99 -o conftest -O2 -march=pentium4 -pipe -fomit-frame-pointer  -I/usr/include/python2.7 -Wl,-O1 -Wl,--as-needed conftest.c  ('-L/usr/lib/python2.7', '-lpython2.7') >&5
i686-pc-linux-gnu-gcc: error: ('-L/usr/lib/python2.7',: No such file or directory
i686-pc-linux-gnu-gcc: error: '-lpython2.7'): No such file or directory
configure:17694: $? = 1

What happens here is that the configure script is adding ('-L/usr/lib/python2.7', '-lpython2.7') as an argument, which is incorrect.

Could you upload the configure script? We'll need to figure out why it is doing that. The configure script is probably at /var/tmp/portage/app-admin/setools/setools-3.3.7-r3/configure
Comment 13 J.C. Wren 2012-07-16 18:13:38 UTC
Created attachment 318354 [details]
configure script from /var/tmp/portage/app-admin/setools-3.3.7-r3/work/setools-3.3.7
Comment 14 Sven Vermeulen (RETIRED) gentoo-dev 2012-07-16 18:47:40 UTC
Ok so your build sais you don't have pkgconfig or doesn't detect it. Because of that, it tries to deduce the PYTHON_LDFLAGS itself using some python code (which isn't correct).

If you don't have pkgconfig installed, does the problem go away the moment it is installed? If so, i'll probably have it depend on pkgconfig for this, because the python code is auto-generated and probably made for Python 3.x.

If you don't see that as an option, does it help to  provide PYTHON_LDFLAGS yourself (export PYTHON_LDFLAGS="-L/usr/lib/python2.7 -lpython2.7")?
Comment 15 J.C. Wren 2012-07-16 19:10:07 UTC
pkgconfig-0.27 is installed.

Using the "export PYTHON_LDFLAGS="-L/usr/lib/python2.7 -lpython2.7", I get 

make[2]: Leaving directory `/var/tmp/portage/app-admin/setools-3.3.7-r3/work/setools-3.3.7'
make[1]: Leaving directory `/var/tmp/portage/app-admin/setools-3.3.7-r3/work/setools-3.3.7'
 * ERROR: app-admin/setools-3.3.7-r3 failed (compile phase):
 *   PYTHON_LDFLAGS should be indexed array
/usr/lib/portage/bin/ line 214: wait: `PYTHON_LDFLAGS should be indexed array': not a pid or valid job spec
 * The complete build log is located at '/var/tmp/portage/app-admin/setools-3.3.7-r3/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/app-admin/setools-3.3.7-r3/temp/environment'.
Comment 16 Sven Vermeulen (RETIRED) gentoo-dev 2012-07-17 08:51:55 UTC
Hm, I'll check the differences between your config.log and mine when I get back home. If pkg-config is installed, it should detect it (I can remember my config.log showing "has_pkg_config='yes'" whereas yours says "has_pkg_config=''"
Comment 17 Sven Vermeulen (RETIRED) gentoo-dev 2012-07-17 14:47:00 UTC
Do you have python 3.x on your system as well? If you have a python-3 as the default Python, does that work? It seems like python2.7 prints out the library information differently than 3.x.
Comment 18 J.C. Wren 2012-07-17 14:51:47 UTC
# eselect python list
Available Python interpreters:
  [1]   python2.7 *

2.7 only.
Comment 19 Sven Vermeulen (RETIRED) gentoo-dev 2012-07-17 17:14:02 UTC
Hmm, okay, seems like I'll need to patch m4/ac_python_devel.m4 to properly export the PYTHON_LIBS variable to make it an indexed array rather than a string that looks like an array.

Problem is that the syntax for python 2.x (I think 2.5 and earlier) supported that, and 2.7 doesn't anymore as it tries to be somewhat compatible with the print() function of Python 3.
Comment 20 Sven Vermeulen (RETIRED) gentoo-dev 2012-07-17 17:31:09 UTC
You can probably work around this for now using:

~# export PYTHON_LDFLAGS=("-L/usr/lib/python2.7",  "-lpython2.7")
~# emerge setools
Comment 21 Sven Vermeulen (RETIRED) gentoo-dev 2012-07-17 17:42:10 UTC
Created attachment 318476 [details]
Updated ebuild

This ebuild marks the PYTHON_LDFLAGS in the m4/ac_python_devel.m4 as an array. Not sure if that's a proper fix, but early tests here show that it doesn't hurt on systems with python 3 already available.

Can you test this ebuild out (without the workaround then)?
Comment 22 J.C. Wren 2012-07-17 18:40:09 UTC
OK, trying the revised ebuild gives me the original error.

checking consistency of all components of python development environment... no
configure: error: 
  Could not link test program to Python. Maybe the main Python library has been
  installed in some non-standard library path. If so, pass it to configure,
  via the LDFLAGS environment variable.
  Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib"

And trying the export of PYTHON_LDFLAGS as an array does the same thing :(
Comment 23 Sven Vermeulen (RETIRED) gentoo-dev 2012-07-17 19:24:34 UTC

Okay, is it an option to install python-3 on the system? Python 2.7 and 3.x can coexist next to each other. If that's okay for you (and it works) I'll probably depend on python 3 (for building).

Run-time, python-2 and python-3 should both be supported.
Comment 24 J.C. Wren 2012-07-18 16:28:41 UTC
I may be able to install Python-3. I had it installed at one point, but ended up masking it because other ebuilds were getting confused. This was a couple months ago, and that may have been resolved.
Comment 25 Sven Vermeulen (RETIRED) gentoo-dev 2012-07-25 17:58:27 UTC
Were you able to test it with python-3 installed?
Comment 26 J.C. Wren 2012-07-31 17:01:43 UTC
I did emerge python-3, but have not eselect'ed it to be active (should I? That seems like massive breakage for everything else. I do not have good luck where python is involved), and it still failed the compile.
Comment 27 Sven Vermeulen (RETIRED) gentoo-dev 2012-08-15 13:19:26 UTC
Created attachment 321396 [details]
Updated ebuild

This ebuild pulls in a new fix that resets the PYTHON_LDFLAGS variable if the used Python version is 2.7. Can you give this one a go?

I tried it on a stable system where python-3* was fully unmerged (so it wouldn't be used) and I could first reproduce your problem, and then with this ebuild the problem was gone. Also tried on a stable system with python-3* installed to make sure I'm not introducing other build problems, which wasn't the case.
Comment 28 Sven Vermeulen (RETIRED) gentoo-dev 2012-08-24 17:07:01 UTC
setools-3.3.7-r5 in hardened-dev overlay
Comment 29 Sven Vermeulen (RETIRED) gentoo-dev 2012-09-08 18:34:28 UTC
In main tree, ~arch
Comment 30 Sven Vermeulen (RETIRED) gentoo-dev 2012-12-30 15:29:21 UTC
3.3.7-r6 is stable