hoe to build a patched socketmodule.c

jacopo mondi mondi at cs.unibo.it
Sat Jul 11 13:55:25 EDT 2009


Scott David Daniels wrote:
> jacopo mondi wrote:
>> Roger Binns wrote:
>>> jacopo mondi wrote:
>>>> Hi all, I need to patch socketmodule.c (the _socket module) in order to
>>>> add support to an experimental socket family.
>>> You may find it considerably easier to use ctypes since that will avoid
>>> the need for any patching.  You'll also be able to control how read and
>>> write are done (eg read vs recvfrom vs recvmsg vs readv).  You can use
>>> os.fdopen to convert your raw file descriptor into a Python file object
>>> if appropriate.
> 
> The typical Python way of dealing with this is an additional module, not
> a modified module placed back in the library.  So, take the sources and
> edit, but change the module name.  Even better is figure out how to
> use _socket.pyd, to create a smaller _socketexpmodule.c and use that.
> 
> --Scott David Daniels
> Scott.Daniels at Acm.Org
Thanks a lot Scott.
If I'll write a new module, with a new name, based on socketmodule.c I
will not be able to ditribuite the source code and make users compile it
using distutils, instead I have to compile it using the whole python
build system (changing setup.py in python sources to let it know about
my new module) and distribuite the compiled .so with a script to install
it, I suppose. Anyway, that's not too bad...
Reusing _socket.so, or the main wrapper socket.pyc I think is not
possible, because I need to modify low level functions that are not exposed

thanks again
	jacopo



More information about the Python-list mailing list