[bitbake-devel] [PATCH] Fix import spawn error on Python 3.6.5(Default Python version on Ubuntu 18.04 LTS). - Copy the find_executable() function from python3.5/distutils/spawn.py - npm.py do not need to import spawn

Paul Eggleton paul.eggleton at linux.intel.com
Mon May 21 04:13:48 UTC 2018


Hi there,

Thanks for the patch. A few comments:

1) All patches need to have Signed-off-by and a proper commit message. Please 
refer to: http://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines

2) We shouldn't be copying in functions verbatim from Python, that's 
potentially problematic for licensing reasons if nothing else.

3) I wonder, is this even necessary? It should be searching PATH already, thus 
we should be able to just put the name of the executable we want to run 
without needing to find the full path. Looking at the other fetcher modules we 
typically use "/usr/bin/env <command> <options>" so I think that should work 
here as well.

Cheers,
Paul

On Monday, 21 May 2018 2:51:52 AM NZST Tzu Hsiang Lin wrote:
> ---
>  lib/bb/fetch2/clearcase.py | 28 ++++++++++++++++++++++++++--
>  lib/bb/fetch2/npm.py       |  1 -
>  2 files changed, 26 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/bb/fetch2/clearcase.py b/lib/bb/fetch2/clearcase.py
> index 36beab6a..28589dbc 100644
> --- a/lib/bb/fetch2/clearcase.py
> +++ b/lib/bb/fetch2/clearcase.py
> @@ -69,7 +69,6 @@ from   bb.fetch2 import FetchMethod
>  from   bb.fetch2 import FetchError
>  from   bb.fetch2 import runfetchcmd
>  from   bb.fetch2 import logger
> -from   distutils import spawn
>  
>  class ClearCase(FetchMethod):
>      """Class to fetch urls via 'clearcase'"""
> @@ -107,7 +106,7 @@ class ClearCase(FetchMethod):
>          else:
>              ud.module = ""
>  
> -        ud.basecmd = d.getVar("FETCHCMD_ccrc") or 
spawn.find_executable("cleartool") or spawn.find_executable("rcleartool")
> +        ud.basecmd = d.getVar("FETCHCMD_ccrc") or 
_find_executable("cleartool") or _find_executable("rcleartool")
>  
>          if d.getVar("SRCREV") == "INVALID":
>            raise FetchError("Set a valid SRCREV for the clearcase fetcher in 
your recipe, e.g. SRCREV = \"/main/LATEST\" or any other label of your 
choice.")
> @@ -207,6 +206,31 @@ class ClearCase(FetchMethod):
>              output = runfetchcmd(cmd, d, workdir=ud.ccasedir)
>              logger.info("rmview output: %s", output)
>  
> +    def _find_executable(executable, path=None):
> +        """Tries to find 'executable' in the directories listed in 'path'.
> +
> +        A string listing directories separated by 'os.pathsep'; defaults to
> +        os.environ['PATH'].  Returns the complete filename or None if not 
found.
> +        """
> +        if path is None:
> +            path = os.environ['PATH']
> +
> +        paths = path.split(os.pathsep)
> +        base, ext = os.path.splitext(executable)
> +
> +        if (sys.platform == 'win32') and (ext != '.exe'):
> +            executable = executable + '.exe'
> +
> +        if not os.path.isfile(executable):
> +            for p in paths:
> +                f = os.path.join(p, executable)
> +                if os.path.isfile(f):
> +                    # the file exists, we have a shot at spawn working
> +                    return f
> +            return None
> +        else:
> +            return executable
> +
>      def need_update(self, ud, d):
>          if ("LATEST" in ud.label) or (ud.customspec and "LATEST" in 
ud.customspec):
>              ud.identifier += "-%s" % d.getVar("DATETIME",d, True)
> diff --git a/lib/bb/fetch2/npm.py b/lib/bb/fetch2/npm.py
> index 730c346a..408dfc3d 100644
> --- a/lib/bb/fetch2/npm.py
> +++ b/lib/bb/fetch2/npm.py
> @@ -32,7 +32,6 @@ from   bb.fetch2 import runfetchcmd
>  from   bb.fetch2 import logger
>  from   bb.fetch2 import UnpackError
>  from   bb.fetch2 import ParameterError
> -from   distutils import spawn
>  
>  def subprocess_setup():
>      # Python installs a SIGPIPE handler by default. This is usually not 
what
> 


-- 

Paul Eggleton
Intel Open Source Technology Centre





More information about the bitbake-devel mailing list