Patchwork setup: fix a possible NameError on rust build

login
register
mail settings
Submitter Philippe Pepiot
Date April 4, 2019, 1:43 p.m.
Message ID <f7c8453060138de8ab1f.1554385424@euler.in.philpep.org>
Download mbox | patch
Permalink /patch/39475/
State Accepted
Headers show

Comments

Philippe Pepiot - April 4, 2019, 1:43 p.m.
# HG changeset patch
# User Philippe Pepiot <philippe.pepiot@logilab.fr>
# Date 1554385248 -7200
#      Thu Apr 04 15:40:48 2019 +0200
# Node ID f7c8453060138de8ab1f56b760d84157d3f0a064
# Parent  4ee906aa7b60fb6b113e4dc187fbb5a8f42e557c
setup: fix a possible NameError on rust build

  File "setup.py", line 975, in rustbuild
    "command: %r, environment: %r" % (self.rustsrcdir, cmd, env))
NameError: global name 'cmd' is not defined
Georges Racinet - April 4, 2019, 2:24 p.m.
On 4/4/19 3:43 PM, Philippe Pepiot wrote:
> # HG changeset patch
> # User Philippe Pepiot <philippe.pepiot@logilab.fr>
> # Date 1554385248 -7200
> #      Thu Apr 04 15:40:48 2019 +0200
> # Node ID f7c8453060138de8ab1f56b760d84157d3f0a064
> # Parent  4ee906aa7b60fb6b113e4dc187fbb5a8f42e557c
> setup: fix a possible NameError on rust build
>
>   File "setup.py", line 975, in rustbuild
>     "command: %r, environment: %r" % (self.rustsrcdir, cmd, env))
> NameError: global name 'cmd' is not defined
>
> diff --git a/setup.py b/setup.py
> --- a/setup.py
> +++ b/setup.py
> @@ -1084,7 +1084,7 @@ class RustExtension(Extension):
>          except subprocess.CalledProcessError:
>              raise RustCompilationError(
>                  "Cargo failed. Working directory: %r, "
> -                "command: %r, environment: %r" % (self.rustsrcdir, cmd, env))
> +                "command: %r, environment: %r" % (self.rustsrcdir, cargocmd, env))

Ah yes, indeed that seems right, thanks.

As a side note, I can't get pyflakes (flake8) not pylint to catch this,
even if running explicitely on setup.py; this is a bit puzzling.
Augie Fackler - April 5, 2019, 5:54 p.m.
queued, thanks

> On Apr 4, 2019, at 10:24, Georges Racinet <georges.racinet@octobus.net> wrote:
> 
> 
> On 4/4/19 3:43 PM, Philippe Pepiot wrote:
>> # HG changeset patch
>> # User Philippe Pepiot <philippe.pepiot@logilab.fr>
>> # Date 1554385248 -7200
>> #      Thu Apr 04 15:40:48 2019 +0200
>> # Node ID f7c8453060138de8ab1f56b760d84157d3f0a064
>> # Parent  4ee906aa7b60fb6b113e4dc187fbb5a8f42e557c
>> setup: fix a possible NameError on rust build
>> 
>>  File "setup.py", line 975, in rustbuild
>>    "command: %r, environment: %r" % (self.rustsrcdir, cmd, env))
>> NameError: global name 'cmd' is not defined
>> 
>> diff --git a/setup.py b/setup.py
>> --- a/setup.py
>> +++ b/setup.py
>> @@ -1084,7 +1084,7 @@ class RustExtension(Extension):
>>         except subprocess.CalledProcessError:
>>             raise RustCompilationError(
>>                 "Cargo failed. Working directory: %r, "
>> -                "command: %r, environment: %r" % (self.rustsrcdir, cmd, env))
>> +                "command: %r, environment: %r" % (self.rustsrcdir, cargocmd, env))
> 
> Ah yes, indeed that seems right, thanks.
> 
> As a side note, I can't get pyflakes (flake8) not pylint to catch this,
> even if running explicitely on setup.py; this is a bit puzzling.
> 
> -- 
> Georges Racinet
> https://octobus.net
> GPG: BF5456F4DC625443849B6E58EE20CA44EF691D39, sur serveurs publics
> 
> 
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -1084,7 +1084,7 @@  class RustExtension(Extension):
         except subprocess.CalledProcessError:
             raise RustCompilationError(
                 "Cargo failed. Working directory: %r, "
-                "command: %r, environment: %r" % (self.rustsrcdir, cmd, env))
+                "command: %r, environment: %r" % (self.rustsrcdir, cargocmd, env))
 
 class RustEnhancedExtension(RustExtension):
     """A C Extension, conditionally enhanced with Rust code.