[Python-Dev] Relocating Python
Casey Duncan
casey at pandora.com
Tue Jul 29 21:54:31 CEST 2008
On Jul 29, 2008, at 12:56 PM, Lupusoru, Razvan A wrote:
> Hello,
>
> I am trying to get Python 2.5.2 working for an IA32 system. The
> compilation is done on an Ubuntu 8.04.1 dev system. I am using a
> custom gcc and ld specific to the IA32 system.
>
> This is my makefile:
> ##############################
> BUILD_DEST = /i686-custom-kernel
> CC = $(BUILD_DEST)/bin/i686-linux-gcc
> CPP = $(CC) –E
> CXX = $(BUILD_DEST)/bin/i686-linux-g++
> LD = $(BUILD_DEST)/bin/i686-linux-ld
> PYTHONINSTALLPATH = $(BUILD_DEST)/usr
> Export
>
> all:
> tar xzfv Python-2.5.2.tgz
> ./Python-2.5.2/configure –prefix=$
> {PYTHONINSTALLPATH} –host=i686-linux –enable-shared
> cd Python-2.5.2
> make
> make install
> ##############################
>
> Everything compiles correctly. I then copy the contents of the
> $BUILD_DEST and put them on the hard drive for my IA32 system. I
> basically use the contents of $BUILD_DEST as the root directory on
> my IA32 system. Python seems to run correctly when I run it, but
> when I do things like “import pysqlite”, it cannot find it. Is there
> anything special I have to do to relocate my python (since on my
> IA32 system it runs from /usr/bin/python but it originally gets
> created in ${BUILD_DEST}/usr/bin/python)?
You'll want to pass configure the prefix where python will ultimately
be installed, otherwise the paths used during make won't make sense
on the destination system. That said, pysqlite is not part of the
stdlib, so your actual problem may have more to do with how you've
installed it then anything. When you run python once relocated, what
does os.path contain?
What we do for packaging, is run 'configure' normally and then 'make',
then override some make variables for 'make install' to temporarily
install it in a different place for package staging. It looks
something like this:
./configure && \
make && \
make BINDIR=$(shell pwd)/path/to/tmp/bin \
CONFINCLUDEDIR=$(shell pwd)/path/to/tmp/include \
INCLUDEDIR=$(shell pwd)/path/to/tmp/include \
LIBDIR=$(shell pwd)/path/to/tmp/lib \
MANDIR=$(shell pwd)/path/to/tmp/man \
SCRIPTDIR=$(shell pwd)/path/to/tmp/lib \
install
Then when the package is deployed, the files are actually installed
under the standard 'configure' prefix (/usr/local I think).
hth,
-Casey
More information about the Python-Dev
mailing list