Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix the requirements arg to the gazelle python manifest generator. #2533

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sputt
Copy link

@sputt sputt commented Dec 24, 2024

Fix args passed into the gazelle manifest file generator if the requirements file is not a source file.

@sputt
Copy link
Author

sputt commented Dec 24, 2024

Before

SUBCOMMAND: # //private/tools:gazelle_python_manifest.genrule [action 'Executing genrule //private/tools:gazelle_python_manifest.genrule', configuration: c44a261b7e8f814b4f77f0e2cc503ebef701b283942d7e8ff5ae6f26c41513da, execution platform: @@platforms//host:host, mnemonic: Genrule]
(cd /private/var/tmp/_bazel_sputt/3b16e11ed38a9a587395e3bd748a9a16/execroot/_main && \
  exec env - \
    PATH=/Users/sputt/Library/Caches/bazelisk/downloads/sha256/02b117b97d0921ae4d4f4e11d27e2c0930381df416e373435d5d0419c6a26f24/bin:/Users/sputt/.vscode/extensions/ms-python.python-2024.22.0-darwin-arm64/python_files/deactivate/zsh:/Users/sputt/req-compile/venv/bin:/Library/Frameworks/Python.framework/Versions/3.12/bin:/Library/Frameworks/Python.framework/Versions/3.11/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/sputt/.vscode/extensions/ms-python.python-2024.22.0-darwin-arm64/python_files/deactivate/zsh:/Users/sputt/req-compile/venv/bin:/Library/Frameworks/Python.framework/Versions/3.12/bin:/Library/Frameworks/Python.framework/Versions/3.11/bin \
  /bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/rules_python_gazelle_plugin~/manifest/generate/generate_/generate --manifest-generator-hash=bazel-out/darwin_arm64-fastbuild/bin/external/rules_python_gazelle_plugin~/manifest/generate/generate_lib_sources_hash.hash --requirements=private/tools/gazelle_python_manifest_requirements.txt --pip-repository-name=req_compile_deps --modules-mapping=bazel-out/darwin_arm64-fastbuild/bin/private/tools/modules_mapping.json --output=bazel-out/darwin_arm64-fastbuild/bin/private/tools/gazelle_python_manifest.generated_manifest --update-target=//private/tools:gazelle_python_manifest.update')
# Configuration: c44a261b7e8f814b4f77f0e2cc503ebef701b283942d7e8ff5ae6f26c41513da
# Execution platform: @@platforms//host:host
ERROR: /Users/sputt/req-compile/private/tools/BUILD.bazel:16:24: Executing genrule //private/tools:gazelle_python_manifest.genrule failed: (Exit 1): bash failed: error executing Genrule command (from target //private/tools:gazelle_python_manifest.genrule) /bin/bash -c ... (remaining 1 argument skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
2024/12/24 11:07:24 ERROR: failed to write output: open private/tools/gazelle_python_manifest_requirements.txt: no such file or directory
Target //private/tools:gazelle_python_manifest.update failed to build
--requirements=private/tools/gazelle_python_manifest_requirements.txt

After

SUBCOMMAND: # //private/tools:gazelle_python_manifest.genrule [action 'Executing genrule //private/tools:gazelle_python_manifest.genrule', configuration: c44a261b7e8f814b4f77f0e2cc503ebef701b283942d7e8ff5ae6f26c41513da, execution platform: @@platforms//host:host, mnemonic: Genrule]
(cd /private/var/tmp/_bazel_sputt/3b16e11ed38a9a587395e3bd748a9a16/execroot/_main && \
  exec env - \
    PATH=/Users/sputt/Library/Caches/bazelisk/downloads/sha256/02b117b97d0921ae4d4f4e11d27e2c0930381df416e373435d5d0419c6a26f24/bin:/Users/sputt/.vscode/extensions/ms-python.python-2024.22.0-darwin-arm64/python_files/deactivate/zsh:/Users/sputt/req-compile/venv/bin:/Library/Frameworks/Python.framework/Versions/3.12/bin:/Library/Frameworks/Python.framework/Versions/3.11/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/sputt/.vscode/extensions/ms-python.python-2024.22.0-darwin-arm64/python_files/deactivate/zsh:/Users/sputt/req-compile/venv/bin:/Library/Frameworks/Python.framework/Versions/3.12/bin:/Library/Frameworks/Python.framework/Versions/3.11/bin \
  /bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/rules_python_gazelle_plugin~/manifest/generate/generate_/generate --manifest-generator-hash=bazel-out/darwin_arm64-fastbuild/bin/external/rules_python_gazelle_plugin~/manifest/generate/generate_lib_sources_hash.hash --requirements=bazel-out/darwin_arm64-fastbuild/bin/private/tools/gazelle_python_manifest_requirements.txt --pip-repository-name=req_compile_deps --modules-mapping=bazel-out/darwin_arm64-fastbuild/bin/private/tools/modules_mapping.json --output=bazel-out/darwin_arm64-fastbuild/bin/private/tools/gazelle_python_manifest.generated_manifest --update-target=//private/tools:gazelle_python_manifest.update')
# Configuration: c44a261b7e8f814b4f77f0e2cc503ebef701b283942d7e8ff5ae6f26c41513da
# Execution platform: @@platforms//host:host
--requirements=bazel-out/darwin_arm64-fastbuild/bin/private/tools/gazelle_python_manifest_requirements.txt

Copy link
Collaborator

@dougthor42 dougthor42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you able to provide a test case that gets fixed by this change?

I tested things locally and didn't see any glaring issues, but am also not entirely sure how to reproduce the issue.

@sputt
Copy link
Author

sputt commented Dec 27, 2024

Yes you must only provide a generated file as the requirements.txt, or have the macro produce one with the genrule, to produce the issue. rootpath is not correct as an arg to an action input, but happens to work when the file is a source file.

Here is the example from the req-compile project:

gazelle_python_manifest(
    name = "gazelle_python_manifest",
    modules_mapping = ":modules_map",
    pip_repository_name = "req_compile_deps",
    requirements = [
        "//3rdparty:requirements.linux.txt",
        "//private/tests/annotations:requirements.linux.txt",
        "//private/tests/platlib:requirements.linux.txt",
    ],
)

https://github.com/periareon/req-compile/blob/3ef72ef1849caf2412f4bb4f0a6dadbb17f5fbcc/private/tools/BUILD.bazel#L23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants