[mod_python] Mod_python compilation question, per your's comment on "What Powers Curse"

Graham Dumpleton graham.dumpleton at gmail.com
Tue May 29 06:58:19 EDT 2007


What they have done wrong is that in:

  /usr/lib64/python2.4/config

they should have a symlink to the libpython2.4.so in /usr/lib64.

On Ubuntu they have this link and it compiles fine.

Graham

On 29/05/07, ÕÅ³É <czhang.web at gmail.com> wrote:
>
> On 2007-5-28, at ÏÂÎç6:03, Graham Dumpleton wrote:
>
> > On 28/05/07, ÕÅ³É <czhang.web at gmail.com> wrote:
> >> Graham or other mod_python gurus on the m-list:
> >>
> >> I tried to verify our mod_python compilation/installation is indeed
> >> correct after I read the comment <http://www.davidcramer.net/curse/
> >> 44/
> >> what-powers-curse.html#comment-9271>, especially this part:
> >> [quote]
> >> As a reference point for discussion a correctly compiled Python/
> >> mod_python should only result in an Apache mod_python.so loadable
> >> module of at most about 400 kilobytes.
> >> [/quote]
> >>
> >> Unfortunately, ours mod_python.so is 1.3M in size:
> >> # ls -lh /usr/lib64/apache2/modules/mod_python.so
> >> -rwxr-xr-x 1 root root 1.3M 2007-04-26 08:42 /usr/lib64/apache2/
> >> modules/mod_python.so
> >>
> >> Since our Linux box is running Gentoo 2006.1, we do have the shared
> >> library for Python:
> >> # ls -l /usr/lib/libpython2.4.so
> >> lrwxrwxrwx 1 root root 19 2007-05-28 17:24 /usr/lib/libpython2.4.so -
> >>  > libpython2.4.so.1.0
> >> # ls -l /usr/lib/libpython2.4.so.1.0
> >> -r-xr-xr-x 1 root root 1073360 2007-05-28 17:24 /usr/lib/
> >> libpython2.4.so.1.0
> >
> > What Python libraries are in:
> >
> >  /usr/lib64/python2.4/config
> >
> > and:
> >
> >  /usr/lib64
> >
> > Ie., the 64 bit lib directories.
> >
> > It is going to look in the 'config' directory location above first and
> > if there is only a static library there are not a shared library, it
> > will probably use the static library. This is because the link line
> > for library building according to your logs is:
> >
> >  -L/usr/lib64/python2.4/config
> >
> > Graham
>
> # ls /usr/lib64/python2.4/config
> config.c     install-sh      Makefile         makesetup
> Setup         Setup.local
> config.c.in  libpython2.4.a  Makefile.pre.in  python.o   Setup.config
>
> Indeed there is only a static library.
>
> # ls -ld /usr/lib
> lrwxrwxrwx 1 root root 5 2006-04-03 16:20 /usr/lib -> lib64
>
> The memory usage of mod_python with the static linked Python on our
> box is (via top):
>    PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
> 12243 aiyo       1   0  114m  51m 4428 S  0.0  2.0  22:05.23 /usr/
> sbin/apache2 -f /home/aiyo/apach
> 12605 aiyo       1   0  106m  47m 3536 S  6.0  1.9  17:47.74 /usr/
> sbin/apache2 -f /home/aiyo/apach
> 13192 aiyo       1   0  102m  44m 3536 S  5.0  1.8   7:38.23 /usr/
> sbin/apache2 -f /home/aiyo/apach
> 12949 aiyo       1   0  103m  44m 3540 S  0.0  1.8  11:32.30 /usr/
> sbin/apache2 -f /home/aiyo/apach
> 13297 aiyo       1   0  101m  43m 3536 S  0.0  1.7   5:12.81 /usr/
> sbin/apache2 -f /home/aiyo/apach
> 27974 aiyo      31   0 96200  11m 6188 S  0.0  0.4   0:01.95 /usr/
> sbin/apache2 -f /home/aiyo/php/h
> 28606 aiyo       1   0 95212  10m 6064 S  0.0  0.4   0:01.58 /usr/
> sbin/apache2 -f /home/aiyo/php/h
> 28604 aiyo       1   0 95224  10m 5964 S  0.0  0.4   0:01.89 /usr/
> sbin/apache2 -f /home/aiyo/php/h
> 12128 aiyo       1   0 95192 9856 5504 S  0.0  0.4   0:00.41 /usr/
> sbin/apache2 -f /home/aiyo/php/h
> 27972 aiyo      17   0 93004 8264 4992 S  0.0  0.3   0:00.17 /usr/
> sbin/apache2 -f /home/aiyo/php/h
>
> The first five apache process is an apache instance running
> mod_python, the next five apache process is another apache instance
> running mod_php5.
>
> I just found out there is a program called 'python-config', whose
> output is:
> # python-config
> -lpython2.4 -lm -L/usr/lib64/python2.4/config
>
> Seems to me that this is where the link parameters for Python come
> from, but don't know how to adjust it to have '-L/usr/lib64'.
>
> I decided to supply the environment variable LDFLAGS="-L/usr/lib64"
> while compiling mod_python, that results in such link command:
> /usr/share/apr-0/build/libtool --silent --mode=link x86_64-pc-linux-
> gnu-gcc -o mod_python.la  -rpath /usr/lib64/apache2/modules -module -
> avoid-version    finfoobject.lo hlistobject.lo hlist.lo
> filterobject.lo connobject.lo serverobject.lo util.lo tableobject.lo
> requestobject.lo _apachemodule.lo mod_python.lo -L/usr/lib64 -L/usr/
> lib64/python2.4/config -Xlinker -export-dynamic -lm -lpython2.4 -
> lpthread -ldl -lutil -lm
>
> # ldd src/.libs/mod_python.so
>          libpython2.4.so.1.0 => /usr/lib/libpython2.4.so.1.0
> (0x00002b359b034000)
>          libpthread.so.0 => /lib/libpthread.so.0 (0x00002b359b240000)
>          libdl.so.2 => /lib/libdl.so.2 (0x00002b359b35a000)
>          libutil.so.1 => /lib/libutil.so.1 (0x00002b359b45f000)
>          libm.so.6 => /lib/libm.so.6 (0x00002b359b562000)
>          libc.so.6 => /lib/libc.so.6 (0x00002b359b6b7000)
>          /lib64/ld-linux-x86-64.so.2 (0x0000555555554000)
>
> Now the memory usage of mod_python with the dynamic linked Python on
> our box is (via top):
>    PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
> 20754 aiyo       5   0  114m  46m 4460 S  0.0  1.9  12:16.48 /usr/
> sbin/apache2 -f /home/aiyo/apach
> 22607 aiyo       1   0  105m  44m 3472 S  0.0  1.8   2:16.71 /usr/
> sbin/apache2 -f /home/aiyo/apach
> 21664 aiyo       1   0  104m  44m 3916 S  0.0  1.8   8:18.80 /usr/
> sbin/apache2 -f /home/aiyo/apach
> 22498 aiyo       1   0  103m  43m 3476 S  1.0  1.7   2:18.09 /usr/
> sbin/apache2 -f /home/aiyo/apach
> 22681 aiyo       1   0  101m  42m 3472 S  0.0  1.7   1:11.02 /usr/
> sbin/apache2 -f /home/aiyo/apach
> 22721 aiyo       1   0 99.5m  40m 3460 S  0.0  1.6   0:19.66 /usr/
> sbin/apache2 -f /home/aiyo/apach
>
> Looks like I do squeeze a few meg bytes out of each apache process
> with your help. :-)
> Thanks.
>
> BR,
> - Cheng



More information about the Mod_python mailing list