Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 232575 - Packages that use /usr/lib/python instead of /usr/$(get_libdir)/python
Summary: Packages that use /usr/lib/python instead of /usr/$(get_libdir)/python
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High major (vote)
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords: Tracker
Depends on: 232594 232596 232602 233646 233649
Blocks:
  Show dependency tree
 
Reported: 2008-07-21 15:27 UTC by Ali Polatel (RETIRED)
Modified: 2010-11-07 14:51 UTC (History)
2 users (show)

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


Attachments
python.eclass (python.eclass.diff,435 bytes, patch)
2008-07-22 17:50 UTC, Rob Cakebread (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ali Polatel (RETIRED) gentoo-dev 2008-07-21 15:27:34 UTC
Tracker bug for packages that don't use $(get_libdir) where they should.
Comment 1 Carsten Lohrke (RETIRED) gentoo-dev 2008-07-21 19:12:58 UTC
Isn't it about time to provide $PYTHON_LIBDIR and maybe for convenience $PYTHON_SITE globally via python.eclass, instead reiterating /usr/$(get_libdir)/python${PYVER} in all and every ebuild using Python, again and again!?
Comment 2 Rob Cakebread (RETIRED) gentoo-dev 2008-07-22 17:50:41 UTC
Created attachment 161110 [details, diff]
python.eclass

(In reply to comment #1)
> Isn't it about time to provide $PYTHON_LIBDIR and maybe for convenience
> $PYTHON_SITE globally via python.eclass, instead reiterating
> /usr/$(get_libdir)/python${PYVER} in all and every ebuild using Python, again
> and again!?

We agreed to do this a few years ago at a Python project meeting but never took action. We'll do it today unless someone speaks up with. I'd suggest PYTHON_LIBDIR and PYTHON_SITEDIR as names (see patch).

Note the variables are exported in python_version() because we need $PYVER, so you'd use it like:

python_version
doins ${PYTHON_SITEDIR}/foo
Comment 3 Rob Cakebread (RETIRED) gentoo-dev 2008-07-22 20:24:43 UTC
After talk in #gentoo-python the latest suggestion is to use functions instead of variables:


# @FUNCTION: get_python_libdir
# @RETURN: Returns the python library dir
get_python_libdir() {
	python_version
	echo "/usr/$(get_libdir)/python${PYVER}"
}

# @FUNCTION: get_python_sitedir
# @RETURN: Returns the python site-packages dir
get_python_sitedir() {
	echo "$(get_python_libdir)/site-packages"
}
Comment 4 Israel G. Lugo 2008-07-22 23:20:42 UTC
Should all packages always use $(get_libdir), or only in specific cases?

I have a multilib amd64 system and have come across the lib/lib64 question before. Notably, in dev-python/astng, where a fix to prevent a file collision with another ebuild assumes the duplicate file is being installed to /usr/$(get_libdir), when in fact it's being installed to /usr/lib. This causes the fix to fail on systems where get_libdir returns something other than lib, which is true of amd64. Therefore, the file collision still exists on those systems (bug 233025).

I was under the (possibly mistaken) impression that /usr/$(get_libdir) (e.g. /usr/lib64) should be used for platform-specific Python modules (e.g. non-pure-Python modules, .so and so on) while /usr/lib should be used as the directory for platform-shared modules (e.g. pure Python stuff).

I based this on the Python distutils documentation, for example from distutils.sysconfig.get_python_lib:
def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
    """Return the directory containing the Python library (standard or
    site additions).

    If 'plat_specific' is true, return the directory containing
    platform-specific modules, i.e. any module from a non-pure-Python
    module distribution; otherwise, return the platform-shared library
    directory.  If 'standard_lib' is true, return the directory
    containing standard Python library modules; otherwise, return the
    directory for site-specific modules.

This function, at least in dev-lang/python-2.4.4-r13, contains the following:

    if os.name == "posix":
        if plat_specific:
            lib = "lib64"
        else:
            lib = "lib"

The whole Python distutils process seems geared towards splitting between "platform-specific" and "platform-shared" packages. The distutils install_lib command, for example, gets the destination of the library files from the install command (in distutils.command.install_lib.finalize_options()) which, for packages which don't contain any non-pure-Python modules, returns the standard /usr/lib directory as the target.

If I run the following on my amd64 system:
$ python -c 'from distutils.sysconfig import get_python_lib; print get_python_lib()'

I get /usr/lib/python2.4/site-packages, which to me would seem to make sense.

Likewise, if I run:
$ python -c 'from distutils.command.install import install; \
from distutils.dist import Distribution; x = install(Distribution()); \
x.finalize_options(); print "purelib:", x.install_purelib; \
print "platlib:", x.install_platlib; print "install_lib:", \
x.install_lib'

On my system, this would print:
purelib: /usr/lib/python2.4/site-packages
platlib: /usr/lib64/python2.4/site-packages
install_lib: /usr/lib/python2.4/site-packages/

where purelib is the install.install_purelib variable ("for pure module distributions", say the comments), platlib is install.install_platlib ("non-pure, dists w/extensions") and install_lib is install.install_lib ("the actual directory to install modules to").

I have posted all of this with greater detail on bug 223025, comment 10.

Is Gentoo just following a different logic from the Python distutils, or have I misunderstood something?

If someone from Gentoo Python could shed some light here for me, I would appreciate it. Also, if you could please make an informed comment on bug 233025, where me and another user where having precisely the same question (whether the ebuild is wrong for not installing to $(get_libdir) or it's actually right and the collision fix is broken).

Thank you kindly.
Comment 5 Israel G. Lugo 2008-07-22 23:23:35 UTC
Forgot to mention, if I'm wrong and all Python modules should indeed be installed to /usr/$(get_libdir) then the aforementioned bug 233025 is also blocking this one. We were uncertain as to whether it should block this or not due to the whole doubt I mentioned above.
Comment 6 Israel G. Lugo 2008-07-22 23:25:49 UTC
Sorry for the triple comment... just wanted to note I said bug 233025 several times above when I really should have said bug 223025. Apologies for the typo.
Comment 7 Rob Cakebread (RETIRED) gentoo-dev 2008-07-31 02:07:03 UTC
I've added get_python_sitedir() and get_python_libdir() functions to the python.eclass.

Isreal, I'm trying to get access to a lib64 system so I can give you an answer and document this in our project guide[1]. I can't remember where this was discussed when we first started using get_libdir. 

[1] http://www.gentoo.org/proj/en/Python/developersguide.xml
Comment 8 Rob Cakebread (RETIRED) gentoo-dev 2008-08-01 22:28:59 UTC
NOTE:

The functions have been named python_get_sitedir and python_get_libdir to follow existing function names. Thanks for pointing that out, Necoro.
Comment 9 René 'Necoro' Neumann 2008-08-01 22:29:46 UTC
Just to list other packages, which need to be addressed and are not already filed:

- numeric-23.7 (perhaps this version can be dropped)
- pmw-1.2 (filed an ebuild bump under bug#233638)
- psycopg-1.1.21
- pychecker-0.8.17
- pyclimate-1.2.1-r1
- pydispatcher (also could need a bump :))
- pygtkglext-1.0.1* (perhaps can be dropped?)
- pythong
- python-irclib
- sancho-0.11-r1 (also: strange slotting: 0.0 and 0)
- visual-3.2.9
- wxpython/files/wxpy-config.py
- xsv-2.7
Comment 10 Dirkjan Ochtman (RETIRED) gentoo-dev 2010-10-27 15:44:36 UTC
Updated:

- numeric is gone from the tree
- pmw-1.3.2 is in the tree and has been fixed
- psycopg-1.1.21 was fixed up
- pychecker-0.8.18 doesn't seem to have this problem
- >=pyclimate-1.2.2 doesn't seem to have this problem
- pydispatcher got bumped and doesn't have the problem anymore
- pygtkglext-1.0.1* doesn't seem to have this problem
- pythong doesn't seem to have this problem
- python-irclib has been fixed
- sancho-2.4 doesn't seem to have this problem
- visual-3.2.9 has been fixed
- xsv-2.7 has been fixed
- wxpython/files/wxpy-config.py script doesn't exist anymore

So I think we're done here. Just to check: checking if it still has this problem can basically be done by seeing if /usr/lib is in the ebuild, right?
Comment 11 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2010-10-29 22:59:50 UTC
(In reply to comment #10)

`grep usr/lib/python ${ebuilds}` reports e.g. mail-filter/tmda.
Comment 12 Dirkjan Ochtman (RETIRED) gentoo-dev 2010-11-04 15:20:59 UTC
These seem to be all that's left...

dev-lang/python/python-2.4.6.ebuild:    python_mod_optimize -f -x "/(site-packages|test|tests)/" /usr/lib/python${SLOT}
dev-lang/python/python-2.4.6.ebuild:    python_mod_cleanup /usr/lib/python${SLOT}
dev-python/numpy/numpy-1.3.0-r1.ebuild: rm -f "${ED}"/usr/lib/python*/site-packages/numpy/*.txt || die
dev-python/numpy/numpy-1.3.0-r2.ebuild: rm -f "${ED}"/usr/lib/python*/site-packages/numpy/*.txt || die
dev-python/numpy/numpy-1.4.1.ebuild:    rm -f "${ED}"/usr/lib/python*/site-packages/numpy/*.txt || die
mail-filter/tmda/tmda-1.0.3-r3.ebuild:  insinto "/usr/lib/python${pv}/site-packages/TMDA"
mail-filter/tmda/tmda-1.0.3-r3.ebuild:  insinto "/usr/lib/python${pv}/site-packages/TMDA/pythonlib/email"
mail-filter/tmda/tmda-1.1.12.ebuild:    insinto "/usr/lib/python${pv}/site-packages/TMDA"
mail-filter/tmda/tmda-1.1.12.ebuild:    insinto "/usr/lib/python${pv}/site-packages/TMDA/Queue"
mail-filter/tmda/tmda-1.1.12.ebuild:    insinto "/usr/lib/python${pv}/site-packages/TMDA/pythonlib/email"
mail-filter/tmda/tmda-1.1.12.ebuild:    insinto "/usr/lib/python${pv}/site-packages/TMDA/pythonlib/email/mime"
mail-filter/tmda/tmda-1.1.4.ebuild:     insinto "/usr/lib/python${pv}/site-packages/TMDA"
mail-filter/tmda/tmda-1.1.4.ebuild:     insinto "/usr/lib/python${pv}/site-packages/TMDA/pythonlib/email"

Whatever TMDA is doing seems deeply wrong in more than one ways.
Comment 13 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2010-11-07 14:51:56 UTC
(In reply to comment #12)

The newer versions are fixed:
>=dev-lang/python-2.5
>=dev-python/numpy-1.5.0-r2
>=mail-filter/tmda-1.1.12

This bug can be closed now.