@@ -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) \
--strip-root $(TARGET_DIR) \
$(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)
endef
@@ -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) \
--strip-root $(TARGET_DIR) \
$(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)
endef
@@ -17,7 +17,7 @@ import struct
import sys
-def compile_one(host_path, strip_root=None, force=False):
+def compile_one(host_path, strip_root=None, force=False, verbose=False):
"""
Compile a .py file into a .pyc file located next to it.
@@ -28,6 +28,8 @@ def compile_one(host_path, strip_root=None, force=False):
files.
:arg force:
Recompile even if already up-to-date.
+ :arg verbose:
+ Print compiled file paths.
"""
if os.path.islink(host_path) or not os.path.isfile(host_path):
return # only compile real files
@@ -55,6 +57,9 @@ def compile_one(host_path, strip_root=None, force=False):
else:
runtime_path = host_path
+ if verbose:
+ print(" PYC {}".format(runtime_path))
+
# will raise an error if the file cannot be compiled
py_compile.compile(host_path, cfile=host_path + "c",
dfile=runtime_path, doraise=True)
@@ -81,6 +86,8 @@ def main():
""")
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()
@@ -91,7 +98,7 @@ def main():
for parent, _, files in os.walk(d):
for f in files:
compile_one(os.path.join(parent, f), args.strip_root,
- args.force)
+ args.force, args.verbose)
except Exception as e:
print("error: {}".format(e))
Add a new option that prints the (runtime) path of compiled .py files when VERBOSE=1 is set. 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(-)