All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yann E. MORIN <yann.morin.1998@free.fr>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH v2 4/4] pycompile: add --verbose option
Date: Wed, 9 Sep 2020 22:47:26 +0200	[thread overview]
Message-ID: <20200909204726.GT14354@scaer> (raw)
In-Reply-To: <20200908081026.4701-5-robin.jarry@6wind.com>

Robin, All,

On 2020-09-08 10:10 +0200, Robin Jarry spake thusly:
> Add a new option that prints the (runtime) path of compiled .py files
> when VERBOSE=1 is set.

I said in my reply to the cover letter that I had something to say about
that patch, but in fact no; it's pretty OK.

Just do not forget to switch to using str.format() instead of using the
old-style % formatting. ;-)

Regards,
Yann E. MORIN.

> Signed-off-by: Robin Jarry <robin.jarry@6wind.com>
> ---
>  package/python/python.mk     |  1 +
>  package/python3/python3.mk   |  1 +
>  support/scripts/pycompile.py | 11 +++++++++--
>  3 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/package/python/python.mk b/package/python/python.mk
> index 7000658330e8..50e77db74628 100644
> --- a/package/python/python.mk
> +++ b/package/python/python.mk
> @@ -263,6 +263,7 @@ define PYTHON_CREATE_PYC_FILES
>  	$(HOST_DIR)/bin/python$(PYTHON_VERSION_MAJOR) \
>  		$(TOPDIR)/support/scripts/pycompile.py \
>  		$(if $(BR2_REPRODUCIBLE),--force) \
> +		$(if $(VERBOSE),--verbose) \
>  		$(TARGET_DIR) \
>  		$(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)
>  endef
> diff --git a/package/python3/python3.mk b/package/python3/python3.mk
> index e8c200b2081e..1ef757c6b66f 100644
> --- a/package/python3/python3.mk
> +++ b/package/python3/python3.mk
> @@ -280,6 +280,7 @@ define PYTHON3_CREATE_PYC_FILES
>  	$(HOST_DIR)/bin/python$(PYTHON3_VERSION_MAJOR) \
>  		$(TOPDIR)/support/scripts/pycompile.py \
>  		$(if $(BR2_REPRODUCIBLE),--force) \
> +		$(if $(VERBOSE),--verbose) \
>  		$(TARGET_DIR) \
>  		$(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)
>  endef
> diff --git a/support/scripts/pycompile.py b/support/scripts/pycompile.py
> index c60d4e13f3b4..cb2ba7f5016e 100644
> --- a/support/scripts/pycompile.py
> +++ b/support/scripts/pycompile.py
> @@ -16,7 +16,7 @@ import struct
>  import sys
>  
>  
> -def compile_one(host_path, target_root, force=False):
> +def compile_one(host_path, target_root, force=False, verbose=False):
>      """
>      Compile a .py file into a .pyc file located next to it.
>  
> @@ -26,6 +26,8 @@ def compile_one(host_path, target_root, force=False):
>          Absolute path of the target dir (i.e. the future /).
>      :arg force:
>          Recompile even if already up-to-date.
> +    :arg verbose:
> +        Print compiled file paths.
>      """
>      if os.path.islink(host_path):
>          return  # only compile real files
> @@ -49,6 +51,8 @@ def compile_one(host_path, target_root, force=False):
>      # determine the runtime path of the file (i.e.: relative path to target
>      # root dir prepended with "/").
>      runtime_path = os.path.join("/", os.path.relpath(host_path, target_root))
> +    if verbose:
> +        print("  PYC  %s" % (runtime_path,))
>  
>      # will raise an error if the file cannot be compiled
>      py_compile.compile(host_path, cfile=host_path + "c",
> @@ -63,6 +67,8 @@ def main():
>                          help="Folder located inside TARGET to scan and compile")
>      parser.add_argument("--force", action="store_true",
>                          help="Force compilation even if already compiled")
> +    parser.add_argument("--verbose", action="store_true",
> +                        help="Print compiled files")
>  
>      args = parser.parse_args()
>  
> @@ -83,7 +89,8 @@ def main():
>                  parser.error("PATH: not inside TARGET dir: %r" % d)
>              for parent, _, files in os.walk(d):
>                  for f in files:
> -                    compile_one(os.path.join(parent, f), args.target, args.force)
> +                    compile_one(os.path.join(parent, f), args.target,
> +                                args.force, args.verbose)
>  
>      except Exception as e:
>          print("error: %s" % e, file=sys.stderr)
> -- 
> 2.28.0
> 

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

  reply	other threads:[~2020-09-09 20:47 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-04 11:29 [Buildroot] [PATCH] pycompile: fix .pyc original source file paths Julien Floret
2020-09-04 21:26 ` Yann E. MORIN
2020-09-04 21:32   ` Yann E. MORIN
2020-09-08  8:10 ` [Buildroot] [PATCH v2 0/4] pycompile: fix .pyc source paths + improvements Robin Jarry
2020-09-08  8:10   ` [Buildroot] [PATCH v2 1/4] pycompile: add main entry point Robin Jarry
2020-09-08  8:10   ` [Buildroot] [PATCH v2 2/4] pycompile: sort imports Robin Jarry
2020-09-08  8:10   ` [Buildroot] [PATCH v2 3/4] pycompile: fix .pyc original source file paths Robin Jarry
2020-09-09 20:34     ` Yann E. MORIN
2020-09-10  7:29       ` Robin Jarry
2020-09-08  8:10   ` [Buildroot] [PATCH v2 4/4] pycompile: add --verbose option Robin Jarry
2020-09-09 20:47     ` Yann E. MORIN [this message]
2020-09-09 19:53   ` [Buildroot] [PATCH v2 0/4] pycompile: fix .pyc source paths + improvements Yann E. MORIN
2020-09-10  7:45 ` [Buildroot] [PATCH v3 0/2] " Robin Jarry
2020-09-10  7:45   ` [Buildroot] [PATCH v3 1/2] support/scripts/pycompile: fix .pyc original source file paths Robin Jarry
2020-09-10  7:53     ` Robin Jarry
2020-09-10  7:45   ` [Buildroot] [PATCH v3 2/2] support/scripts/pycompile: add --verbose option Robin Jarry
2020-09-10  8:32 ` [Buildroot] [PATCH v4 0/2] pycompile: fix .pyc source paths + improvements Robin Jarry
2020-09-10  8:32   ` [Buildroot] [PATCH v4 1/2] support/scripts/pycompile: fix .pyc original source file paths Robin Jarry
2020-09-11 21:15     ` Yann E. MORIN
2020-09-12 11:44       ` Robin Jarry
2020-09-13  8:10         ` Yann E. MORIN
2020-09-13  9:03     ` Yann E. MORIN
2020-09-14  7:33       ` Robin Jarry
2020-09-15 18:46     ` Peter Korsgaard
2020-09-10  8:32   ` [Buildroot] [PATCH v4 2/2] support/scripts/pycompile: add --verbose option Robin Jarry
2020-09-13  9:03     ` Yann E. MORIN

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=20200909204726.GT14354@scaer \
    --to=yann.morin.1998@free.fr \
    --cc=buildroot@busybox.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.