Skip to content

Commit

Permalink
Add wheels to handle cycles in deps logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ewianda committed Jan 29, 2024
1 parent 8ee57e9 commit 0a1a77d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/workspace_snippet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,21 @@ NAME=rules_python_gazelle
COMMIT=$(git rev-parse HEAD)
PREFIX=${NAME}-${COMMIT}
SHA=$(git archive --format=tar --prefix=${PREFIX}/ ${COMMIT} | gzip | shasum -a 256 | awk '{print $1}')
INTEGRITY=$(git archive --format=tar --prefix=${PREFIX}/ ${COMMIT} | gzip | openssl dgst -sha256 -binary | openssl base64 -A)

cat << EOF
cat <<EOF
MODULE.bazel setup:
\`\`\`starlark
bazel_dep(name = "com_github_benchsci_rules_python_gazelle", version = "0.0.0", repo_name = "com_github_benchsci_rules_python_gazelle")
archive_override(
module_name = "com_github_benchsci_rules_python_gazelle",
integrity = "sha256-${INTEGRITY}",
strip_prefix = "${PREFIX}",
urls = ["https://github.com/benchsci/rules_python_gazelle/archive/$COMMIT.tar.gz"],
)
\`\`\`
WORKSPACE setup:
\`\`\`starlark
Expand Down
9 changes: 7 additions & 2 deletions gazelle/modules_mapping/def.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ module name doesn't match the wheel distribution name.
def _modules_mapping_impl(ctx):
modules_mapping = ctx.actions.declare_file(ctx.attr.modules_mapping_name)
args = ctx.actions.args()
all_wheels = depset(
[whl for whl in ctx.files.wheels],
transitive = [dep[DefaultInfo].files for dep in ctx.attr.wheels] + [dep[DefaultInfo].data_runfiles.files for dep in ctx.attr.wheels],
)
args.add(modules_mapping.path)
args.add_all([whl.path for whl in ctx.files.wheels])
args.add_all([whl.path for whl in all_wheels.to_list()])

ctx.actions.run(
inputs = ctx.files.wheels,
inputs = all_wheels.to_list(),
outputs = [modules_mapping],
executable = ctx.executable._generator,
arguments = [args],
Expand Down

0 comments on commit 0a1a77d

Please sign in to comment.