Python sys.prefix

2010-01-21 Thread zachar
Hi All,

I need some help about my "problem":
I compiled and installed python with ./configure --prefix=/opt/pyhon2.6.4... 
But I have to move it to a different directory (the reason is very difficult 
but I must do this)... I started the interpreter from shell and I was surprised 
because It still worked and It changed the sys.prefix so it pointed to the 
correct place so the sys.path was correct The questions are: HOW? Is it a 
feature which is not documented (at least I couldn't find anything about it)?

From the official python documentation 
(http://docs.python.org/library/sys.html?highlight=sys#sys.prefix):
"sys.prefix¶

A string giving the site-specific directory prefix where the platform 
independent Python files are installed; by default, this is the string 
'/usr/local'. This can be set at build time with the --prefix argument to the 
configure script. The main collection of Python library modules is installed in 
the directory prefix + '/lib/pythonversion' while the platform independent 
header files (all except pyconfig.h) are stored in prefix + 
'/include/pythonversion', where version is equal to version[:3]."

In my case, this is not correct: it looks, after I call the interpreter, 
something change the sys.prefix variable and point it to the right place and 
not to that directory which I used with the configuration script... This is 
very useful (I am happy because it solves one of my problems) but I am afraid 
of it will be do it in a different way in the future (as it is not documented).

Thanks,
Regards,
Balazs
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python sys.prefix

2010-01-22 Thread Balazs Zachar
It looks like the python install environment is easily movable between 
two machine with the same OS (I mean, with the correct libraries)...

Can I use this in production?

Please consider the following test, after I use ./configure 
--prefix=/opt/python2.6.4 && make && make install:


[r...@centos-5-4-test1 ~]# /opt/python2.6.4/bin/python
Python 2.6.4 (r264:75706, Jan 20 2010, 20:26:15)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
...import sys
...sys.prefix
'/opt/python2.6.4'
...sys.path
['', '/opt/python2.6.4/lib/python26.zip', 
'/opt/python2.6.4/lib/python2.6', 
'/opt/python2.6.4/lib/python2.6/plat-linux2', 
'/opt/python2.6.4/lib/python2.6/lib-tk', 
'/opt/python2.6.4/lib/python2.6/lib-old', 
'/opt/python2.6.4/lib/python2.6/lib-dynload', 
'/opt/python2.6.4/lib/python2.6/site-packages']



[r...@centos-5-4-test1 ~]# mv /opt/python2.6.4/ /opt/python2.6.4_newplace
[r...@centos-5-4-test1 ~]# /opt/python2.6.4_newplace/bin/python
Python 2.6.4 (r264:75706, Jan 20 2010, 20:26:15)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
...import sys
...sys.prefix
'/opt/python2.6.4_newplace'
...sys.path
['', '/opt/python2.6.4_newplace/lib/python26.zip', 
'/opt/python2.6.4_newplace/lib/python2.6', 
'/opt/python2.6.4_newplace/lib/python2.6/plat-linux2', 
'/opt/python2.6.4_newplace/lib/python2.6/lib-tk', 
'/opt/python2.6.4_newplace/lib/python2.6/lib-old', 
'/opt/python2.6.4_newplace/lib/python2.6/lib-dynload', 
'/opt/python2.6.4_newplace/lib/python2.6/site-packages']



On 01/21/2010 05:56 PM, zac...@awst.at wrote:

Hi All,

I need some help about my "problem":
I compiled and installed python with ./configure --prefix=/opt/pyhon2.6.4... 
But I have to move it to a different directory (the reason is very difficult 
but I must do this)... I started the interpreter from shell and I was surprised 
because It still worked and It changed the sys.prefix so it pointed to the 
correct place so the sys.path was correct The questions are: HOW? Is it a 
feature which is not documented (at least I couldn't find anything about it)?

 From the official python documentation 
(http://docs.python.org/library/sys.html?highlight=sys#sys.prefix):
"sys.prefix¶

 A string giving the site-specific directory prefix where the platform 
independent Python files are installed; by default, this is the string '/usr/local'. 
This can be set at build time with the --prefix argument to the configure script. 
The main collection of Python library modules is installed in the directory prefix + 
'/lib/pythonversion' while the platform independent header files (all except 
pyconfig.h) are stored in prefix + '/include/pythonversion', where version is equal 
to version[:3]."

In my case, this is not correct: it looks, after I call the interpreter, 
something change the sys.prefix variable and point it to the right place and 
not to that directory which I used with the configuration script... This is 
very useful (I am happy because it solves one of my problems) but I am afraid 
of it will be do it in a different way in the future (as it is not documented).

Thanks,
Regards,
Balazs
   


--
http://mail.python.org/mailman/listinfo/python-list