Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 344231 - dev-python/gnome-python-extras-base: Checking for Python Library Path is horribly inefficient. (uses find /usr/ name libpython)
Summary: dev-python/gnome-python-extras-base: Checking for Python Library Path is horr...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Gentoo Linux Gnome Desktop Team
URL:
Whiteboard:
Keywords: NeedPatch
: 431176 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-11-05 04:47 UTC by Gary HUnt
Modified: 2012-08-13 09:34 UTC (History)
8 users (show)

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


Attachments
pkg-config wrapper (pkg-config,1008 bytes, text/plain)
2011-06-17 21:53 UTC, Alexandre Rostovtsev (RETIRED)
Details
improved pkg-config wrapper (pkg-config,1.26 KB, text/plain)
2011-06-17 23:45 UTC, Alexandre Rostovtsev (RETIRED)
Details
gnucash-python-path.patch (python-path.patch,2.53 KB, patch)
2011-06-20 22:14 UTC, Ed Catmur
Details | Diff
gnucash-python-path.patch (python-path.patch,2.01 KB, patch)
2011-06-21 22:26 UTC, Ed Catmur
Details | Diff
planner-python-patch.patch (planner-0.14.6-find-python.patch,1.03 KB, patch)
2011-07-05 12:42 UTC, Pacho Ramos
Details | Diff
planner config.log (config.log,42.42 KB, text/plain)
2011-07-05 12:43 UTC, Pacho Ramos
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gary HUnt 2010-11-05 04:47:09 UTC
During configure, checking for Python Library Path takes forever as the configure script uses find on multiple directories including I believe /usr to search for present python libraries.

        for i in "$python_path/lib/python$PYTHON_VERSION/config/" "$python_path/lib/python$PYTHON_VERSION/" "$python_path/lib/python/config/" "$python_path/lib/python/" "$python_path/" ; do
		if test -e "$i"; then
	                python_path=`find $i -type f -name libpython$PYTHON_VERSION.* -print | sed "1q"`
        	        if test -n "$python_path" ; then
				python_lib="python$PYTHON_VERSION"
                	        break
	                fi



Reproducible: Always

Steps to Reproduce:
1. Emerge package gnome-python-extras-2.25.3 as usual method
2.
3.

Actual Results:  
checking for python extension module directory... ${exec_prefix}/lib64/python2.6/site-packages
checking for headers required to compile python extensions... found
checking for Python library path... *GAVE UP waiting after a few minutes*

Expected Results:  
checking for python extension module directory... ${exec_prefix}/lib64/python2.6/site-packages
checking for headers required to compile python extensions... found
checking for Python library path... found

The configure script in this ebuild app-office/planner also showing the same problems as part of the code was copied from here.
Comment 1 Pacho Ramos gentoo-dev 2010-11-06 10:37:27 UTC
And what alternative should be used instead for locating proper path? (this is anyway an upstream issue). Thanks
Comment 2 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2010-11-06 19:56:00 UTC
I suggest using distutils.sysconfig.get_config_var(...).
Comment 3 Pacho Ramos gentoo-dev 2011-03-12 11:21:08 UTC
I have seen this affects to more packages in the tree (like gnucash and others), wouldn't be possible to find a more general solution to, for example, drop that checking in favor of a better one when unpacking sources? I am referring to some fix on a eclass for not needing to fix every package showing this bug
Comment 4 Pacho Ramos gentoo-dev 2011-03-15 09:14:42 UTC
Arfrever, if you have time, could you please try to provide a patch for explaining upstreams how to properly check for python paths? Thanks a lot
Comment 5 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2011-04-18 17:05:06 UTC
(In reply to comment #4)
> Arfrever, if you have time, could you please try to provide a patch for
> explaining upstreams how to properly check for python paths?

The following commands should help you:

$ python2.6 -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_inc())'
/usr/include/python2.6
$ python2.6 -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(standard_lib=True))'
/usr/lib64/python2.6
$ python2.6 -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(standard_lib=False))'
/usr/lib64/python2.6/site-packages
$ python2.6 -c 'import distutils.sysconfig; print(distutils.sysconfig.get_config_var("LDLIBRARY"))'
libpython2.6.so
$ python2.6 -c 'import distutils.sysconfig; print(distutils.sysconfig.get_config_var("INSTSONAME"))'
libpython2.6.so.1.0
$ python2.6 -c 'import distutils.sysconfig; print(distutils.sysconfig.get_config_var("LIBRARY"))'
libpython2.6.a
Comment 6 Thomas R. (TRauMa) 2011-05-08 11:51:36 UTC
It's not only slow, but also apparently breaks with splitdebug:

checking for Python include path... /usr/include/python2.6
checking for Python library path... find: `/usr/lib/python/config/': No such file or directory
find: `/usr/lib/python/': No such file or directory
/usr/lib64/debug/usr/lib64
checking python extra libraries...
Comment 7 Gilles Dartiguelongue (RETIRED) gentoo-dev 2011-05-08 12:25:08 UTC
It's just slow here with splitdebug and 3 python slots installed.
Comment 8 Thomas Kahle (RETIRED) gentoo-dev 2011-05-08 12:33:58 UTC
(In reply to comment #6)
> It's not only slow, but also apparently breaks with splitdebug:
> 
> checking for Python include path... /usr/include/python2.6
> checking for Python library path... find: `/usr/lib/python/config/': No such
> file or directory
> find: `/usr/lib/python/': No such file or directory
> /usr/lib64/debug/usr/lib64
> checking python extra libraries...

It does not really 'fail', or does it?  Does the emerge fail ? 
It looks to me like it just tries to run find on a non-existent directory, but it finds what it searches for somewhere else.
Comment 9 quanta 2011-06-08 09:43:00 UTC
Is there any workaround for this? I got the same problem when emerging scribes editor: each package egg-python, gtkspell-python, ... hangs at "Checking for Python Library Path..." for 5 minutes around.
Comment 10 Pacho Ramos gentoo-dev 2011-06-16 10:15:33 UTC
Looks like changes would be like the following:
http://git.gnome.org/browse/gnome-python-extras/commit/?id=77cca7ce35bfb4f6bc283672dc295c2bb82a3b58
Comment 11 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2011-06-17 16:07:21 UTC
(In reply to comment #10)

It will cause new problems:
- Python doesn't install python.pc, so AC_MSG_ERROR([Can't find python.pc]) will
  be run.
- Only Python 2.7 and >=3.1 install python-${Python_version}.pc
  (e.g. python-2.7.pc, python-3.1.pc, python-3.2.pc), so using of
  python-$PYTHON_VERSION in pkg-config calls in acinclude.m4 would still break
  support for Python <=2.6.
Comment 12 Alexandre Rostovtsev (RETIRED) gentoo-dev 2011-06-17 16:51:00 UTC
(In reply to comment #11)
> It will cause new problems:
> - Python doesn't install python.pc

Obvious solution: have eselect-python install python.pc.
Comment 13 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2011-06-17 17:03:13 UTC
(In reply to comment #12)

It wouldn't work with functionality of setting of locally active version of Python (via EPYTHON environmental variable), so it cannot be implemented.
Comment 14 Alexandre Rostovtsev (RETIRED) gentoo-dev 2011-06-17 17:29:18 UTC
(In reply to comment #13)
> It wouldn't work with functionality of setting of locally active version of
> Python (via EPYTHON environmental variable), so it cannot be implemented.

You are right. So we need to somehow make pkg-config EPYTHON-aware...

Perhaps the eclass could generate a pkg-config wrapper script in a temporary directory under WORKDIR that does argument munging, transforming "python" into whatever is appropriate given the value of EPYTHON?
Comment 15 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2011-06-17 18:31:23 UTC
(In reply to comment #14)

A pkg-config wrapper might be useful for other reasons, but it won't help for support for Python <=2.6.
Comment 16 Alexandre Rostovtsev (RETIRED) gentoo-dev 2011-06-17 18:42:57 UTC
(In reply to comment #15)
> A pkg-config wrapper might be useful for other reasons, but it won't help for
> support for Python <=2.6.

python-2.6.pc can be easily generated using python2.6's distutils in a temporary directory that's added to PKG_CONFIG_PATH by the wrapper.

Is there a good way to check for paths for python2.5 and python2.4? AFAICT, they don't have a distutils module.
Comment 17 Alexandre Rostovtsev (RETIRED) gentoo-dev 2011-06-17 18:46:38 UTC
(In reply to comment #16)
> Is there a good way to check for paths for python2.5 and python2.4? AFAICT,
> they don't have a distutils module.

Never mind, they do have it.
Comment 18 Pacho Ramos gentoo-dev 2011-06-17 19:14:33 UTC
(In reply to comment #11)
> (In reply to comment #10)
> 
> It will cause new problems:
> - Python doesn't install python.pc, so AC_MSG_ERROR([Can't find python.pc])
> will
>   be run.

Is this situation "normal"? I mean, looks like we are the only distribution having this problem... or upstream looks to think python.pc should be present on most of systems.


> - Only Python 2.7 and >=3.1 install python-${Python_version}.pc
>   (e.g. python-2.7.pc, python-3.1.pc, python-3.2.pc), so using of
>   python-$PYTHON_VERSION in pkg-config calls in acinclude.m4 would still break
>   support for Python <=2.6.

In the worst case we could still make them require python2.7 anyway :-/, not perfect... but I am still unsure about supporting all python2 versions in the tree
Comment 19 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2011-06-17 19:36:16 UTC
(In reply to comment #18)
> Is this situation "normal"?

Yes.

> I mean, looks like we are the only distribution having this problem...
> or upstream looks to think python.pc should be present on most of systems.

python-$(VERSION).pc is always installed by Makefile of Python 2.7 and >=3.1, while an additional symlink might be created only when "bininstall" or "install" target is used. Ebuilds use "altinstall" target to decrease chance of collisions between slots. Other distributions might not support having multiple Python versions installed parallelly.

Please convince upstream to use the following code in acinclude.m4:

if pkg-config --exists python-$PYTHON_VERSION; then
  python_ldflags=`pkg-config --libs python-$PYTHON_VERSION`
else
  python_ldflags="-lpython$PYTHON_VERSION"
fi
Comment 20 Alexandre Rostovtsev (RETIRED) gentoo-dev 2011-06-17 21:53:27 UTC
Created attachment 277417 [details]
pkg-config wrapper

Well, until the upstream has been convinced, here is a pkg-config wrapper that uses the EPYTHON environmental variable to munge "python" arguments to "python-X.Y", and if EPYTHON doesn't have a pkg-config file, the wrapper generates one using distutils.

To use it, stick it into ${WORKDIR}/tmp, and add ${WORKDIR}/tmp to the beginning of PATH.
Comment 21 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2011-06-17 22:07:15 UTC
(In reply to comment #20)

Some options of pkg-config require an argument. (E.g. if test.pc defines "python" variable, then `pkg-config test --variable python` prints value of this variable.)
Comment 22 Alexandre Rostovtsev (RETIRED) gentoo-dev 2011-06-17 23:45:52 UTC
Created attachment 277419 [details]
improved pkg-config wrapper

(In reply to comment #21)
> Some options of pkg-config require an argument. (E.g. if test.pc defines
> "python" variable, then `pkg-config test --variable python` prints value of
> this variable.)

Good point. Here's an improved wrapper that replaces "python" only if "python" is not an argument to an option or a version specifier.
Comment 23 Pacho Ramos gentoo-dev 2011-06-18 11:39:49 UTC
(In reply to comment #19)
> (In reply to comment #18)
> > Is this situation "normal"?
> 
> Yes.
> 
> > I mean, looks like we are the only distribution having this problem...
> > or upstream looks to think python.pc should be present on most of systems.
> 
> python-$(VERSION).pc is always installed by Makefile of Python 2.7 and >=3.1,
> while an additional symlink might be created only when "bininstall" or
> "install" target is used. Ebuilds use "altinstall" target to decrease chance of
> collisions between slots. Other distributions might not support having multiple
> Python versions installed parallelly.
> 
> Please convince upstream to use the following code in acinclude.m4:
> 
> if pkg-config --exists python-$PYTHON_VERSION; then
>   python_ldflags=`pkg-config --libs python-$PYTHON_VERSION`
> else
>   python_ldflags="-lpython$PYTHON_VERSION"
> fi

Reported then:
https://bugzilla.gnome.org/show_bug.cgi?id=652893
Comment 24 Ed Catmur 2011-06-20 22:14:52 UTC
Created attachment 277639 [details, diff]
gnucash-python-path.patch

Are we going to fix stuff in the tree while we wait for the various upstreams? Here's a patch for gnucash to start with.
Comment 25 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2011-06-21 17:21:39 UTC
(In reply to comment #24)

Please use distutils.sysconfig instead of pkg-config.
Comment 26 Ed Catmur 2011-06-21 22:26:31 UTC
Created attachment 277725 [details, diff]
gnucash-python-path.patch

Hope this is better.  Uses distutils.sysconfig instead of pkgconfig.
Comment 27 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2011-06-21 22:47:55 UTC
(In reply to comment #26)

It looks better.
Comment 28 Pacho Ramos gentoo-dev 2011-07-05 12:42:28 UTC
Created attachment 279157 [details, diff]
planner-python-patch.patch

After trying to pull similar changes to planner, configure failed with:

checking if msgfmt accepts -c... yes
checking for gmsgfmt... (cached) /usr/bin/gmsgfmt
checking for xgettext... (cached) /usr/bin/xgettext
./configure: line 17669: syntax error: unexpected end of file

Do you know what I am doing wrong? Thanks
Comment 29 Pacho Ramos gentoo-dev 2011-07-05 12:43:24 UTC
Created attachment 279159 [details]
planner config.log
Comment 30 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2011-07-05 15:23:49 UTC
(In reply to comment #28)

Delete one 'python_path=`$PYTHON -c 'import distutils.sysconfig; \' from your patch.
Comment 31 Pacho Ramos gentoo-dev 2011-07-05 19:36:33 UTC
+  05 Jul 2011; Pacho Ramos <pacho@gentoo.org> planner-0.14.5.ebuild,
+  +files/planner-0.14.5-find-python.patch:
+  Find python in a faster way, bug #344231, upstream bug #654044. Thanks a lot
+  to Arfrever Frehtes Taifersar Arahesis and Ed Catmur for their help.
+
Comment 32 Pacho Ramos gentoo-dev 2011-08-29 15:59:45 UTC
+*gnucash-2.4.7 (29 Aug 2011)
+
+  29 Aug 2011; Pacho Ramos <pacho@gentoo.org> +gnucash-2.4.7.ebuild,
+  +files/gnucash-2.4.7-python-detection.patch:
+  Version bump, find python in a faster way, bug #344231, thanks a lot to
+  Arfrever Frehtes Taifersar Arahesis and Ed Catmur for their help.
+
Comment 33 Alexandre Rostovtsev (RETIRED) gentoo-dev 2012-08-13 07:12:09 UTC
*** Bug 431176 has been marked as a duplicate of this bug. ***
Comment 34 Alexandre Rostovtsev (RETIRED) gentoo-dev 2012-08-13 09:34:56 UTC
Finally fixed this for gnome-python-extras-base and friends. Note that upstream had patched this issue in a different way which assumes python.pc exists and therefore is rather inconvenient for us to use in an ebuild (http://git.gnome.org/browse/gnome-python-extras/commit/?id=77cca7ce35bfb4f6bc283672dc295c2bb82a3b58). But gnome-python-extras development stopped years ago, so 2.25.3 is almost certainly the last release.

>  13 Aug 2012; Alexandre Rostovtsev <tetromino@gentoo.org>
>  gnome-python-extras-base-2.25.3.ebuild,
>  +files/gnome-python-extras-base-2.25.3-python-libs.patch:
>  Finally fix horribly slow python libs detection (bug #344231).

>  13 Aug 2012; Alexandre Rostovtsev <tetromino@gentoo.org>
>  egg-python-2.25.3.ebuild, +files/egg-python-2.25.3-python-libs.patch:
>  Finally fix horribly slow python libs detection (bug #344231).

>  13 Aug 2012; Alexandre Rostovtsev <tetromino@gentoo.org>
>  gdl-python-2.25.3.ebuild, +files/gdl-python-2.25.3-python-libs.patch:
>  Finally fix horribly slow python libs detection (bug #344231).

>  13 Aug 2012; Alexandre Rostovtsev <tetromino@gentoo.org>
>  gtkhtml-python-2.25.3.ebuild, +files/gtkhtml-python-2.25.3-python-libs.patch:
>  Finally fix horribly slow python libs detection (bug #344231).

>  13 Aug 2012; Alexandre Rostovtsev <tetromino@gentoo.org>
>  gtkspell-python-2.25.3.ebuild,
>  +files/gtkspell-python-2.25.3-python-libs.patch:
>  Finally fix horribly slow python libs detection (bug #344231).

>  13 Aug 2012; Alexandre Rostovtsev <tetromino@gentoo.org>
>  libgda-python-2.25.3.ebuild, +files/libgda-python-2.25.3-python-libs.patch:
>  Finally fix horribly slow python libs detection (bug #344231).

>  13 Aug 2012; Alexandre Rostovtsev <tetromino@gentoo.org>
>  libgksu-python-2.25.3.ebuild, +files/libgksu-python-2.25.3-python-libs.patch:
>  Finally fix horribly slow python libs detection (bug #344231).