From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A0607A052A; Fri, 10 Jul 2020 16:48:21 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 87EF11DE6B; Fri, 10 Jul 2020 16:47:41 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id C70571DE6B for ; Fri, 10 Jul 2020 16:47:39 +0200 (CEST) IronPort-SDR: ilSHuwAQ8xDrDciXBPO/3lOBLAFrn0lkLYp/x+U30sSmqn8uPvK6l6wr/tz8jeuJ5tfmjbQrRp HmVdgjR0Zt2Q== X-IronPort-AV: E=McAfee;i="6000,8403,9678"; a="149676946" X-IronPort-AV: E=Sophos;i="5.75,336,1589266800"; d="scan'208";a="149676946" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jul 2020 07:47:38 -0700 IronPort-SDR: JX4yJdHI8bdI4HNMj7hcx1AUm+14GBJILM7sTH6YL1es8GXMynRdGK4l5y99w8WhNgN3XMh+I9 DHdmbShMeLXA== X-IronPort-AV: E=Sophos;i="5.75,336,1589266800"; d="scan'208";a="458302079" Received: from bricha3-mobl.ger.corp.intel.com ([10.249.32.166]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 10 Jul 2020 07:47:37 -0700 Date: Fri, 10 Jul 2020 15:47:33 +0100 From: Bruce Richardson To: Robin Jarry Cc: Louise Kilheeney , dev@dpdk.org, david.marchand@redhat.com Message-ID: <20200710144733.GD684@bricha3-MOBL.ger.corp.intel.com> References: <20200710101055.33671-1-louise.kilheeney@intel.com> <20200710133358.j535wy7onvelu3ln@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200710133358.j535wy7onvelu3ln@6wind.com> Subject: Re: [dpdk-dev] [PATCH 0/9] python2 deprecation notice X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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