[libvirt] Python script and extension module directory handling

Commit 66137344feb488ea87b0d92f3c03844d9a7a7786 changed the Python detection mechanism in configure. This results in a changed install location for the Python bindings at least on Fedora 12 64bit systems. For the explanation below I assume a Fedora 12 64bit systems, libvirt is configured with prefix /usr and Python 2.6 is installed. Before this commit libvirt.py and libvirtmod.so were installed to /usr/lib64/python2.6/site-packages. After this commit both are installed to /usr/lib/python2.6/site-packages. This is at least wrong for libvirtmod.so, as it should be installed to /usr/lib64/python2.6/site-packages on a 64bit system. Before this commit pythondir was set manually to /usr/lib64/python2.6/site-packages and python/Makefile.am contains 'python_LTLIBRARIES = libvirtmod.la' that results in installing libvirtmod.so to pythondir. AM_PATH_PYTHON defines two variables: pythondir and pyexecdir. But according to the AM_PATH_PYTHON documentation [1] pythondir is the directory where Python scripts should be installed. /usr/lib/python2.6/site-packages in this case, because Python scripts are not architecture dependent in general. pyexecdir is the directory where Python extension modules (shared libraries) should be installed. AM_PATH_PYTHON detects pyexecdir correctly as /usr/lib64/python2.6/site-packages, but python/Makefile.am contains 'python_LTLIBRARIES = libvirtmod.la' that results in installing libvirtmod.so to pythondir. So python/Makefile.am must be changed: diff --git a/python/Makefile.am b/python/Makefile.am index 736631e..04342b7 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -32,7 +32,7 @@ mylibs = $(top_builddir)/src/libvirt.la all-local: libvirt.py -python_LTLIBRARIES = libvirtmod.la +pyexec_LTLIBRARIES = libvirtmod.la libvirtmod_la_SOURCES = libvirt-override.c typewrappers.c libvirt.c libvirt.h # Python <= 2.4 header files contain a redundant decl, hence we Now libvirtmod.so is installed to the correct directory: /usr/lib64/python2.6/site-packages But libvirt.py gets installed to /usr/lib/python2.6/site-packages, this is different from the installation directory before the commit. A default Fedora 12 64bit installation has *.py files installed to /usr/lib/python2.6/site-packages and /usr/lib64/python2.6/site-packages. By looking at both directories the policy it pretty obvious: Packages that are pure Python go to /usr/lib/python2.6/site-packages and packages that are mixed (Python and shared libraries) go completely to /usr/lib64/python2.6/site-packages. So we restore the behavior from before the commit completely by applying this additional patch: diff --git a/python/Makefile.am b/python/Makefile.am index 736631e..04342b7 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -60,14 +60,14 @@ $(GENERATED): generated.stamp $(libvirtmod_la_OBJECTS): $(GENERATED) install-data-local: - $(mkinstalldirs) $(DESTDIR)$(pythondir) - @INSTALL@ -m 0644 libvirt.py $(DESTDIR)$(pythondir) + $(mkinstalldirs) $(DESTDIR)$(pyexecdir) + @INSTALL@ -m 0644 libvirt.py $(DESTDIR)$(pyexecdir) $(mkinstalldirs) $(DESTDIR)$(DOCS_DIR) @(for doc in $(DOCS) ; \ do @INSTALL@ -m 0644 $$doc $(DESTDIR)$(DOCS_DIR) ; done) uninstall-local: - rm -f $(DESTDIR)$(pythondir)/libvirt.py + rm -f $(DESTDIR)$(pyexecdir)/libvirt.py CLEANFILES= $(GENERATED) generated.stamp I discussed this with Daniel Veillard on IRC and there was some confusion what the actual problem was and how to solve it, so I wanted to recap it here. Also thanks to Daniel Hokka Zakrisson, who gave the important hint about pythondir vs pyexecdir on IRC. [1] http://www.gnu.org/software/hello/manual/automake/Python.html Matthias

On Sat, Dec 12, 2009 at 12:47:46AM +0100, Matthias Bolte wrote:
From 1f5083be1dcbf6877dfbae44e9ea4e50ebaec708 Mon Sep 17 00:00:00 2001 From: Matthias Bolte <matthias.bolte@googlemail.com> Date: Sat, 12 Dec 2009 00:11:31 +0100 Subject: [PATCH] Fix install location for Python bindings
Commit 66137344feb488ea87b0d92f3c03844d9a7a7786 changed the Python detection mechanism in configure to use AM_PATH_PYTHON. This results in a changed install location for the Python bindings, at least on Fedora 12 64bit systems.
Before this commit libvirt.py and libvirtmod.so were installed to
/usr/lib64/python2.6/site-packages
After this commit they are installed to
/usr/lib/python2.6/site-packages
Mixed Python packages (containing *.py and *.so files) should be installed to the pyexecdir directory detected by AM_PATH_PYTHON.
This restores the install location from before the AM_PATH_PYTHON commit.
* configure.in: remove unnecessary pythondir export * python/Makefile.am: switch from pythondir to pyexecdir
ACK this looks correct to me. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Sat, Dec 12, 2009 at 11:12:31AM +0000, Daniel P. Berrange wrote:
On Sat, Dec 12, 2009 at 12:47:46AM +0100, Matthias Bolte wrote:
From 1f5083be1dcbf6877dfbae44e9ea4e50ebaec708 Mon Sep 17 00:00:00 2001 From: Matthias Bolte <matthias.bolte@googlemail.com> Date: Sat, 12 Dec 2009 00:11:31 +0100 Subject: [PATCH] Fix install location for Python bindings
Commit 66137344feb488ea87b0d92f3c03844d9a7a7786 changed the Python detection mechanism in configure to use AM_PATH_PYTHON. This results in a changed install location for the Python bindings, at least on Fedora 12 64bit systems.
Before this commit libvirt.py and libvirtmod.so were installed to
/usr/lib64/python2.6/site-packages
After this commit they are installed to
/usr/lib/python2.6/site-packages
Mixed Python packages (containing *.py and *.so files) should be installed to the pyexecdir directory detected by AM_PATH_PYTHON.
This restores the install location from before the AM_PATH_PYTHON commit.
* configure.in: remove unnecessary pythondir export * python/Makefile.am: switch from pythondir to pyexecdir
ACK this looks correct to me.
ACK I was wondering a bit about the location for the .py, but I prefer this approach, thanks ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

2009/12/14 Daniel Veillard <veillard@redhat.com>:
On Sat, Dec 12, 2009 at 11:12:31AM +0000, Daniel P. Berrange wrote:
On Sat, Dec 12, 2009 at 12:47:46AM +0100, Matthias Bolte wrote:
From 1f5083be1dcbf6877dfbae44e9ea4e50ebaec708 Mon Sep 17 00:00:00 2001 From: Matthias Bolte <matthias.bolte@googlemail.com> Date: Sat, 12 Dec 2009 00:11:31 +0100 Subject: [PATCH] Fix install location for Python bindings
Commit 66137344feb488ea87b0d92f3c03844d9a7a7786 changed the Python detection mechanism in configure to use AM_PATH_PYTHON. This results in a changed install location for the Python bindings, at least on Fedora 12 64bit systems.
Before this commit libvirt.py and libvirtmod.so were installed to
/usr/lib64/python2.6/site-packages
After this commit they are installed to
/usr/lib/python2.6/site-packages
Mixed Python packages (containing *.py and *.so files) should be installed to the pyexecdir directory detected by AM_PATH_PYTHON.
This restores the install location from before the AM_PATH_PYTHON commit.
* configure.in: remove unnecessary pythondir export * python/Makefile.am: switch from pythondir to pyexecdir
ACK this looks correct to me.
ACK I was wondering a bit about the location for the .py, but I prefer this approach,
thanks !
Daniel
Okay, pushed. Matthias
participants (3)
-
Daniel P. Berrange
-
Daniel Veillard
-
Matthias Bolte