Skip to content

Commit

Permalink
Use a feature flag instead of a an argument for content hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
elthariel committed Apr 7, 2023
1 parent d92886c commit 47e163d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
5 changes: 3 additions & 2 deletions .plzconfig
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,6 @@ DefaultValue = //tools:wheel_resolver
Optional = true
Inherit = true

[featureflags]
PythonWheelHashing = true
[PluginConfig "feature_flags"]
WheelHashing = true
ContentHashing = false
11 changes: 5 additions & 6 deletions build_defs/python.build_defs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"

Expand All @@ -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"'
Expand Down

0 comments on commit 47e163d

Please sign in to comment.