From 8c2b2412da8cca663203e51d59d62a8588192765 Mon Sep 17 00:00:00 2001 From: Stephanie Ding Date: Tue, 21 Dec 2021 09:25:42 -0800 Subject: [PATCH] Preserve `taint/` subdirectory structure when building `pyre-check` wheel Summary: Our open source builds have been broken for a long time, because the taint.config in the `taint` data folder shipped with our wheel has just been empty. It seems like the root cause was that all of our taint from various folders such as `taint/core_privacy_security`, `taint/common` was being copied into the wheel under `pyre_check/taint` rather than keeping the subdirectory structure, meaning that the empty taint.config under `common/` is being written to the `pyre_check/taint` folder in the wheel, overwriting the `core_privacy_security/taint.config` file at times, because files from both subfolders are being copied to the same destination location in the wheel. Since we need to release a new open source package due to recent GitHub issues asking about features we have long implemented (but have not pushed out), let's fix the script so we can make non-broken builds again. Reviewed By: 0xedward Differential Revision: D33247107 fbshipit-source-id: 67288937d4e640092c9b650af9f77184a08d5f27 --- scripts/pypi/setup.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/scripts/pypi/setup.py b/scripts/pypi/setup.py index e9db4fdf675..492ad7c3033 100644 --- a/scripts/pypi/setup.py +++ b/scripts/pypi/setup.py @@ -45,15 +45,27 @@ def find_taint_stubs() -> List[Tuple[str, List[str]]]: taint_stubs = [] for path in Path(os.path.join(os.getcwd(), "taint")).iterdir(): if path.is_dir(): - _, temporary_stubs = get_data_files(directory=str(path), extension_glob="*") - taint_stubs += temporary_stubs - _, third_party_taint_stubs = get_data_files( + relative_directory, temporary_stubs = get_data_files( + directory=str(path), extension_glob="*" + ) + if temporary_stubs: + taint_stubs.append( + ( + os.path.join("lib", "pyre_check", relative_directory), + temporary_stubs, + ) + ) + relative_directory, third_party_taint_stubs = get_data_files( directory=os.path.join(os.getcwd(), "third_party_taint"), extension_glob="*" ) - taint_stubs += third_party_taint_stubs - if not taint_stubs: - return [] - return [(os.path.join("lib", "pyre_check", "taint"), taint_stubs)] + if third_party_taint_stubs: + taint_stubs.append( + ( + os.path.join("lib", "pyre_check", relative_directory), + third_party_taint_stubs, + ) + ) + return taint_stubs def run(