[mod_python] Compile problems - Mod_Python 3.1.4

Jim Gallacher jg.lists at sympatico.ca
Tue May 10 01:09:15 EDT 2005


Frank,

I may have been a little premature with the solution I offered. The 
problem I found in setup.py is in the subversion trunk version, not in 
the mod_python 3.1.4 tarball. If you are compiling from the tarball then 
your problems may lie elsewhere. If you are using the svn repository, 
then the attached patch should fix your problems.

Changes:
Fixed regular expression problem in getconfigure_option()
Fixed indent problem in getconfigure_option()
Fixed incorrect libraries list in ModPyExtension. List was specific to 
windows.

(Nicolas - I'll email the patch to python-dev in a separate message).

Regards,
Jim

Nicolas Lehuen wrote:
> Did you try :
> 
> r = re.compile(r's,\s*@%s@,\s*(?P<OPTION_STRING>[^,]+),\s*' % (option_name))
> 
> Notice the "r" just before the quote to toggle the regular expression
> string mode.
> 
> Regards,
> Nicolas
> 
> 2005/5/9, Jim Gallacher <jg.lists at sympatico.ca>:
> 
>>Frank,
>>
>>Frank Gruman wrote:
>>
>>>Nicolas,
>>>
>>>The script you are running is automatically included as part of the make
>>>process on Linux.
>>>
>>>But I am willing to try anything...
>>
>>OK, here's something. :)
>>
>>
>>>Running the script with the method you specify returns the same ending
>>>error code that I found earlier (about the APXS definition not found).
>>>Thanks for the idea, though.
>>>
>>>Anyone have any idea why the setup.py script is not able to pass the
>>>APXS value from config.status back to setup.py (getconfigure_option
>>>function).  I have verified that there is a value assigned in
>>>config.status (/usr/local/apache2/bin/apxs).
>>
>>I think there is a problem with the regular expression which searches
>>for APXS in config.status. (I'm getting the same error on Debian as you
>>are on SLES).
>>
>>Setup.py is using the following re:
>>r = re.compile('s, @%s@, (?P<OPTION_STRING>[^,]+), ' % (option_name))
>>
>>While my config.status output looks like this:
>>s, at APXS@,/usr/bin/apxs2,;t t
>>
>>Notice the lack of spaces after the commas? I wonder if the output of
>>configure is somehow platform dependant, which is why Nicolas has not
>>seen a problem?
>>
>>I've been trying to tweak the re to make it work, but so far it's mainly
>>been an exercise in banging head against the monitor. (Somebody really
>>should come up with a padded monitor - they'd make a fortune). I both
>>love and hate regular expressions at the same time.
>>
>>Anyway, as a quick fix you could apply the following patch to
>>setup.py.in, and do the configure + make cycle again.
>>
>>Index: setup.py.in
>>===================================================================
>>--- setup.py.in (revision 169349)
>>+++ setup.py.in (working copy)
>>@@ -62,7 +62,8 @@
>>
>>  def getapxs_location():
>>      """finds the location of apxs from the config.status file"""
>>-    return getconfigure_option("APXS")
>>+    #return getconfigure_option("APXS")
>>+    return '/usr/local/apache2/bin/apxs'
>>
>>  def getapxs_option(option):
>>      APXS = getapxs_location()
>>
>>Also, I don't know if you resolved the psp_flex issue, but the
>>src/Makefile.in hard codes LEX=/usr/local/bin/flex, which fails on my
>>system since flex is located in /usr/bin. A quick edit of the Makefile
>>took care of that for me.
>>
>>If your luck is anything like mine the next thing you'll have to deal
>>with is the linker not finding libapr.
>>
>>Personally, I've avoided these issues by using the setup.py included
>>with Debian, even when compiling from the svn trunk.
>>
>>Regards,
>>Jim
>>
>>
>>
>>>Oh - also realized I didn't provide OS - SLES 9.
>>>
>>>Regards,
>>>Frank
>>>
>>>Nicolas Lehuen wrote:
>>>
>>>
>>>>Hi,
>>>>
>>>>Just a wild guess, as I'm building under Win32... Did you try :
>>>>
>>>>python setup.py install
>>>>
>>>>?
>>>>
>>>>This works under Win32.
>>>>
>>>>Regards,
>>>>
>>>>Nicolas
>>>>
>>>>2005/5/9, Frank Gruman <fgatwork at verizon.net>:
>>>>
>>>>
>>>>
>>>>>Hello all,
>>>>>
>>>>>I am trying to test the latest Apache dev version, and found an issue when trying to compile mod_python 3.1.4 with it.
>>>>>
>>>>>I originally tired using Apache 2.1.5-dev (from tip on Friday, 06-May) with mod_python 3.1.4 and Python 2.4.1.  When this failed, I thought that there might have been a resolution in the current mod_python tip, so pulled the mod_python tip as of 09-May @ 13:00.  Still ran into the same errors.
>>>>>
>>>>>The system goes through the ./configure without any issues.  Please see the steps / output below.  It gets quite long, so please bear with me.
>>>>>
>>>>>*  Configure *****************************************
>>>>>toybox:/sources/mod_python-3.1.4 # ./configure --with-apxs=/usr/local/apache2/bin/apxs
>>>>>checking for gcc... gcc
>>>>>checking for C compiler default output... a.out
>>>>>checking whether the C compiler works... yes
>>>>>checking whether we are cross compiling... no
>>>>>checking for suffix of executables...
>>>>>checking for suffix of object files... o
>>>>>checking whether we are using the GNU C compiler... yes
>>>>>checking whether gcc accepts -g... yes
>>>>>checking for ar... ar
>>>>>checking for a BSD-compatible install... /usr/bin/install -c
>>>>>checking whether make sets ${MAKE}... yes
>>>>>checking for main in -lm... yes
>>>>>checking for gcc option to accept ANSI C... none needed
>>>>>checking for an ANSI C-conforming const... yes
>>>>>checking your blood pressure... a bit high, but we can proceed
>>>>>configure: checking whether apxs is available...
>>>>>checking for --with-apxs... /usr/local/apache2/bin/apxs executable, good
>>>>>checking Apache version... 2.1.5-dev
>>>>>checking for Apache libexec directory... /usr/local/apache2/modules
>>>>>checking for Apache include directory... -I/usr/local/apache2/include
>>>>>checking for --with-python... no
>>>>>checking for python... /usr/bin/python
>>>>>checking Python version... 2.4
>>>>>checking Python install prefix... /usr
>>>>>checking for Py_NewInterpreter in -lpython2.4... yes
>>>>>checking what libraries Python was linked with... -lpython2.4   -lpthread -ldl  -lutil   -lm
>>>>>checking linker flags used to link Python...
>>>>>checking where Python include files are... -I/usr/include/python2.4
>>>>>configure: creating ./config.status
>>>>>config.status: creating Makefile
>>>>>config.status: creating src/Makefile
>>>>>config.status: creating Doc/Makefile
>>>>>config.status: creating test/testconf.py
>>>>>config.status: creating dist/setup.py
>>>>>config.status: creating dist/Makefile
>>>>>toybox:/sources/mod_python-3.1.4 #
>>>>>****************************************************
>>>>>
>>>>>No warnings or errors.  Looks good.  Let's go on...
>>>>>
>>>>>* 1st Make *****************************************
>>>>>toybox:/sources/mod_python-3.1.4 # make
>>>>>make[1]: Entering directory `/sources/mod_python-3.1.4/src'
>>>>>
>>>>>Compiling for DSO.
>>>>>
>>>>>
>>>>>
>>>
>>><snipped log as it was getting to big for the message board>
>>>
>>>>>/usr/local/apache2/build/libtool --silent --mode=link gcc -o mod_python.la  -rpath /usr/local/apache2/modules -module -avoid-version    hlistobject.lo hlist.lo filterobject.lo connobject.lo serverobject.lo util.lo tableobject.lo requestobject.lo _apachemodule.lo mod_python.lo -L/usr/lib/python2.4/config -Xlinker -export-dynamic -lm -lpython2.4 -lpthread -ldl -lutil -lm
>>>>>make[1]: Leaving directory `/sources/mod_python-3.1.4/src'
>>>>>make[1]: Entering directory `/sources/mod_python-3.1.4/dist'
>>>>>ln -s ../lib/python/mod_python
>>>>>ln -s ../src
>>>>>make[2]: Entering directory `/sources/mod_python-3.1.4/src'
>>>>>/usr/local/bin/flex -R -opsp_parser.c --header-file=include/psp_flex.h psp_parser.l
>>>>>make[2]: /usr/local/bin/flex: Command not found
>>>>>make[2]: *** [psp_parser.c] Error 127
>>>>>make[2]: Leaving directory `/sources/mod_python-3.1.4/src'
>>>>>make[1]: *** [build] Error 2
>>>>>make[1]: Leaving directory `/sources/mod_python-3.1.4/dist'
>>>>>make: *** [do_dso] Error 2
>>>>>toybox:/sources/mod_python-3.1.4 #
>>>>>***************************************************
>>>>>
>>>>>It appears I the system could not find psp_parser.c.  This is not in the src directory.  I looked at the SVN repository, and found it there.  Not sure why it didn't come with the initial checkout, but I manually downloaded it.  Let's try to do a MAKE again.
>>>>>
>>>>>* 2nd Make ****************************************
>>>>>
>>>>>toybox:/sources/mod_python-3.1.4 # make clean && make
>>>>>
>>>>>
>>>>>
>>>
>>><snipped log as it was getting to big for the message board>
>>>
>>>
>>>>>/usr/local/apache2/build/libtool --silent --mode=link gcc -o mod_python.la  -rpath /usr/local/apache2/modules -module -avoid-version    hlistobject.lo hlist.lo filterobject.lo connobject.lo serverobject.lo util.lo tableobject.lo requestobject.lo _apachemodule.lo mod_python.lo -L/usr/lib/python2.4/config -Xlinker -export-dynamic -lm -lpython2.4 -lpthread -ldl -lutil -lm
>>>>>make[1]: Leaving directory `/sources/mod_python-3.1.4/src'
>>>>>make[1]: Entering directory `/sources/mod_python-3.1.4/dist'
>>>>>ln -s ../lib/python/mod_python
>>>>>make[2]: Entering directory `/sources/mod_python-3.1.4/src'
>>>>>make[2]: `psp_parser.c' is up to date.
>>>>>make[2]: Leaving directory `/sources/mod_python-3.1.4/src'
>>>>>/usr/bin/python setup.py build
>>>>>Traceback (most recent call last):
>>>>> File "setup.py", line 138, in ?
>>>>>   ModPyModule = ModPyExtension(getmp_srcdir(), [getmp_includedir(), getapache_includedir()], [getapache_libdir()])
>>>>> File "setup.py", line 80, in getapache_includedir
>>>>>   return getapxs_option("INCLUDEDIR")
>>>>> File "setup.py", line 68, in getapxs_option
>>>>>   APXS = getapxs_location()
>>>>> File "setup.py", line 65, in getapxs_location
>>>>>   return getconfigure_option("APXS")
>>>>> File "setup.py", line 47, in getconfigure_option
>>>>>   raise AssertionError("unable to find @%s@ definition in %s", (option_name, config_status_file))
>>>>>AssertionError: ('unable to find @%s@ definition in %s', ('APXS', '/sources/mod_python-3.1.4/config.status'))
>>>>>make[1]: *** [build] Error 1
>>>>>make[1]: Leaving directory `/sources/mod_python-3.1.4/dist'
>>>>>make: *** [do_dso] Error 2
>>>>>toybox:/sources/mod_python-3.1.4 #
>>>>>****************************************************
>>>>>
>>>>>So - now it seems to have problems reading the value I passed for the APXS parameter.  And I can't figure out why.
>>>>>
>>>>>Any ideas??
>>>>>
>>>>>Regards,
>>>>>Frank
>>>>>_______________________________________________
>>>>>Mod_python mailing list
>>>>>Mod_python at modpython.org
>>>>>http://mailman.modpython.org/mailman/listinfo/mod_python
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>------------------------------------------------------------------------
>>>
>>>_______________________________________________
>>>Mod_python mailing list
>>>Mod_python at modpython.org
>>>http://mailman.modpython.org/mailman/listinfo/mod_python
>>
>>
> 

-------------- next part --------------
Index: dist/setup.py.in
===================================================================
--- dist/setup.py.in	(revision 169406)
+++ dist/setup.py.in	(working copy)
@@ -39,12 +39,12 @@
     if not os.path.exists(config_status_file):
         raise AssertionError("config.status not found in expected location (%s)" % config_status_file)
     header = open(config_status_file, 'r')
-    r = re.compile('s, @%s@, (?P<OPTION_STRING>[^,]+), ' % (option_name))
+    r = re.compile(r's,\s*@%s@,\s*(?P<OPTION_STRING>[^,]+),\s*' % (option_name))
     for line in header.readlines():
         m = r.search(line)
         if m is not None:
             return m.group('OPTION_STRING')
-        raise AssertionError("unable to find @%s@ definition in %s", (option_name, config_status_file))
+    raise AssertionError("unable to find @%s@ definition in %s", (option_name, config_status_file))
 
 def getmp_version():
     """finds out the version of mod_python"""
@@ -120,10 +120,15 @@
 class ModPyExtension(Extension):
     """a class that actually builds the mod_python.so extension for Apache (yikes)"""
     def __init__(self, source_dir, include_dirs, library_dirs):
+        if winbuild:
+            libraries = ['libhttpd', 'libapr', 'libaprutil', 'ws2_32']
+        else:
+            libraries = ['apr-0', 'aprutil-0']
+
         Extension.__init__(self, "mod_python_so",
             sources = [os.path.join(source_dir, source_file) for source_file in modpy_src_files],
                            include_dirs=include_dirs,
-            libraries = ['libhttpd', 'libapr', 'libaprutil', 'ws2_32'],
+            libraries = libraries
             library_dirs=library_dirs
                            )
         if winbuild:


More information about the Mod_python mailing list