From c89f2a8172afc1b2f394ae6c95cdf193c5703cc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20BRIDAY?= Date: Wed, 31 Jan 2024 17:43:03 +0100 Subject: [PATCH] =?UTF-8?q?update=20build=20scripts:=20PEP=20632=20?= =?UTF-8?q?=E2=80=93=20Deprecate=20distutils=20module?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- goil/templates/build/build_py.goilTemplate | 4 ++-- goil/templates/build/make_py.goilTemplate | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/goil/templates/build/build_py.goilTemplate b/goil/templates/build/build_py.goilTemplate index 8380b279a..107bdb390 100755 --- a/goil/templates/build/build_py.goilTemplate +++ b/goil/templates/build/build_py.goilTemplate @@ -42,7 +42,7 @@ if exists POSTBUILD then let postgoals := mapof exists POSTBUILD default ( @() ) by NAME end if -%#! /usr/bin/env python +%#! /usr/bin/env python3 # -*- coding: UTF-8 -*- #---------------------------------------------------------------------- #--- Python Build file for application % !CPUNAME % @@ -61,7 +61,7 @@ end if #--- build.py is generated each time goil is called by make.py #---------------------------------------------------------------------- -import sys, os, subprocess, string, distutils.spawn +import sys, os, subprocess, string from string import Template #--- Add some function for Python3 support diff --git a/goil/templates/build/make_py.goilTemplate b/goil/templates/build/make_py.goilTemplate index 5f15d4713..5529f9000 100755 --- a/goil/templates/build/make_py.goilTemplate +++ b/goil/templates/build/make_py.goilTemplate @@ -41,7 +41,7 @@ foreach pb in exists POSTBUILD default( @() ) do end foreach end foreach -%#! /usr/bin/env python +%#! /usr/bin/env python3 # -*- coding: UTF-8 -*- #---------------------------------------------------------------------- #--- Python Make file for application % !CPUNAME % @@ -179,11 +179,11 @@ os.chdir (scriptDir) #--- Launch build.py # is there the 'python' executable? -import distutils.spawn -if distutils.spawn.find_executable("python"): - childProcess = subprocess.Popen (["python", "build.py", askedGoal, str(maxParallelJobs)]) -else: #no python executable, maybe python3 - childProcess = subprocess.Popen (["python3", "build.py", askedGoal, str(maxParallelJobs)]) +import shutil +cmd = shutil.which('python') +if not cmd: + cmd = shutil.which('python3') +childProcess = subprocess.Popen ([cmd, "build.py", askedGoal, str(maxParallelJobs)]) #--- Wait for subprocess termination if childProcess.poll () == None :