view tools/python/Makefile @ 19527:0e24e9674ded

tools: Always use sane upstream (`native') python paths

Previously, by default we would install our python modules into
/usr/lib/python/xen, for example /usr/lib/python/xen/__init__.py.
Upstream python's standard install location (a) includes the Python
version number and (b) puts things in site-packages by default.

Our best conjecture for the reason for this was an attempt to make the
installs portable between different python versions. However, that
doesn't work because compiled python modules (.pyc), and C python
extensions corresponding to one version of python, are not compatible
across different versions of python.

This is why upstream include the version number.

site-packages is the standard location for locally-installed packages
and is automatically included on the python search path.

In this change, we abandon our own unusual python path setup:

* Invoke setup.py in an entirely standard manner. We pass
PREFIX and DESTDIR using the appropriate options provided by
setup.py for those purposes (adding them to setup.py calls
which were previously lacking them).

* Since the installation locations are now on the standard
python path, we no longer need to add anything to the path
in any of our python utilities. Therefore remove all that
code from every python script. (Many of these scripts
unconditionally added /usr/lib/python and /usr/lib64/python which
is wrong even in the old world.)

* There is no longer any special `Xen python path'. xen-python-path
is no longer needed. It is no longer called by anything in our
tree. However since out-of-tree callers may still invoke it, we
retain it. It now prints a fixed string referring to a directory
which does not to exist; callers (who use it to augment their
python path) will thus add a nonexistent directory to their python
path which is harmless.

* Remove various workarounds including use of setup.py --home
(which is intended for something completely different).

* Remove tests for the XEN_PYTHON_NATIVE_INSTALL build-time
environment variable. The new behaviour is the behaviour which we
should have had if this variable had been set. That is, it is now
as if this variable was always set but also bugs in the resulting
install have been fixed.

This should be a proper fix for the bug addressed by c/s 19515.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Apr 08 19:13:04 2009 +0100 (2009-04-08)
parents d9de5cc2b0bc
children bf946cc3008b
line source
1 XEN_ROOT = ../..
2 include $(XEN_ROOT)/tools/Rules.mk
4 .PHONY: all
5 all: build
7 # For each new supported translation, add its name here, eg 'fr_FR'
8 # to cause the .po file to be built & installed, eg
10 POPACKAGE := xen-xm
11 PODIR := xen/xm/messages
12 POTFILE := $(PODIR)/xen-xm.pot
13 I18NSRCFILES = $(shell find xen/xm/ -name '*.py')
14 CATALOGS = $(patsubst %,xen/xm/messages/%.mo,$(LINGUAS))
15 NLSDIR = $(SHAREDIR)/locale
17 .PHONY: build buildpy
18 buildpy:
19 CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py build
21 build: buildpy refresh-pot refresh-po $(CATALOGS)
23 # NB we take care to only update the .pot file it strings have
24 # actually changed. This is complicated by the embedded date
25 # string, hence the sed black magic. This avoids the expensive
26 # re-generation of .po files on every single build
27 refresh-pot: $(I18NSRCFILES)
28 xgettext --default-domain=$(POPACAKGE) \
29 --keyword=N_ \
30 --keyword=_ \
31 -o $(POTFILE)-tmp \
33 sed -f remove-potcdate.sed < $(POTFILE) > $(POTFILE)-1
34 sed -f remove-potcdate.sed < $(POTFILE)-tmp > $(POTFILE)-2
35 set -e; if cmp -s $(POTFILE)-1 $(POTFILE)-2; then \
36 rm -f $(POTFILE)-tmp $(POTFILE)-1 $(POTFILE)-2; \
37 else \
38 mv $(POTFILE)-tmp $(POTFILE); \
39 rm -f $(POTFILE)-1 $(POTFILE)-2; \
40 fi
42 refresh-po: $(POTFILE)
43 set -e; for l in $(LINGUAS); do \
44 if $(MSGMERGE) $(PODIR)/$$l.po $(POTFILE) > $(PODIR)/$$l-tmp ; then \
45 mv -f $(PODIR)/$$l-tmp $(PODIR)/$$l.po ; \
46 echo "$(MSGMERGE) of $$l.po succeeded" ; \
47 else \
48 echo "$(MSGMERGE) of $$l.po failed" ; \
49 rm -f $(PODIR)/$$l-tmp ; \
50 fi \
51 done
53 %.mo: %.po
54 $(MSGFMT) -c -o $@ $<
56 .PHONY: install
57 install: install-messages install-dtd
58 CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install \
59 --prefix="$(PREFIX)" --root="$(DESTDIR)" --force
61 install-dtd: all
63 $(INSTALL_DATA) xen/xm/create.dtd $(DESTDIR)$(DOCDIR)
65 install-messages: all
66 set -e; if which $(MSGFMT) >/dev/null ; then \
68 for l in $(LINGUAS); do \
71 $(INSTALL_DATA) $(PODIR)/$$l.mo \
73 done ; \
74 fi
76 .PHONY: test
77 test:
78 export LD_LIBRARY_PATH=$$(readlink -f ../libxc):$$(readlink -f ../xenstore); python test.py -b -u
80 .PHONY: clean
81 clean:
82 rm -rf build *.pyc *.pyo *.o *.a *~ $(CATALOGS) xen/util/auxbin.pyc
83 rm -f $(DEPS)
85 -include $(DEPS)