From 47e163d17a8346ffb830c1aa1bf99c32def475c9 Mon Sep 17 00:00:00 2001 From: Julien 'Lta' BALLET Date: Fri, 7 Apr 2023 10:57:23 +0200 Subject: [PATCH] Use a feature flag instead of a an argument for content hashing --- .plzconfig | 5 +++-- build_defs/python.build_defs | 11 +++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.plzconfig b/.plzconfig index aab20ce3..7151b800 100644 --- a/.plzconfig +++ b/.plzconfig @@ -105,5 +105,6 @@ DefaultValue = //tools:wheel_resolver Optional = true Inherit = true -[featureflags] -PythonWheelHashing = true +[PluginConfig "feature_flags"] +WheelHashing = true +ContentHashing = false diff --git a/build_defs/python.build_defs b/build_defs/python.build_defs index 182ebc67..3d7bf8c1 100644 --- a/build_defs/python.build_defs +++ b/build_defs/python.build_defs @@ -95,7 +95,7 @@ def python_library(name:str, srcs:list=[], resources:list=[], deps:list=[], visi def python_binary(name:str, main:str, srcs:list=[], resources:list=[], out:str=None, deps:list=[], data:list=None, visibility:list=None, test_only:bool=False, zip_safe:bool=None, site:bool=False, strip:bool=False, interpreter:str=CONFIG.PYTHON.DEFAULT_INTERPRETER, - shebang:str='', labels:list&features&tags=[], content_stamp:bool=False): + shebang:str='', labels:list&features&tags=[]): """Generates a Python binary target. This compiles all source files together into a single .pex file which can @@ -128,8 +128,6 @@ def python_binary(name:str, main:str, srcs:list=[], resources:list=[], out:str=N shebang (str): Exact shebang to apply to the generated file. By default we will determine something appropriate for the given interpreter. labels (list): Labels to apply to this rule. - content_stamp(bool): Use the built content as the pex_stamp source to build the extract - path for non-zip-safe path instead of the rule hash. Default to False """ assert main not in srcs, "main file should not be included in srcs" @@ -149,9 +147,10 @@ def python_binary(name:str, main:str, srcs:list=[], resources:list=[], out:str=N cmd = '$TOOLS_PEX -s "%s" -m "%s" %s --interpreter_options="%s"' % ( shebang, CONFIG.PYTHON.MODULE_DIR, zipsafe_flag, CONFIG.PYTHON.INTERPRETER_OPTIONS) - # If content stamp is given, we use the hash of the built dependencies instead - # of the RULE_HASH as the base of the pex extraction folder - if content_stamp: + # If content hashing feature flag is enabled, we use the hash of the built + # dependencies instead of the RULE_HASH as the base of the pex extraction + # folder + if "content_hashing" in CONFIG.PYTHON.FEATURE_FLAGS: cmd += f' --stamp="$(hash :{lib_rule_name})"' else: cmd += ' --stamp="$RULE_HASH"'