1# Only used for PyTorch open source BUCK build 2 3IGNORED_ATTRIBUTE_PREFIX = [ 4 "apple", 5 "fbobjc", 6 "windows", 7 "fbandroid", 8 "macosx", 9] 10 11IGNORED_ATTRIBUTES = [ 12 "feature", 13 "platforms", 14 "contacts", 15] 16 17# TODO (huydhn): PyTorch OSS is still built with old buck not buck2, and there 18# aren't available options https://buck.build/rule/cxx_library.html. This can 19# be removed when we migrate OSS to buck2 20ONLY_AVAILABLE_IN_BUCK2 = [ 21 "supports_shlib_interfaces", 22] 23 24def filter_attributes(kwgs): 25 keys = list(kwgs.keys()) 26 27 # drop unncessary attributes 28 for key in keys: 29 if key in IGNORED_ATTRIBUTES or key in ONLY_AVAILABLE_IN_BUCK2: 30 kwgs.pop(key) 31 else: 32 for invalid_prefix in IGNORED_ATTRIBUTE_PREFIX: 33 if key.startswith(invalid_prefix): 34 kwgs.pop(key) 35 return kwgs 36