Re: 2to3 adds '.' in front dir of "from dir import ..." statements (Was: [MoM] lefse migration to python 3])

2019-09-13 Thread Thomas Goirand
On 9/12/19 9:22 AM, Michael Kesper wrote:
> Hi all,
> 
> On 12.09.19 08:30, Thomas Goirand wrote:
>> I wont comment on the relative import ambiguity problem, as Ghislain
>> replied correctly. However, I do want to comment on 2to3.
>>
>> I generally recommend against using it, in the favor of other tools. 
> ...
>>
>> The advantage is that you'll get a source code that will work on both
>> Python 2 and 3. It's generally a way more easy to submit upstream, which
>> may not want to loose Python 2 compatibility.
> 
> We should stop caring about that.
> Python2 will be EOL'ed at January 1, 2020 [0].
> Python2 will vanish from next Debian release.
> Please convert into idiomatic Python3 code, that's the sane way going forward.

As much as WE are concerned, probably. However, there's still multiple
cases where you still care having compat with both versions of Python.
First, the case where upstream does care about Py2. You probably wont
succeed convincing them it is too late and they should stop caring.
There's also the case where, as a package maintainer, you see a Python
package that currently has only Py2 support. In some case, you need to
first introduce Python 3 compat without breaking Python 2 support, so
you that way get enough time to fix the reverse dependencies.

I am not buying into the argument that adding a dependency on six.py is
a problem. It generally isn't. If upstream cares about dependency-less
stuff, then probably you should ignore upstream and do the work in
Debian alone, until upstream fixes his code to do Python 3 only.

Cheers,

Thomas Goirand (zigo)



Re: 2to3 adds '.' in front dir of "from dir import ..." statements (Was: [MoM] lefse migration to python 3])

2019-09-12 Thread Andrey Rahmatullin
On Thu, Sep 12, 2019 at 08:30:20AM +0200, Thomas Goirand wrote:
> I wont comment on the relative import ambiguity problem, as Ghislain
> replied correctly. However, I do want to comment on 2to3.
> 
> I generally recommend against using it, in the favor of other tools. For
> example, you can use sixer, which I maintain in Debian, and often used
> (and abused) to do Python 3 conversions. There's also 2to6, which I
> don't know much about, but I've read it works about the same way as
> sixer (which was specifically written for OpenStack).
> 
> The advantage is that you'll get a source code that will work on both
> Python 2 and 3. It's generally a way more easy to submit upstream, which
> may not want to loose Python 2 compatibility.
I can add to this that it's non-trivial to convert from six to normal Py3
code, unless there are some tools that I didn't find. And it's really time
to do that, not to convert TO six.

-- 
WBR, wRAR


signature.asc
Description: PGP signature


Re: 2to3 adds '.' in front dir of "from dir import ..." statements (Was: [MoM] lefse migration to python 3])

2019-09-12 Thread Andreas Tille
Hi Michael,

On Thu, Sep 12, 2019 at 09:22:06AM +0200, Michael Kesper wrote:
> On 12.09.19 08:30, Thomas Goirand wrote:
> > I wont comment on the relative import ambiguity problem, as Ghislain
> > replied correctly. However, I do want to comment on 2to3.
> > 
> > I generally recommend against using it, in the favor of other tools. 
> ...
> > 
> > The advantage is that you'll get a source code that will work on both
> > Python 2 and 3. It's generally a way more easy to submit upstream, which
> > may not want to loose Python 2 compatibility.
> 
> We should stop caring about that.
> Python2 will be EOL'ed at January 1, 2020 [0].
> Python2 will vanish from next Debian release.
> Please convert into idiomatic Python3 code, that's the sane way going forward.

I agree here.  @Thomas:  We talked about sixer at DebConf (thanks for
the hint in any case).  But I consider the additional dependency it
introduces something I'd like to avoid if possible.  So I first try my
luck with 2to3 (and I admit I observed some surprises which did not made
me that lucky at all) before I'd use sixer as fallback.

Kind regards

   Andreas.

-- 
http://fam-tille.de



Re: 2to3 adds '.' in front dir of "from dir import ..." statements (Was: [MoM] lefse migration to python 3])

2019-09-12 Thread Michael Kesper
Hi all,

On 12.09.19 08:30, Thomas Goirand wrote:
> I wont comment on the relative import ambiguity problem, as Ghislain
> replied correctly. However, I do want to comment on 2to3.
> 
> I generally recommend against using it, in the favor of other tools. 
...
> 
> The advantage is that you'll get a source code that will work on both
> Python 2 and 3. It's generally a way more easy to submit upstream, which
> may not want to loose Python 2 compatibility.

We should stop caring about that.
Python2 will be EOL'ed at January 1, 2020 [0].
Python2 will vanish from next Debian release.
Please convert into idiomatic Python3 code, that's the sane way going forward.

Best regards
Michael

[0] https://github.com/python/devguide/pull/344
https://pythonclock.org/



signature.asc
Description: OpenPGP digital signature


Re: 2to3 adds '.' in front dir of "from dir import ..." statements (Was: [MoM] lefse migration to python 3])

2019-09-12 Thread Thomas Goirand
On 9/10/19 7:50 AM, Andreas Tille wrote:
> Hi,
> 
> in the process of the Python3 migration the package lefse was converted
> using 2to3.

Hi Andreas,

I wont comment on the relative import ambiguity problem, as Ghislain
replied correctly. However, I do want to comment on 2to3.

I generally recommend against using it, in the favor of other tools. For
example, you can use sixer, which I maintain in Debian, and often used
(and abused) to do Python 3 conversions. There's also 2to6, which I
don't know much about, but I've read it works about the same way as
sixer (which was specifically written for OpenStack).

The advantage is that you'll get a source code that will work on both
Python 2 and 3. It's generally a way more easy to submit upstream, which
may not want to loose Python 2 compatibility.

Cheers,

Thomas Goirand (zigo)



Re: 2to3 adds '.' in front dir of "from dir import ..." statements (Was: [MoM] lefse migration to python 3])

2019-09-12 Thread Thomas Goirand
On 9/10/19 7:50 AM, Andreas Tille wrote:
> Hi,
> 
> in the process of the Python3 migration the package lefse was converted
> using 2to3.

Hi Andreas,

I wont comment on the relative import ambiguity problem, as Ghislain
replied correctly. However, I do want to comment on 2to3.

I generally recommend against using it, in the favor of other tools. For
example, you can use sixer, which I maintain in Debian, and often used
(and abused) to do Python 3 conversions. There's also 2to6, which I
don't know much about, but I've read it works about the same way as
sixer (which was specifically written for OpenStack).

The advantage is that you'll get a source code that will work on both
Python 2 and 3. It's generally a way more easy to submit upstream, which
may not want to loose Python 2 compatibility.

Cheers,

Thomas Goirand (zigo)



Re: 2to3 adds '.' in front dir of "from dir import ..." statements (Was: [MoM] lefse migration to python 3])

2019-09-10 Thread Ghislain Vaillant
It results from the ambiguity between absolute and relative imports in
Python 2.

Here 2to3 considers your imports being relative, hence the added dot. I
believe no dots would be added should a `from __future__ import
absolute_import` be found in the preamble of the module.

Hope this helps.

Ghis

Le mar. 10 sept. 2019 à 07:51, Andreas Tille  a écrit :

> Hi,
>
> in the process of the Python3 migration the package lefse was converted
> using 2to3.  The changes can be found in git[1].  I'm wondering about
> the following diff created by 2to3:
>
>   - from lefse import *
>   + from .lefse import *
>
> When calling a random binary of the resulting binary package lefse I
> experienced:
>
> $ plot_features
> Traceback (most recent call last):
>   File "/usr/bin/plot_features", line 6, in 
> from .lefse import *
> ModuleNotFoundError: No module named '__main__.lefse'; '__main__' is not a
> package
>
>
> I think the line
>
>from lefse import *
>
> should remain to keep that script functional.  I now checked another
> package (cain - nothing pushed yet) and here also 2to3 is changing
>
>from something import *
>
> to
>
>from .something import *
>
> Could somebody please enlighten me about this added '.' which does not
> seem to work?
>
> Kind regards
>
>   Andreas.
>
> [1] https://salsa.debian.org/med-team/lefse
>
> --
> http://fam-tille.de
>
>