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

Use the pants native-client if it is present in the distribution. #172

Merged
merged 6 commits into from
May 15, 2023
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
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release Notes

## 0.7.1

Adds support for using the [Pants native client](https://github.com/pantsbuild/pants/pull/11922),
if it has been included in the Pants distribution. Pants releases starting with `2.17.0a0` are
expected to include the native client.

## 0.7.0

This release updates `scie-jump` to 0.11.0 and `ptex` to 0.7.0. The `scie-jump` upgrade brings in
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ members = [
[package]
name = "scie-pants"
description = "Protects your Pants from the elements."
version = "0.7.0"
version = "0.7.1"
edition = "2021"
authors = [
"John Sirois <john.sirois@gmail.com>",
Expand Down
5 changes: 3 additions & 2 deletions package/scie-pants.lift.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@
"description": "Runs a hermetic Pants installation.",
"env": {
"=PANTS_VERSION": "{scie.bindings.configure:PANTS_VERSION}",
"PANTS_BUILDROOT_OVERRIDE": "{scie.bindings.configure:PANTS_BUILDROOT_OVERRIDE}"
"PANTS_BUILDROOT_OVERRIDE": "{scie.bindings.configure:PANTS_BUILDROOT_OVERRIDE}",
"=_PANTS_SERVER_EXE": "{scie.bindings.install:PANTS_SERVER_EXE}"
stuhood marked this conversation as resolved.
Show resolved Hide resolved
},
"exe": "{scie.bindings.install:VIRTUAL_ENV}/bin/pants",
"exe": "{scie.bindings.install:PANTS_CLIENT_EXE}",
"args": [
"{scie.bindings.configure:PANTS_SHA_FIND_LINKS}"
]
Expand Down
28 changes: 19 additions & 9 deletions package/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub(crate) fn run_integration_tests(
env::set_var("PANTS_PANTSD", "False");
}

test_pants_sha(scie_pants_scie);
test_pants_shas(scie_pants_scie);
test_python_repos_repos(scie_pants_scie);
test_initialize_new_pants_project(scie_pants_scie);
test_set_pants_version(scie_pants_scie);
Expand Down Expand Up @@ -294,14 +294,24 @@ fn test_pants_bootstrap_tools(scie_pants_scie: &Path) {
.unwrap();
}

fn test_pants_sha(scie_pants_scie: &Path) {
integration_test!("Verifying PANTS_SHA is respected");
execute(
Command::new(scie_pants_scie)
.env("PANTS_SHA", "8e381dbf90cae57c5da2b223c577b36ca86cace9")
.args(["--no-verify-config", "-V"]),
)
.unwrap();
fn test_pants_shas(scie_pants_scie: &Path) {
for sha in [
// initial
"8e381dbf90cae57c5da2b223c577b36ca86cace9",
// native-client added to wheel
"558d843549204bbe49c351d00cdf23402da262c1",
] {
integration_test!("Verifying significant PANTS_SHA: {sha}");
let existing_project_dir = create_tempdir().unwrap();
touch(&existing_project_dir.path().join("pants.toml")).unwrap();
execute(
Command::new(scie_pants_scie)
.current_dir(existing_project_dir.path())
.env("PANTS_SHA", sha)
.args(["--no-verify-config", "-V"]),
)
.unwrap();
}
}

fn test_python_repos_repos(scie_pants_scie: &Path) {
Expand Down
9 changes: 2 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,8 @@ fn get_pants_process() -> Result<Process> {
let pants_debug = matches!(env::var_os("PANTS_DEBUG"), Some(value) if !value.is_empty());
let scie_boot = match env::var_os("PANTS_BOOTSTRAP_TOOLS") {
Some(_) => ScieBoot::BootstrapTools,
None => {
if pants_debug {
ScieBoot::PantsDebug
} else {
ScieBoot::Pants
}
}
None if pants_debug => ScieBoot::PantsDebug,
None => ScieBoot::Pants,
};

let pants_bin_name = env::var_os("PANTS_BIN_NAME")
Expand Down
12 changes: 12 additions & 0 deletions tools/src/scie_pants/install_pants.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import subprocess
import sys
from argparse import ArgumentParser
from glob import glob
from pathlib import Path
from typing import Iterable, NoReturn

Expand Down Expand Up @@ -116,8 +117,19 @@ def main() -> NoReturn:
)
info(f"New virtual environment successfully created at {venv_dir}.")

pants_server_exe = str(venv_dir / "bin" / "pants")
# Added in https://github.com/pantsbuild/pants/commit/558d843549204bbe49c351d00cdf23402da262c1
native_client_binaries = glob(
str(venv_dir / "lib/python*/site-packages/pants/bin/native_client")
)
pants_client_exe = (
native_client_binaries[0] if len(native_client_binaries) == 1 else pants_server_exe
)

with open(env_file, "a") as fp:
print(f"VIRTUAL_ENV={venv_dir}", file=fp)
print(f"PANTS_SERVER_EXE={pants_server_exe}", file=fp)
print(f"PANTS_CLIENT_EXE={pants_client_exe}", file=fp)

sys.exit(0)

Expand Down