william-os4y / fapws3

Fast Asynchronous Python Web Server (based on libev)
GNU General Public License v2.0
341 stars 38 forks source link

Build fails on OS X Lion 10.7.2 #31

Closed mettienne closed 12 years ago

mettienne commented 12 years ago

Trying to build fapws3 on OS X Lion 10.7.2:

python Python 2.7.1 (r271:86832, Jun 25 2011, 05:09:01) [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin Type "help", "copyright", "credits" or "license" for more information.

brew list libev pkg-config

sudo python setup.py build Find python 2.4 or higher ----------Find ev.h in /usr/include/sys ----------Find Python.h in /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 ----------Find libev.a in /usr/local/lib running build running build_py running egg_info writing fapws3.egg-info/PKG-INFO writing top-level names to fapws3.egg-info/top_level.txt writing dependency_links to fapws3.egg-info/dependency_links.txt writing entry points to fapws3.egg-info/entry_points.txt reading manifest file 'fapws3.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' writing manifest file 'fapws3.egg-info/SOURCES.txt' running build_ext building 'fapws._evwsgi' extension llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/usr/include/sys -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c fapws/extra.c -o build/temp.macosx-10.7-intel-2.7/fapws/extra.o fapws/extra.c: In function ‘cur_time’: fapws/extra.c:124: warning: implicit declaration of function ‘time’ fapws/extra.c:125: warning: implicit declaration of function ‘gmtime’ fapws/extra.c:125: warning: assignment makes pointer from integer without a cast fapws/extra.c:131: warning: implicit declaration of function ‘strftime’ fapws/extra.c:131: warning: incompatible implicit declaration of built-in function ‘strftime’ fapws/extra.c: In function ‘time_rfc1123’: fapws/extra.c:150: warning: assignment makes pointer from integer without a cast fapws/extra.c:151: warning: incompatible implicit declaration of built-in function ‘strftime’ fapws/extra.c:152: error: dereferencing pointer to incomplete type fapws/extra.c:153: error: dereferencing pointer to incomplete type fapws/extra.c: In function ‘cur_time’: fapws/extra.c:124: warning: implicit declaration of function ‘time’ fapws/extra.c:125: warning: implicit declaration of function ‘gmtime’ fapws/extra.c:125: warning: assignment makes pointer from integer without a cast fapws/extra.c:131: warning: implicit declaration of function ‘strftime’ fapws/extra.c:131: warning: incompatible implicit declaration of built-in function ‘strftime’ fapws/extra.c: In function ‘time_rfc1123’: fapws/extra.c:150: warning: assignment makes pointer from integer without a cast fapws/extra.c:151: warning: incompatible implicit declaration of built-in function ‘strftime’ fapws/extra.c:152: error: dereferencing pointer to incomplete type fapws/extra.c:153: error: dereferencing pointer to incomplete type lipo: can't open input file: /var/tmp//cctEwHqX.out (No such file or directory) error: command 'llvm-gcc-4.2' failed with exit status 1

Seems like a problem with the #include . Same errors and warnings installing from the python3 branch. Any suggestions?

Mikko

william-os4y commented 12 years ago

I don't have Mac, so I cannot help you. Please refer to the user's community of Fapws. When I release Fapws, I personally, perform tests on Linux (Archlinux and Fedore), Freebsd, OpenBSD and DragonFlyBSD. If someone will donate a Mac ... he is welcome ;-)

When contacting people, better to refer to the version of Fapws you are using, python, libev and OS. I remind you that Master branch runs only on Python-2.x.

mettienne commented 12 years ago

I made a bit progression. Now I'm stuck with the -R linker flag defined in extra_link_args=['-Wl,-R%s' % res] not being recognized by the os x linker. If i comment out this line i get the following:

llvm-gcc-4.2 -Wl,-F. -bundle -undefined dynamic_lookup -Wl,-F. -arch i386 -arch x86_64 build/temp.macosx-10.7-intel-2.7/fapws/extra.o build/temp.macosx-10.7-intel-2.7/fapws/wsgi.o build/temp.macosx-10.7-intel-2.7/fapws/mainloop.o build/temp.macosx-10.7-intel-2.7/fapws/_evwsgi.o -L/usr/local/lib -lev -o build/lib.macosx-10.7-intel-2.7/fapws/_evwsgi.so -Wl,-L/usr/local/lib ld: duplicate symbol _debug in build/temp.macosx-10.7-intel-2.7/fapws/mainloop.o and build/temp.macosx-10.7-intel-2.7/fapws/wsgi.o for architecture i386 collect2: ld returned 1 exit status

It seems like other people had problems compiling on OS X as well. DId you ever hear of anyone successfully compiling fapws3 on OS X?

mettienne commented 12 years ago

Hi again. I finally managed to build fapws3 and has successfully tested it with the hello world example.

My system specs are:

OS X 10.7.2 Python 2.7.1 Homebrew 0.8.1

The steps I took to make it work are as follows:

Build libev for multi-architecture: $ brew edit libev add: ENV["CFLAGS"] = '-arch i386 -arch x86_64' just above the line: system "./configure", "--disable-dependency-tracking", run brew install libev

Get the source for fapws3 and edit the setup.py file:

Including the search dir /usr/include will incorrectly make the compiler use time.h from this dir. To avoid this replace line 66 with: search_include_dirs.extend(['/usr/local/include','/opt/local/include','/usr/pkg/include/ev'])

The -R path option is not recognized by the osx linker and is not needed: Comment out line 125

Lastly it seems like some symbols are defined globally in multiple files. I guess the GNU compiler handles this, but to make it work on OS X we have to define all global variables external:

mainloop.c replace line 27-37 with:

extern int debug; extern PyObject pydeferqueue; extern PyObject py_base_module; //to store the fapws.base python module extern PyObject py_config_module; //to store the fapws.config module extern PyObject py_registered_uri; //list containing the uri registered and their associated wsgi callback.

define MAX_BUFF 32768 //read buffer size. bigger faster, but memory foot print bigger

define MAX_RETRY 9 //number of connection retry

extern char * VERSION; extern PyObject py_generic_cb; extern char \ date_format;

wsgi.c replace line 12-14 with:

extern char server_name; extern char server_port; extern int debug;

William, I will be happy to test it, if you put any of these fixes in the source code.

Mikko

william-os4y commented 12 years ago

Done. Can you check the latest release of "master" ?

mettienne commented 12 years ago

Great, builds without errors on my system. You could consider adding the libev install details to the mac getting started section: If you have homebrew build libev for multi-architecture: $ brew edit libev

add: ENV["CFLAGS"] = '-arch i386 -arch x86_64' just above the line: system "./configure", "--disable-dependency-tracking",

$ sudo brew install libev

Great project, I'm considering to use Fapws for our production site instead of Cherokee because of its very low memory footprint and excellent speed.