[Twisted-web] CorePost 0.0.7 - all about content types

Jarosław Fedewicz jaroslaw.fedewicz at gmail.com
Fri Sep 30 11:55:56 EDT 2011

On Sep 30, 2011, at 16:55 , exarkun at twistedmatrix.com wrote:

> On 01:18 pm, jacek99 at gmail.com wrote:
>> And once I reach 0.1 with all of these features, I will post some blog
>> entries about this together with PyPy benchmarks...so that people don't
>> think
>> Javascript / Node.js is your only option when it comes to async I/O web
>> frameworks :-)
>> BTW, is there any progress on getting Twisted to install under PyPy in 
>> the
>> near future? I know you guys have been looking into it....
> http://twistedmatrix.com/trac/ticket/5158 is resolved now.  If there are 
> still problems with Twisted trunk at HEAD on PyPy, please let us know. :)

There are in fact some problems.

$ sudo pypy-c ./setup.py install
running install
running bdist_egg
running egg_info
writing top-level names to Twisted.egg-info/top_level.txt
writing requirements to Twisted.egg-info/requires.txt
writing dependency_links to Twisted.egg-info/dependency_links.txt
writing Twisted.egg-info/PKG-INFO
writing manifest file 'Twisted.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.6-i386/egg
running install_lib
running build_py
running build_ext
cc -arch i386 -fPIC -Wimplicit -I/opt/local/lib/pypy/include -c conftest.c -o conftest.o
building 'twisted.runner.portmap' extension
cc -arch i386 -fPIC -Wimplicit -I/opt/local/lib/pypy/include -c twisted/runner/portmap.c -o build/temp.macosx-10.6-i386-2.7/twisted/runner/portmap.o
twisted/runner/portmap.c:10:20: error: Python.h: No such file or directory
twisted/runner/portmap.c:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
twisted/runner/portmap.c:31: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
twisted/runner/portmap.c:45: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘PortmapMethods’
twisted/runner/portmap.c: In function ‘initportmap’:
twisted/runner/portmap.c:55: warning: implicit declaration of function ‘Py_InitModule’
twisted/runner/portmap.c:55: error: ‘PortmapMethods’ undeclared (first use in this function)
twisted/runner/portmap.c:55: error: (Each undeclared identifier is reported only once
twisted/runner/portmap.c:55: error: for each function it appears in.)

I have PyPy 1.6 with cpyext.

This patch seems to fix the C extensions errors:

Index: twisted/topfiles/setup.py
--- twisted/topfiles/setup.py	(revision 32705)
+++ twisted/topfiles/setup.py	(working copy)
@@ -37,10 +37,11 @@
               condition=lambda _: _isCPython and sys.platform == "win32"),
-              ["twisted/python/_initgroups.c"]),
+              ["twisted/python/_initgroups.c"],
+              condition=lambda _: _isCPython),
-              condition=lambda _: sys.platform != "win32"),
+              condition=lambda _: _isCPython and sys.platform != "win32"),
 # Figure out which plugins to include: all plugins except subproject ones
Index: twisted/runner/topfiles/setup.py
--- twisted/runner/topfiles/setup.py	(revision 32705)
+++ twisted/runner/topfiles/setup.py	(working copy)
@@ -1,6 +1,8 @@
 # Copyright (c) Twisted Matrix Laboratories.
 # See LICENSE for details.
+from twisted.python.dist import _isCPython
     from twisted.python.dist import setup, ConditionalExtension as Extension
 except ImportError:
@@ -11,7 +13,7 @@
 extensions = [
-              condition=lambda builder: builder._check_header("rpc/rpc.h")),
+              condition=lambda builder: _isCPython and builder._check_header("rpc/rpc.h")),
 if __name__ == '__main__':

however, setuptools trigger GC mis(?)behaviour in PyPy and setup fails:

.... lots of logging snipped
Extracting Twisted-11.0.0_r32705-py2.7-macosx-10.6-i386.egg to /opt/local/lib/pypy/site-packages
error: /opt/local/lib/pypy/site-packages/Twisted-11.0.0_r32705-py2.7-macosx-10.6-i386.egg/twisted/enterprise/row.pyc: Too many open files

This error is known to PyPy guys, they, however, insist that setuptools are wrong and not them. Which sounds totally wrong to me, but again, who am I to judge.

More information about the Twisted-web mailing list