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

Make sure output directory for actool exists before invoking actool #896

Merged
merged 1 commit into from
Sep 3, 2020

Conversation

thii
Copy link
Member

@thii thii commented Sep 2, 2020

Previously, each "actool" compile action declared an output directory
but didn't create it. Instead, it relied on Bazel to create the
directory before invoking the tool. With a non-remote spawn strategy,
Bazel would implicitly create it for you; but with the remote spawn
strategy, it is not created by the remote worker.

Additionally, this was also against what was documented for
declare_directory, which says that "You must create an action that
generates the directory".

This patches the "actool" wrapper to create an empty directory if one
doesn't exist at the specified output path, to make it works with remote
execution.

Fixes #861.

@thii thii force-pushed the actool_declare_directory branch from bda63b1 to f248143 Compare September 2, 2020 06:25
Previously, each "actool" compile action declared an output directory
but didn't create it. Instead, it relied on Bazel to create the
directory before invoking the tool. With a non-remote spawn strategy,
Bazel would implicitly create it for you; but with the remote spawn
strategy, it is not created by the remote worker.

Additionally, this was also against what was documented for
`declare_directory`, which says that "You must create an action that
generates the directory".

This patches the "actool" wrapper to create an empty directory if one
doesn't exist at the specified output path, to make it works with remote
execution.
@thii thii force-pushed the actool_declare_directory branch from f248143 to 57045bd Compare September 2, 2020 07:10
for idx, arg in enumerate(toolargs):
if arg == "--compile":
output_dir = toolargs[idx + 1]
if not os.path.exists(output_dir):
Copy link
Contributor

Choose a reason for hiding this comment

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

could use os.makedirs(output_dir, exist_ok=True) instead of checking for existence

Copy link
Member Author

Choose a reason for hiding this comment

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

Checked that but it's only available on Python ≥ 3.5.

Copy link
Contributor

Choose a reason for hiding this comment

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

ugh i wish rules_python just bundled real python toolchains...

for idx, arg in enumerate(toolargs):
if arg == "--compile":
output_dir = toolargs[idx + 1]
if not os.path.exists(output_dir):
Copy link
Contributor

Choose a reason for hiding this comment

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

ugh i wish rules_python just bundled real python toolchains...

@segiddins segiddins merged commit 1b78488 into bazelbuild:master Sep 3, 2020
@thii thii deleted the actool_declare_directory branch September 3, 2020 01:28
copybara-service bot pushed a commit that referenced this pull request Jan 24, 2022
Previously, each "actool" compile action declared an output directory
but didn't create it. Instead, it relied on Bazel to create the
directory before invoking the tool. With a non-remote spawn strategy,
Bazel would implicitly create it for you; but with the remote spawn
strategy, it is not created by the remote worker.

Additionally, this was also against what was documented for
declare_directory, which says that "You must create an action that
generates the directory".

This patches the "actool" wrapper to create an empty directory if one
doesn't exist at the specified output path, to make it works with remote
execution.

#896

RELNOTES: None
PiperOrigin-RevId: 423797086
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Actions that declare directories but don't create those directories fail to build with remote strategy
3 participants