DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: Robin Jarry <robin.jarry@6wind.com>
Cc: Louise Kilheeney <louise.kilheeney@intel.com>,
	dev@dpdk.org, david.marchand@redhat.com
Subject: Re: [dpdk-dev] [PATCH 0/9] python2 deprecation notice
Date: Fri, 10 Jul 2020 15:47:33 +0100	[thread overview]
Message-ID: <20200710144733.GD684@bricha3-MOBL.ger.corp.intel.com> (raw)
In-Reply-To: <20200710133358.j535wy7onvelu3ln@6wind.com>

On Fri, Jul 10, 2020 at 03:33:58PM +0200, Robin Jarry wrote:
> Hi Louise,
> 
> 2020-07-10, Louise Kilheeney:
> > This patchset adds deprecation notices to python scripts,
> > warning of the removal of python2 support from the DPDK 20.11 release.
> 
> While showing warnings to users about Python 2 support drop in 20.11 is
> good, it seems like the shebangs in a lot of these scripts still refer
> to "python".
> 
> dpdk$ git describe 
> v20.05-623-geff30b59cc2e
> dpdk$ git grep '#.*!.*python\>'
> app/test-bbdev/test-bbdev.py:1:#!/usr/bin/env python
> app/test-cmdline/cmdline_test.py:1:#!/usr/bin/env python
> app/test/autotest.py:1:#!/usr/bin/env python
> buildtools/map_to_win.py:1:#!/usr/bin/env python
> config/arm/armv8_machine.py:1:#!/usr/bin/python
> devtools/update_version_map_abi.py:1:#!/usr/bin/env python
> usertools/cpu_layout.py:1:#!/usr/bin/env python
> usertools/dpdk-devbind.py:1:#! /usr/bin/env python
> usertools/dpdk-pmdinfo.py:1:#!/usr/bin/env python
> usertools/dpdk-telemetry-client.py:1:#! /usr/bin/env python
> 
> On many distros, "python" still points (as of today) to python2. You
> series will cause warnings that cannot be avoided.
> 
> Also, on some distros, "python" does not exist at all (RHEL 8 and CentOS
> 8 for example). And only "python2" or "python3" are available.
> 
> I wonder if it would not be better to find a way to make these shebangs
> "dynamic" somehow. It is not trivial and I don't see any other solution
> than plain modification of the shebangs at build time.
> 
> However, there is no way (to my knowledge) to specify which version of
> python is "selected" during the build.
> 
> Does anyone have a proper solution?
> 
That's a good point and I'm not sure there is a clean solution to it -
especially if there is no "python" without a 2 or 3 at the end?

Theoretically we could put something like this at the start of each script
to ensure it runs with python3 if available and "python" otherwise:

from __future__ import print_function
import sys
import os
import distutils.spawn

if sys.version_info.major < 3:
    py3 = distutils.spawn.find_executable("python3")
    if py3:
        print("Running", ' '.join([py3] + sys.argv))
        sys.exit(os.system(' '.join([py3] + sys.argv)))

print("Running", str(sys.argv), "with python version",\
    str(sys.version_info.major) + "." + str(sys.version_info.minor))

It doesn't solve the problem of those systems where /usr/bin/env python
returns nothing, but in those cases the script won't run at all, so the
user needs to explicitly call via python2/3 directly and the deprecation
notice is correct if they pick the wrong one. For most distros where
"python" alone does exist, the above code will work to prevent the
deprecation notice appearing except where the user does not have python3
available.

If we want to go with a build-time selection approach, we should just
change the defaults in all scripts to python3 and only change them back in
the Makefile build if python3 is not found. [Meson requires python3, so we
can ignore any checks there.]

Regards,
/Bruce

  reply	other threads:[~2020-07-10 14:48 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-10 10:10 Louise Kilheeney
2020-07-10 10:10 ` [dpdk-dev] [PATCH 1/9] usertools/cpu_layout: add " Louise Kilheeney
2020-07-10 10:10 ` [dpdk-dev] [PATCH 2/9] usertools/dpdk-telemetry-client: " Louise Kilheeney
2020-07-10 10:10 ` [dpdk-dev] [PATCH 3/9] usertools/dpdk-devbind: add " Louise Kilheeney
2020-07-10 10:10 ` [dpdk-dev] [PATCH 4/9] devtools/update_version_map: " Louise Kilheeney
2020-07-10 10:59   ` Neil Horman
2020-07-13  8:12   ` Kinsella, Ray
2020-07-10 10:10 ` [dpdk-dev] [PATCH 5/9] app/test-cmdline: " Louise Kilheeney
2020-07-10 10:10 ` [dpdk-dev] [PATCH 6/9] app/test: " Louise Kilheeney
2020-07-10 10:10 ` [dpdk-dev] [PATCH 7/9] usertools/dpdk-pmdinfo: " Louise Kilheeney
2020-07-10 11:00   ` Neil Horman
2020-07-10 10:10 ` [dpdk-dev] [PATCH 8/9] app/test-bbdev: python3 compatibility changes Louise Kilheeney
2020-07-10 10:10 ` [dpdk-dev] [PATCH 9/9] app/test-bbdev: add python2 deprecation notice Louise Kilheeney
2020-07-10 15:53   ` Chautru, Nicolas
2020-07-10 10:30 ` [dpdk-dev] [PATCH 0/9] " Bruce Richardson
2020-07-10 13:33 ` Robin Jarry
2020-07-10 14:47   ` Bruce Richardson [this message]
2020-07-13  9:21   ` Bruce Richardson
2020-07-14  1:19     ` Stephen Hemminger
2020-07-15  7:01     ` Robin Jarry
2020-07-16 14:44     ` Robin Jarry
2020-07-16 21:01       ` Stephen Hemminger
2020-07-17 12:42         ` Bruce Richardson
2020-07-17 15:06           ` Stephen Hemminger
2020-07-17 16:24             ` Bruce Richardson
2020-07-21 20:25               ` Thomas Monjalon
2020-07-21 20:56                 ` David Marchand
2020-07-21 21:05 ` David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200710144733.GD684@bricha3-MOBL.ger.corp.intel.com \
    --to=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=louise.kilheeney@intel.com \
    --cc=robin.jarry@6wind.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).