-
Notifications
You must be signed in to change notification settings - Fork 554
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gazelle): Remove integrity field from Gazelle manifest (#1666)
As per the discussion in #1465 and in this PR, this PR does the following: - Make the `requirements` parameter to the `gazelle_python_manifest` macro optional. - If `requirements` is not provided, no integrity field is added to the manifest, and `diff_test` is used to see if the manifest is stale instead of the existing `go_test` that just checks the integrity. - Migrates `go_binary` to `genrule` to generate the manifest file that can be used with `diff_test`. (There's still a `go_binary` under the hood, but the manifest macro itself uses a genrule now rather than a wrapper `go_binary`.) - It does not migrate the manifest generator from Go to Python; hopefully that can be deferred to another PR. A custom `copy_to_source.sh` script is included, which is used to update the manifest in the source tree. Compatibility discussion: - The update and test target names have not changed; they are still `//:gazelle_python_manifest.update` and `//:gazelle_python_manifest.test`.
- Loading branch information
Showing
12 changed files
with
161 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
6.0.0 | ||
6.4.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""Copy a generated file to the source tree. | ||
Run like: | ||
copy_to_source path/to/generated_file path/to/source_file_to_overwrite | ||
""" | ||
|
||
import os | ||
import shutil | ||
import stat | ||
import sys | ||
from pathlib import Path | ||
|
||
|
||
def copy_to_source(generated_relative_path: Path, target_relative_path: Path) -> None: | ||
"""Copy the generated file to the target file path. | ||
Expands the relative paths by looking at Bazel env vars to figure out which absolute paths to use. | ||
""" | ||
# This script normally gets executed from the runfiles dir, so find the absolute path to the generated file based on that. | ||
generated_absolute_path = Path.cwd() / generated_relative_path | ||
|
||
# Similarly, the target is relative to the source directory. | ||
target_absolute_path = os.getenv("BUILD_WORKSPACE_DIRECTORY") / target_relative_path | ||
|
||
print(f"Copying {generated_absolute_path} to {target_absolute_path}") | ||
target_absolute_path.parent.mkdir(parents=True, exist_ok=True) | ||
shutil.copy(generated_absolute_path, target_absolute_path) | ||
|
||
target_absolute_path.chmod(0O664) | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) != 3: | ||
sys.exit("Usage: copy_to_source <generated_file> <target_file>") | ||
|
||
copy_to_source(Path(sys.argv[1]), Path(sys.argv[2])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.