Skip to content

Commit ee9905e

Browse files
authored
Fix Pants native client handling. (#183)
Guard against the Pants wheel not containing an executable native client / Pip not installing the native client with executable permissions. Today this guards the former: ``` $ zipinfo ~/Downloads/pantsbuild.pants-2.17.0a1-cp39-cp39-manylinux2014_x86_64.whl | grep native_client -rw-r--r-- 2.0 unx 24584416 b- defN 23-May-19 23:21 pants/bin/native_client ``` Fixes #182
1 parent 750ccd7 commit ee9905e

File tree

5 files changed

+45
-2
lines changed

5 files changed

+45
-2
lines changed

CHANGES.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Release Notes
22

3+
## 0.7.2
4+
5+
This release fixes handling of the Pants native client by ensuring it is executable before trying
6+
to run it.
7+
38
## 0.7.1
49

510
Adds support for using the [Pants native client](https://github.com/pantsbuild/pants/pull/11922),

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ members = [
66
[package]
77
name = "scie-pants"
88
description = "Protects your Pants from the elements."
9-
version = "0.7.1"
9+
version = "0.7.2"
1010
edition = "2021"
1111
authors = [
1212
"John Sirois <[email protected]>",

package/src/test.rs

+32
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ pub(crate) fn run_integration_tests(
128128

129129
test_caching_issue_129(scie_pants_scie);
130130
test_custom_pants_toml_issue_153(scie_pants_scie);
131+
test_pants_native_client_perms_issue_182(scie_pants_scie);
131132
}
132133

133134
// Max Python supported is 3.8 and only Linux and macOS x86_64 wheels were released.
@@ -822,3 +823,34 @@ export PANTS_CONFIG_FILES=${{PANTS_TOML}}
822823
String::from_utf8(output.stdout.to_vec()).unwrap().trim()
823824
);
824825
}
826+
827+
fn test_pants_native_client_perms_issue_182(scie_pants_scie: &Path) {
828+
integration_test!(
829+
"Verifying scie-pants sets executable perms on the Pants native client binary when \
830+
present ({issue})",
831+
issue = issue_link(182)
832+
);
833+
834+
let tmpdir = create_tempdir().unwrap();
835+
836+
let pants_release = "2.17.0a1";
837+
let pants_toml_content = format!(
838+
r#"
839+
[GLOBAL]
840+
pants_version = "{pants_release}"
841+
"#
842+
);
843+
let pants_toml = tmpdir.path().join("pants.toml");
844+
write_file(&pants_toml, false, pants_toml_content).unwrap();
845+
846+
let output = execute(
847+
Command::new(scie_pants_scie)
848+
.arg("-V")
849+
.current_dir(&tmpdir)
850+
.stdout(Stdio::piped()),
851+
);
852+
assert_eq!(
853+
pants_release,
854+
decode_output(output.unwrap().stdout).unwrap().trim()
855+
);
856+
}

tools/src/scie_pants/install_pants.py

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import logging
77
import os
8+
import stat
89
import subprocess
910
import sys
1011
from argparse import ArgumentParser
@@ -70,6 +71,10 @@ def pip_install(*args: str) -> None:
7071
pip_install("--progress-bar", "off", *pants_requirements)
7172

7273

74+
def chmod_plus_x(path: str) -> None:
75+
os.chmod(path, os.stat(path).st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
76+
77+
7378
def main() -> NoReturn:
7479
parser = ArgumentParser()
7580
parser.add_argument(
@@ -125,6 +130,7 @@ def main() -> NoReturn:
125130
pants_client_exe = (
126131
native_client_binaries[0] if len(native_client_binaries) == 1 else pants_server_exe
127132
)
133+
chmod_plus_x(pants_client_exe)
128134

129135
with open(env_file, "a") as fp:
130136
print(f"VIRTUAL_ENV={venv_dir}", file=fp)

0 commit comments

Comments
 (0)