[PATCHES] Port pytalloc to Python 3

Petr Viktorin pviktori at redhat.com
Fri Dec 5 02:52:42 MST 2014


Hi,
Thanks for looking at the patches! Replies inline.

On 11/28/2014 06:29 PM, Jelmer Vernooij wrote:
> Hi Petr,
>
> On Thu, Nov 27, 2014 at 03:47:30PM +0100, Petr Viktorin wrote:
[...]
>
>> I've asked about getting personal copyright assignment from Red Hat legal
>> (I'm new to that part, too). Hopefully that will get sorted out before
>> review is done. Please treat this patchset as a WIP for the time being.
> ack.

I've sent in the DCO; attaching new patches with the sign-off line.

[...]
>>  From 9908f55c38ac7e69c96d094065e3f312c963f293 Mon Sep 17 00:00:00 2001
>> From: Petr Viktorin <pviktori at redhat.com>
>> Date: Wed, 12 Nov 2014 16:53:33 +0100
>> Subject: [PATCH 1/4] buildtools: Honor LDVERSION when looking for Python
>>   library
>>

> ^^ Waf patches should go to waf upstream first. We can then update our copy of waf in Samba.

The patch was accepted to upstream waf's 1.5 branch 
(https://code.google.com/p/waf/issues/detail?id=1405).

Samba's copy has diverged though, there are BSD fixes upstream and a 
cross-compiling patch only in Samba.

>> Subject: [PATCH 2/4] buildtools: Use all of pyext_PATTERN in
>>   map_shlib_extension
> LGTM.

>> Subject: [PATCH 3/4] pytalloc: Port to Python 3
> LGTM.
>
>> diff --git a/lib/talloc/pytalloc.c b/lib/talloc/pytalloc.c
>> index 80196c6c77b58c395f5dde78e3d19f6d9de4c4a3..15fbcb08cb722357982a0d5c36d1918a43b4c2df 100644
>> --- a/lib/talloc/pytalloc.c
>> +++ b/lib/talloc/pytalloc.c
>> @@ -21,7 +21,10 @@
>>   #include <talloc.h>
>>   #include <pytalloc.h>
>>
>> -void inittalloc(void);
>> +/* Py_TYPE is defined in Python 2.6+, and becomes mandatory in Python 3 */
>> +#ifndef Py_TYPE
>> +#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
>> +#endif
> We can drop this I think, since we don't support Python < 2.6.

Dropped.

>> Subject: [PATCH 4/4] pytalloc: Build pytalloc.o as py3talloc.o under Python 3
> LGTM
>

>> diff --git a/lib/talloc/pytalloc_guide.txt b/lib/talloc/pytalloc_guide.txt
>> index 8abe1d4a1dca9f0e3d20002df7eeead7f6316afe..e79dd4db103ce29d9af6ef6d5211e80cf1665dfe 100644
>> --- a/lib/talloc/pytalloc_guide.txt
>> +++ b/lib/talloc/pytalloc_guide.txt
>> @@ -20,6 +20,13 @@ for objects that wrap talloc-maintained memory in C. It won't write your
>>   bindings for you but it will make it easier to write C bindings that involve
>>   talloc, and take away some of the boiler plate.
>>
>> +Python 3
>> +--------
>> +
>> +pytalloc can be used with Python 3. Usage from Python extension remains
>> +the same, but for the C utilities you will need to link against "py3talloc".
>> +To make a build for Python 3, configure with PYTHON=/usr/lib/python3.
> s,/usr/lib/python3,/usr/bin/python3/

Thanks for the catch!

>> diff --git a/lib/talloc/wscript b/lib/talloc/wscript
>> index 986492ccde8c7cdac830dc237893775a2682b2fd..57c0faae778c0427859668e3c5b478f62670af97 100644
>> --- a/lib/talloc/wscript
>> +++ b/lib/talloc/wscript
>> @@ -113,21 +113,25 @@ def build(bld):
>>                             manpages='man/talloc.3')
>>
>>       if not bld.CONFIG_SET('USING_SYSTEM_PYTALLOC_UTIL') and not bld.env.disable_python:
>> -        bld.SAMBA_LIBRARY('pytalloc-util',
>> +        if bld.env.PYTHON_VERSION >= '3':
> ^^ How hard would it be to build with all Python versions found rather than
> just the one that we found first? That would make preventing regressions with
> python3 a lot easier.

I'm afraid that would end up being a major refactoring in Waf – all the 
PYTHON* configuration in the build system assumes a single Python 
version for the entire build, so we'd have to add some way to have two 
parallel configurations for anything that touches Python.

If Samba ends up supporting both Python versions only for a short time, 
(except the small stand-alone libraries), then it definitely wouldn't be 
worth the effort. Otherwise, it probably also wouldn't, but I would look 
into it more in that case.

-- 
Petr³

-------------- next part --------------
A non-text attachment was scrubbed...
Name: v2-0001-buildtools-Honor-LDVERSION-when-looking-for-Pytho.patch
Type: text/x-patch
Size: 3024 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20141205/9813bbc9/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v2-0002-buildtools-Use-all-of-pyext_PATTERN-in-map_shlib_.patch
Type: text/x-patch
Size: 1281 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20141205/9813bbc9/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v2-0003-pytalloc-Port-to-Python-3.patch
Type: text/x-patch
Size: 6951 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20141205/9813bbc9/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v2-0004-pytalloc-Build-pytalloc.o-as-py3talloc.o-under-Py.patch
Type: text/x-patch
Size: 3856 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20141205/9813bbc9/attachment-0003.bin>


More information about the samba-technical mailing list