[ovs-dev] [PATCH] python: Fixup python shebangs to python3

Ilya Maximets i.maximets at ovn.org
Tue Aug 18 20:10:35 UTC 2020


On 8/18/20 9:17 PM, Gregory Rose wrote:
> 
> On 8/18/2020 11:31 AM, Ilya Maximets wrote:
>> On 8/18/20 6:45 PM, Greg Rose wrote:
>>> Builds on RHEL 8.2 systems are failing due to this issue.
>>>
>>> See [1] as to why this is necessary.
>>>
>>> I used the following command to identify files that need this fix:
>>> find . -type f -executable | /usr/lib/rpm/redhat/brp-mangle-shebangs
>>>
>>> I also updated the copyright notices as needed.
>>>
>>> 1. https://fedoraproject.org/wiki/Changes/Make_ambiguous_python_shebangs_error
>>>
>>> Signed-off-by: Greg Rose <gvrose8192 at gmail.com>
>>> ---
>>>   ipsec/ovs-monitor-ipsec.in                            |  4 ++--
>>>   ofproto/ipfix-gen-entities                            |  4 ++--
>>>   ovsdb/dot2pic                                         |  4 ++--
>>>   ovsdb/ovsdb-doc                                       |  4 ++--
>>>   ovsdb/ovsdb-dot.in                                    |  2 +-
>>>   ovsdb/ovsdb-idlc.in                                   |  2 +-
>>>   python/build/soutil.py                                |  4 ++--
>>>   tests/ovsdb-monitor-sort.py                           | 16 ++++++++++++++--
>>>   tests/sendpkt.py                                      |  4 ++--
>>>   tests/test-l7.py                                      |  4 ++--
>>>   tests/uuidfilt.py                                     | 18 +++++++++++++++++-
>>>   utilities/bugtool/ovs-bugtool.in                      |  4 ++--
>>>   utilities/ovs-check-dead-ifs.in                       |  2 +-
>>>   utilities/ovs-dev.py                                  |  4 ++--
>>>   utilities/ovs-dpctl-top.in                            |  4 ++--
>>>   utilities/ovs-l3ping.in                               |  2 +-
>>>   utilities/ovs-parse-backtrace.in                      |  4 ++--
>>>   utilities/ovs-pcap.in                                 |  4 ++--
>>>   utilities/ovs-pipegen.py                              |  4 ++--
>>>   utilities/ovs-tcpdump.in                              |  2 +-
>>>   utilities/ovs-tcpundump.in                            |  4 ++--
>>>   utilities/ovs-test.in                                 |  2 +-
>>>   utilities/ovs-vlan-test.in                            |  4 ++--
>>>   vtep/ovs-vtep.in                                      |  4 ++--
>>>   xenserver/etc_xapi.d_plugins_openvswitch-cfg-update   |  4 ++--
>>>   xenserver/opt_xensource_libexec_interface-reconfigure |  2 +-
>>>   xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync |  4 ++--
>>>   27 files changed, 74 insertions(+), 46 deletions(-)
>>>
>>> diff --git a/ipsec/ovs-monitor-ipsec.in b/ipsec/ovs-monitor-ipsec.in
>>> index 37e3703..32e8e90 100755
>>> --- a/ipsec/ovs-monitor-ipsec.in
>>> +++ b/ipsec/ovs-monitor-ipsec.in
>>> @@ -1,5 +1,5 @@
>>> -#! @PYTHON3@
>>> -# Copyright (c) 2017 Nicira, Inc.
>>> +#!/usr/bin/env python3
>>> +# Copyright (c) 2017, 2020 Nicira, Inc.
>>>   #
>>>   # Licensed under the Apache License, Version 2.0 (the "License");
>>>   # you may not use this file except in compliance with the License.
>>> diff --git a/ofproto/ipfix-gen-entities b/ofproto/ipfix-gen-entities
>>> index 0be7199..d5abe9c 100755
>>> --- a/ofproto/ipfix-gen-entities
>>> +++ b/ofproto/ipfix-gen-entities
>>> @@ -1,6 +1,6 @@
>>> -#! /usr/bin/env python
>>> +#!/usr/bin/env python3
>>>   #
>>> -# Copyright (C) 2012 Nicira, Inc.
>>> +# Copyright (C) 2012, 2020 Nicira, Inc.
>>>   #
>>>   # Copying and distribution of this file, with or without modification,
>>>   # are permitted in any medium without royalty provided the copyright
>>> diff --git a/ovsdb/dot2pic b/ovsdb/dot2pic
>>> index de67261..2f858e1 100755
>>> --- a/ovsdb/dot2pic
>>> +++ b/ovsdb/dot2pic
>>> @@ -1,6 +1,6 @@
>>> -#! /usr/bin/env python
>>> +#!/usr/bin/env python3
>>>   -# Copyright (c) 2009, 2010, 2011, 2013, 2017 Nicira, Inc.
>>> +# Copyright (c) 2009, 2010, 2011, 2013, 2017, 2020 Nicira, Inc.
>>>   #
>>>   # Licensed under the Apache License, Version 2.0 (the "License");
>>>   # you may not use this file except in compliance with the License.
>>> diff --git a/ovsdb/ovsdb-doc b/ovsdb/ovsdb-doc
>>> index 406c293..10d0c0c 100755
>>> --- a/ovsdb/ovsdb-doc
>>> +++ b/ovsdb/ovsdb-doc
>>> @@ -1,6 +1,6 @@
>>> -#! /usr/bin/python
>>> +#!/usr/bin/python3
>>>   -# Copyright (c) 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
>>> +# Copyright (c) 2010, 2011, 2012, 2013, 2014, 2015, 2020 Nicira, Inc.
>>>   #
>>>   # Licensed under the Apache License, Version 2.0 (the "License");
>>>   # you may not use this file except in compliance with the License.
>>> diff --git a/ovsdb/ovsdb-dot.in b/ovsdb/ovsdb-dot.in
>>> index 41b986c..571601e 100755
>>> --- a/ovsdb/ovsdb-dot.in
>>> +++ b/ovsdb/ovsdb-dot.in
>>> @@ -1,4 +1,4 @@
>>> -#! @PYTHON3@
>>> +#!/usr/bin/env python3
>>
>> Hmm.  This doesn't look right.
>>
>> All the *.in files are used to generate actual scripts out of them
>> and '@PYTHON3@' is a placeholder for an actual python3 binary location
>> determind at the ./configure stage.  So, I don't think that we should
>> replace them.
>>
>> Best regards, Ilya Maximets.
>>
> 
> Hi Ilya,
> 
> Thanks for the review.
> 
> The shebang check occurs before the expansion of @PYTHON3@ and causes
> build failures.

This is strange.  I just tried to build rpms on rhel 8.2 and on fedora 31.
On both systems shebang check was triggered after the actual build and
only on resulted executable files (without .in).  I think, something
goes terribly wrong if shebang check invoked before the build and on
files that should not be part of a binary distribution.

Could you provide more information on how to reproduce?

> We have no control over when the shebang check runs
> because it is part of the RPM build environment supplied by Red Hat.
> Moreover, the shebang check also substitutes #!/usr/bin/env python3
> with someting like '/usr/libexec/platform-python'.

I see messages like this:
mangling shebang in /usr/bin/ovs-pcap from /usr/bin/python3 to #!/usr/libexec/platform-python

But these are not errors nor even warnings, so should not affect the build.
In fact /usr/bin/python3 is a symlink to /usr/libexec/platform-python.

> 
> If we are only supporting python 3 then I think it's OK to explictly
> say so.  And if we don't do something to fix it then it won't be long
> before builds are failing on Fedora and RHEL systems.

User might specify different versions of python3 if one of them is more
preferred, i.e. you could explicitly set PYTHON3=/usr/bin/python3.6
for ./configure script while having python3.8 by default in a system.

> 
> Do you have any alternative suggestions?  Also, what do you think the problems will be if we use this patch?  It's quite possible I'm missing
> something.
> 
> Thanks,
> 
> - Greg



More information about the dev mailing list