Permalink
Browse files

Dynamically compute python site-packages directory

This allow to compile and use even if you have newer version of python

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
  • Loading branch information...
1 parent 4046907 commit a1d88e24fb3400ea25b94a56afa818d9bcb01582 @freddy77 freddy77 committed Oct 4, 2012
Showing with 24 additions and 25 deletions.
  1. +5 −5 scripts/OMakefile
  2. +4 −4 scripts/examples/python/OMakefile
  3. +2 −2 scripts/rrdd/OMakefile
  4. +13 −14 xapi.spec.in
View
@@ -1,4 +1,4 @@
-PYTHON_DIR=python2.4
+SITE_DIR=$(shell python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
.PHONY: noarch-install install sdk-install
@@ -131,8 +131,8 @@ sdk-install: install
mkdir -p $(SDK)
cp motd $(SDK)/motd
$(IPROG) init.d-sdkinit $(DESTDIR)/etc/rc.d/init.d/sdkinit
- mkdir -p $(DESTDIR)/usr/lib/python2.4/site-packages/xen/lowlevel
- touch $(DESTDIR)/usr/lib/python2.4/site-packages/xen/__init__.py
- touch $(DESTDIR)/usr/lib/python2.4/site-packages/xen/lowlevel/__init__.py
- cp xc.py $(DESTDIR)/usr/lib/python2.4/site-packages/xen/lowlevel
+ mkdir -p $(DESTDIR)$(SITE_DIR)/xen/lowlevel
+ touch $(DESTDIR)$(SITE_DIR)/xen/__init__.py
+ touch $(DESTDIR)$(SITE_DIR)/xen/lowlevel/__init__.py
+ cp xc.py $(DESTDIR)$(SITE_DIR)/xen/lowlevel
@@ -37,15 +37,15 @@ README : index.html
.PHONY: install
install:
mkdir -p $(DESTDIR)$(LIBEXECDIR)
- mkdir -p $(DESTDIR)/usr/lib/$(PYTHON_DIR)/site-packages
+ mkdir -p $(DESTDIR)$(SITE_DIR)
mkdir -p $(DESTDIR)$(PLUGINDIR)
- $(IDATA) XenAPIPlugin.py XenAPI.py inventory.py $(DESTDIR)/usr/lib/$(PYTHON_DIR)/site-packages/
+ $(IDATA) XenAPIPlugin.py XenAPI.py inventory.py $(DESTDIR)$(SITE_DIR)/
$(IEXE) echo.py $(DESTDIR)$(PLUGINDIR)/echo
$(IEXE) wake-on-lan.py $(DESTDIR)$(PLUGINDIR)/wake-on-lan
$(IEXE) shutdown.py $(DESTDIR)$(LIBEXECDIR)/shutdown
$(IEXE) shell.py $(DESTDIR)$(LIBEXECDIR)/shell.py
.PHONY: sdk-install
sdk-install:
- mkdir -p $(DESTDIR)/usr/lib/$(PYTHON_DIR)/site-packages
- $(IDATA) XenAPIPlugin.py XenAPI.py inventory.py $(DESTDIR)/usr/lib/$(PYTHON_DIR)/site-packages/
+ mkdir -p $(DESTDIR)$(SITE_DIR)
+ $(IDATA) XenAPIPlugin.py XenAPI.py inventory.py $(DESTDIR)$(SITE_DIR)/
View
@@ -1,4 +1,4 @@
install:
- mkdir -p $(DESTDIR)/usr/lib/$(PYTHON_DIR)/site-packages
- $(IDATA) rrdd.py $(DESTDIR)/usr/lib/$(PYTHON_DIR)/site-packages/
+ mkdir -p $(DESTDIR)$(SITE_DIR)
+ $(IDATA) rrdd.py $(DESTDIR)$(SITE_DIR)/
$(IPROG) rrdd-example.py $(DESTDIR)$(LIBEXECDIR)
View
@@ -121,6 +121,17 @@ rm -rf %{buildroot}
DESTDIR=$RPM_BUILD_ROOT %{__make} install
+SITEDIR=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
+for f in XenAPI XenAPIPlugin inventory; do
+ for e in py pyc pyo; do
+ echo $SITEDIR/$f.$e
+ done
+done > core-files
+
+for e in py pyc pyo; do
+ echo $SITEDIR/rrdd.$e
+done > rrdd-files
+
%clean
rm -rf $RPM_BUILD_ROOT
@@ -146,7 +157,7 @@ rm -rf $RPM_BUILD_ROOT
%post v6d
[ ! -x /sbin/chkconfig ] || chkconfig --add v6d
-%files core
+%files core -f core-files
%defattr(-,root,root,-)
@OPTDIR@/bin/xapi
/etc/xapi.conf
@@ -272,15 +283,6 @@ rm -rf $RPM_BUILD_ROOT
@OPTDIR@/libexec/pci-info
@OPTDIR@/packages/post-install-scripts/debian-etch
@OPTDIR@/packages/post-install-scripts/debug
-/usr/lib/python2.4/site-packages/XenAPI.py
-/usr/lib/python2.4/site-packages/XenAPI.pyo
-/usr/lib/python2.4/site-packages/XenAPI.pyc
-/usr/lib/python2.4/site-packages/XenAPIPlugin.py
-/usr/lib/python2.4/site-packages/XenAPIPlugin.pyo
-/usr/lib/python2.4/site-packages/XenAPIPlugin.pyc
-/usr/lib/python2.4/site-packages/inventory.py
-/usr/lib/python2.4/site-packages/inventory.pyo
-/usr/lib/python2.4/site-packages/inventory.pyc
/var/xapi/udhcpd.skel
@OPTDIR@/debug/rbac_static.csv
/etc/xapi.d/host-post-declare-dead/10resetvdis
@@ -321,14 +323,11 @@ rm -rf $RPM_BUILD_ROOT
/etc/rc.d/init.d/xcp-networkd
@OPTDIR@/libexec/networkd_db
-%files rrdd
+%files rrdd -f rrdd-files
%defattr(-,root,root,-)
@OPTDIR@/libexec/xcp-rrdd
/etc/rc.d/init.d/xcp-rrdd
/etc/xcp-rrdd.conf
-/usr/lib/python2.4/site-packages/rrdd.py
-/usr/lib/python2.4/site-packages/rrdd.pyc
-/usr/lib/python2.4/site-packages/rrdd.pyo
@OPTDIR@/libexec/rrdd-example.py
@OPTDIR@/libexec/rrdd-example.pyc
@OPTDIR@/libexec/rrdd-example.pyo

0 comments on commit a1d88e2

Please sign in to comment.