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

gittip: Use Meson's capture: true for Python 3.6 compatibility #2869

Merged
merged 1 commit into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions librz/util/str.c
Original file line number Diff line number Diff line change
Expand Up @@ -4067,6 +4067,7 @@ RZ_API char *rz_str_version(const char *program) {
if (!gittip || !*rz_str_trim_head_ro(gittip)) {
goto done;
}
rz_str_trim(gittip);
rz_strbuf_append(sb, "\n");
rz_strbuf_appendf(sb, "commit: %s", gittip);
done:
Expand Down
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ if git_exe.found() and fs.exists('.git')
build_by_default: true,
output: 'gittip',
command: [py3_exe, git_exe_repo_py, git_exe, repo, 'rev-parse', 'HEAD'],
capture: true,
install: true,
install_dir: rizin_bindir
)
Expand Down
4 changes: 1 addition & 3 deletions sys/meson_git_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ def isCArgSupported(executable, path):

def simple_git_execution(args):
try:
called = subprocess.run(args, check=True, capture_output=True)
with open("gittip", "w", encoding="utf8") as f:
f.write(called.stdout.decode("utf8").strip())
called = subprocess.run(args, check=True)

Choose a reason for hiding this comment

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

This is wrong, and using capture: true in Meson is bad -- it causes this python script to be run by meson --internal exe, which imports lots of stuff and is very slow and obscures the command line.

You don't need to throw the baby out with the bathwater. capture_output is python 3.7, sure, but it's also literally an alias for stdout=subprocess.PIPE, stderr=subprocess.PIPE and it's extremely easy to make that work with python 3.6.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks a lot for this hint!

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay #2873 ... Using stdout=subprocess.PIPE changes the behavior of sys/meson_git_wrapper.py away from expected behavior, but hopefully this divergence is only temporary.

Copy link

@eli-schwartz eli-schwartz Aug 5, 2022

Choose a reason for hiding this comment

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

Great. Happy to help. :)

Capture exists solely for the benefit of tools that don't support specifying the output file and usually cannot be modified as they are external processing tools rather than internal helper scripts, so you don't really have a choice.

sys.exit(called.returncode)
except subprocess.CalledProcessError as e:
sys.exit(e.returncode)
Expand Down