Skip to content

Commit 1d0aaaf

Browse files
authored
Drop support for PANTS_SHA (#376)
The `PANTS_SHA` feature was deprecated with the release `0.10.0` of `scie-pants`. Broken out of #351
1 parent d336b8f commit 1d0aaaf

File tree

9 files changed

+25
-143
lines changed

9 files changed

+25
-143
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
run: cargo clippy --locked --all
4343
- name: Unit Tests
4444
run: cargo test --all
45-
- name: Setup Python 3.9
45+
- name: Setup Python 3.9 (Ubuntu only)
4646
if: ${{ matrix.os == 'ubuntu-22.04' }}
4747
uses: actions/setup-python@v4
4848
with:
@@ -54,9 +54,12 @@ jobs:
5454
with:
5555
path: ${{ env.SCIE_PANTS_DEV_CACHE }}
5656
key: ${{ matrix.os }}-scie-pants-v6
57-
- name: Build, Package & Integration Tests
57+
- name: Build, Package & Integration Tests (MacOS)
5858
if: ${{ matrix.os == 'macOS-10.15-X64' || matrix.os == 'macOS-11-ARM64'}}
5959
run: |
60+
# Clean up the science cache for Pants 2.19.1 setup to ensure it's bootstrapped each run.
61+
rm -rf ~/Library/Caches/nce/*/bindings/venv/2.19.1
62+
6063
# TODO(John Sirois): Kill --tools-pex-mismatch-warn:
6164
# https://github.com/pantsbuild/scie-pants/issues/2
6265
#
@@ -69,7 +72,7 @@ jobs:
6972
#
7073
PANTS_BOOTSTRAP_GITHUB_API_BEARER_TOKEN=${{ secrets.GITHUB_TOKEN }} \
7174
cargo run -p package -- test --check --tools-pex-mismatch-warn
72-
- name: Build, Package & Integration Tests
75+
- name: Build, Package & Integration Tests (Ubuntu)
7376
if: ${{ matrix.os == 'ubuntu-22.04' }}
7477
run: |
7578
cargo run -p package -- --dest-dir dist/ tools

CHANGES.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Release Notes
22

3+
## 0.11.0
4+
5+
Drop support for `PANTS_SHA` which was deprecated in `0.10.0`.
6+
37
## 0.10.8
48

59
Redirect pants install messages to a `pants-install.log` file in pants venv directory to not pollute
@@ -50,9 +54,8 @@ It also supports fetching Pants PEXes from behind a firewall.
5054
## 0.10.0
5155

5256
This release deprecates support for running against an arbitrary Pants commit using
53-
`PANTS_SHA=abc123... pants ...`. Pants no longer
54-
publishes the artifacts required for this for new commits, and so this is becoming less and less
55-
useful. To replace use of `PANTS_SHA`, do one of:
57+
`PANTS_SHA=abc123... pants ...`. Pants no longer publishes the artifacts required for this for new
58+
commits, and so this is becoming less and less useful. To replace use of `PANTS_SHA`, do one of:
5659

5760
- Use a released version of Pants.
5861
- Run pants from sources (for example: `PANTS_SOURCE=/path/to/pants-checkout pants ...`).

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
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.10.8"
9+
version = "0.11.0"
1010
edition = "2021"
1111
authors = [
1212
"John Sirois <[email protected]>",

package/scie-pants.toml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ name = "pants"
5656
# appropriate by the default "Boot" one above)
5757
# description = "Runs a hermetic Pants installation."
5858
exe = "{scie.bindings.install:PANTS_CLIENT_EXE}"
59-
args = [
60-
"{scie.bindings.configure:PANTS_SHA_FIND_LINKS}",
61-
]
6259

6360
[lift.commands.env.default]
6461
PANTS_BUILDROOT_OVERRIDE = "{scie.bindings.configure:PANTS_BUILDROOT_OVERRIDE}"
@@ -90,7 +87,6 @@ __import__("debugpy.server.cli").server.cli.main()
9087
"127.0.0.1:5678",
9188
"--wait-for-client",
9289
"{scie.bindings.install:VIRTUAL_ENV}/bin/pants",
93-
"{scie.bindings.configure:PANTS_SHA_FIND_LINKS}",
9490
]
9591

9692
[lift.commands.env.default]
@@ -183,8 +179,6 @@ args = [
183179
"{ptex}",
184180
"--pants-version",
185181
"{scie.env.PANTS_VERSION}",
186-
"--pants-sha",
187-
"{scie.env.PANTS_SHA}",
188182
"--pants-config",
189183
"{scie.env.PANTS_TOML}",
190184
"--github-api-bearer-token",

package/src/test.rs

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -112,31 +112,13 @@ pub(crate) fn run_integration_tests(
112112
test_tools_pex_reproducibility(workspace_root, tools_pex_path, tools_pex_mismatch_warn);
113113
test_pants_bootstrap_tools(scie_pants_scie);
114114

115-
// TODO(John Sirois): The --no-pantsd here works around a fairly prevalent Pants crash on
116-
// Linux x86_64 along the lines of the following, but sometimes varying:
117-
// >> Verifying PANTS_SHA is respected
118-
// Bootstrapping Pants 2.14.0a0+git8e381dbf using cpython 3.9.15
119-
// Installing pantsbuild.pants==2.14.0a0+git8e381dbf into a virtual environment at /home/runner/.cache/nce/67f27582b3729c677922eb30c5c6e210aa54badc854450e735ef41cf25ac747f/bindings/venvs/2.14.0a0+git8e381dbf
120-
// New virtual environment successfully created at /home/runner/.cache/nce/67f27582b3729c677922eb30c5c6e210aa54badc854450e735ef41cf25ac747f/bindings/venvs/2.14.0a0+git8e381dbf.
121-
// 18:11:53.75 [INFO] Initializing scheduler...
122-
// 18:11:53.97 [INFO] Scheduler initialized.
123-
// 2.14.0a0+git8e381dbf
124-
// Fatal Python error: PyGILState_Release: thread state 0x7efe18001140 must be current when releasing
125-
// Python runtime state: finalizing (tstate=0x1f4b810)
126-
//
127-
// Thread 0x00007efe30b75540 (most recent call first):
128-
// <no Python frame>
129-
// Error: Command "/home/runner/work/scie-pants/scie-pants/dist/scie-pants-linux-x86_64" "--no-verify-config" "-V" failed with exit code: None
130-
if matches!(*CURRENT_PLATFORM, Platform::LinuxX86_64) {
131-
log!(Color::Yellow, "Turning off pantsd for remaining tests.");
132-
env::set_var("PANTS_PANTSD", "False");
133-
}
115+
log!(Color::Yellow, "Turning off pantsd for remaining tests.");
116+
env::set_var("PANTS_PANTSD", "False");
134117

135-
test_pants_shas(scie_pants_scie);
136118
test_python_repos_repos(scie_pants_scie);
137119
test_initialize_new_pants_project(scie_pants_scie);
138120
test_set_pants_version(scie_pants_scie);
139-
test_ignore_empty_pants_version_pants_sha(scie_pants_scie);
121+
test_ignore_empty_pants_version(scie_pants_scie);
140122

141123
test_pants_from_pex_version(scie_pants_scie);
142124
test_pants_from_bad_pex_version(scie_pants_scie);
@@ -351,26 +333,6 @@ fn test_pants_bootstrap_tools(scie_pants_scie: &Path) {
351333
.unwrap();
352334
}
353335

354-
fn test_pants_shas(scie_pants_scie: &Path) {
355-
for sha in [
356-
// initial
357-
"8e381dbf90cae57c5da2b223c577b36ca86cace9",
358-
// native-client added to wheel
359-
"558d843549204bbe49c351d00cdf23402da262c1",
360-
] {
361-
integration_test!("Verifying significant PANTS_SHA: {sha}");
362-
let existing_project_dir = create_tempdir().unwrap();
363-
touch(&existing_project_dir.path().join("pants.toml")).unwrap();
364-
execute(
365-
Command::new(scie_pants_scie)
366-
.current_dir(existing_project_dir.path())
367-
.env("PANTS_SHA", sha)
368-
.args(["--no-verify-config", "-V"]),
369-
)
370-
.unwrap();
371-
}
372-
}
373-
374336
fn test_python_repos_repos(scie_pants_scie: &Path) {
375337
integration_test!(
376338
"Verifying --python-repos-repos is used prior to Pants 2.13 (no warnings should be \
@@ -413,8 +375,8 @@ fn test_set_pants_version(scie_pants_scie: &Path) {
413375
.unwrap();
414376
}
415377

416-
fn test_ignore_empty_pants_version_pants_sha(scie_pants_scie: &Path) {
417-
integration_test!("Verifying ignoring PANTS_SHA and PANTS_VERSION when set to empty string");
378+
fn test_ignore_empty_pants_version(scie_pants_scie: &Path) {
379+
integration_test!("Verifying ignoring PANTS_VERSION when set to empty string");
418380

419381
let tmpdir = create_tempdir().unwrap();
420382

@@ -431,7 +393,6 @@ fn test_ignore_empty_pants_version_pants_sha(scie_pants_scie: &Path) {
431393
let output = execute(
432394
Command::new(scie_pants_scie)
433395
.arg("-V")
434-
.env("PANTS_SHA", "")
435396
.env("PANTS_VERSION", "")
436397
.current_dir(&tmpdir)
437398
.stdout(Stdio::piped()),

src/main.rs

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::ffi::{OsStr, OsString};
66
use std::fmt::Debug;
77
use std::path::PathBuf;
88

9-
use anyhow::{anyhow, bail, Context, Result};
9+
use anyhow::{anyhow, Context, Result};
1010
use build_root::BuildRoot;
1111
use log::{info, trace};
1212
use logging_timer::{time, timer, Level};
@@ -78,7 +78,7 @@ impl Process {
7878
fn env_version(env_var_name: &str) -> Result<Option<String>> {
7979
let raw_version = env::var_os(env_var_name).unwrap_or(OsString::new());
8080
if raw_version.len() == 0 {
81-
// setting PANTS_VERSION= or PANTS_SHA= behaves the same as not setting them
81+
// setting PANTS_VERSION= behaves the same as not setting it
8282
Ok(None)
8383
} else {
8484
Ok(Some(raw_version.into_string().map_err(|raw| {
@@ -171,37 +171,11 @@ fn get_pants_process() -> Result<Process> {
171171
(None, None, None, false)
172172
};
173173

174-
let env_pants_sha = env_version("PANTS_SHA")?;
175174
let env_pants_version = env_version("PANTS_VERSION")?;
176-
if let Some(pants_sha) = &env_pants_sha {
177-
// when support for PANTS_SHA is fully removed, PANTS_SHA_FIND_LINKS can be removed too
178-
eprintln!(
179-
"\
180-
DEPRECATED: Support for PANTS_SHA=... will be removed in a future version of the `pants` launcher.
181-
182-
The artifacts for PANTS_SHA are no longer published for new commits. This invocation set PANTS_SHA={pants_sha}.
183-
184-
To resolve, do one of:
185-
- Use a released version of Pants.
186-
- Run pants from sources (for example: `PANTS_SOURCE=/path/to/pants-checkout pants ...`).
187-
- If these are not appropriate, let us know what you're using it for: <https://www.pantsbuild.org/docs/getting-help>.
188-
"
189-
);
190-
191-
if let Some(pants_version) = &env_pants_version {
192-
bail!(
193-
"Both PANTS_SHA={pants_sha} and PANTS_VERSION={pants_version} were set. \
194-
Please choose one.",
195-
)
196-
}
197-
}
198-
199175
let pants_version = if let Some(env_version) = env_pants_version {
200176
Some(env_version)
201-
} else if env_pants_sha.is_none() {
202-
configured_pants_version.clone()
203177
} else {
204-
None
178+
configured_pants_version.clone()
205179
};
206180

207181
if delegate_bootstrap && pants_version.is_none() {
@@ -264,7 +238,7 @@ To resolve, do one of:
264238
env.push(("_PANTS_VERSION_OVERRIDE".into(), version.clone().into()));
265239
}
266240
env.push(("PANTS_VERSION".into(), version.into()));
267-
} else if env_pants_sha.is_none() {
241+
} else {
268242
// Ensure the install binding always re-runs when no Pants version is found so that the
269243
// the user can be prompted with configuration options.
270244
env.push((

tools/src/scie_pants/configure_pants.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from scie_pants.log import fatal, info, init_logging, warn
1717
from scie_pants.pants_version import (
1818
determine_latest_stable_version,
19-
determine_sha_version,
2019
determine_tag_version,
2120
)
2221
from scie_pants.ptex import Ptex
@@ -59,7 +58,6 @@ def prompt_for_pants_config() -> Path | None:
5958
def main() -> NoReturn:
6059
parser = ArgumentParser()
6160
get_ptex = Ptex.add_options(parser)
62-
parser.add_argument("--pants-sha", help="The Pants sha to install (trumps --version)")
6361
parser.add_argument("--pants-version", help="The Pants version to install")
6462
parser.add_argument("--pants-config", help="The path of the pants.toml file")
6563
parser.add_argument(
@@ -82,13 +80,7 @@ def main() -> NoReturn:
8280
finalizers = []
8381
newly_created_build_root = None
8482
pants_config = Path(options.pants_config) if options.pants_config else None
85-
if options.pants_sha:
86-
resolve_info = determine_sha_version(
87-
ptex=ptex, sha=options.pants_sha, find_links_dir=find_links_dir
88-
)
89-
assert resolve_info.sha_version is not None
90-
version = resolve_info.sha_version
91-
elif options.pants_version:
83+
if options.pants_version:
9284
resolve_info = determine_tag_version(
9385
ptex=ptex,
9486
pants_version=options.pants_version,
@@ -125,9 +117,6 @@ def main() -> NoReturn:
125117
with open(env_file, "a") as fp:
126118
if resolve_info.find_links:
127119
print(f"FIND_LINKS={resolve_info.find_links}", file=fp)
128-
# This can be removed once we stop supporting PANTS_SHA:
129-
# NB. this is added unconditionally because it gets set as an argument
130-
print(f"PANTS_SHA_FIND_LINKS={resolve_info.pants_find_links_option(version)}", file=fp)
131120
if newly_created_build_root:
132121
print(f"PANTS_BUILDROOT_OVERRIDE={newly_created_build_root}", file=fp)
133122
print(f"PANTS_VERSION={version}", file=fp)

tools/src/scie_pants/pants_version.py

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,14 @@
3131
@dataclass(frozen=True)
3232
class ResolveInfo:
3333
stable_version: Version
34-
sha_version: Version | None
3534
find_links: str | None
3635

37-
def pants_find_links_option(self, pants_version_selected: Version) -> str:
38-
# We only want to add the find-links repo for PANTS_SHA invocations so that plugins can
39-
# resolve Pants the only place it can be found in that case - our ~private
40-
# binaries.pantsbuild.org S3 find-links bucket.
41-
operator = "-" if pants_version_selected == self.stable_version else "+"
42-
option_name = (
43-
"repos"
44-
if self.stable_version in SpecifierSet("<2.14.0", prereleases=True)
45-
else "find-links"
46-
)
47-
value = f"'{self.find_links}'" if self.find_links else ""
48-
49-
# we usually pass a no-op, e.g. --python-repos-find-links=-[], because this is only used for
50-
# PANTS_SHA support that is now deprecated and will be removed
51-
return f"--python-repos-{option_name}={operator}[{value}]"
52-
5336

5437
def determine_find_links(
5538
ptex: Ptex,
5639
pants_version: str,
5740
sha: str,
5841
find_links_dir: Path,
59-
include_nonrelease_pants_distributions_in_findlinks: bool,
6042
) -> ResolveInfo:
6143
abbreviated_sha = sha[:8]
6244
sha_version = Version(f"{pants_version}+git{abbreviated_sha}")
@@ -79,19 +61,10 @@ def determine_find_links(
7961
f"</a>{os.linesep}".encode()
8062
)
8163
fp.flush()
82-
if include_nonrelease_pants_distributions_in_findlinks:
83-
pantsbuild_pants_find_links = (
84-
"https://binaries.pantsbuild.org/wheels/pantsbuild.pants/"
85-
f"{sha}/{urllib.parse.quote(str(sha_version))}/index.html"
86-
)
87-
ptex.fetch_to_fp(pantsbuild_pants_find_links, fp)
88-
fp.flush()
89-
9064
ptex.fetch_to_fp("https://wheels.pantsbuild.org/simple/", fp)
9165

9266
return ResolveInfo(
9367
stable_version=Version(pants_version),
94-
sha_version=sha_version,
9568
find_links=f"file://{find_links_file}",
9669
)
9770

@@ -101,7 +74,7 @@ def determine_tag_version(
10174
) -> ResolveInfo:
10275
stable_version = Version(pants_version)
10376
if stable_version >= PANTS_PEX_GITHUB_RELEASE_VERSION:
104-
return ResolveInfo(stable_version, sha_version=None, find_links=None)
77+
return ResolveInfo(stable_version, find_links=None)
10578

10679
tag = f"release_{pants_version}"
10780

@@ -145,21 +118,6 @@ def determine_tag_version(
145118
pants_version,
146119
commit_sha,
147120
find_links_dir,
148-
include_nonrelease_pants_distributions_in_findlinks=False,
149-
)
150-
151-
152-
def determine_sha_version(ptex: Ptex, sha: str, find_links_dir: Path) -> ResolveInfo:
153-
version_file_url = (
154-
f"https://raw.githubusercontent.com/pantsbuild/pants/{sha}/src/python/pants/VERSION"
155-
)
156-
pants_version = ptex.fetch_text(version_file_url).strip()
157-
return determine_find_links(
158-
ptex,
159-
pants_version,
160-
sha,
161-
find_links_dir,
162-
include_nonrelease_pants_distributions_in_findlinks=True,
163121
)
164122

165123

0 commit comments

Comments
 (0)