Skip to content
This repository was archived by the owner on Dec 26, 2022. It is now read-only.

Commit 6759fb2

Browse files
Update pants shell script to latest version
Signed-off-by: Christopher Maier <[email protected]>
1 parent d87a3a7 commit 6759fb2

File tree

1 file changed

+30
-13
lines changed

1 file changed

+30
-13
lines changed

pants

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ fi
3434

3535
PANTS_BOOTSTRAP="${PANTS_SETUP_CACHE}/bootstrap-$(uname -s)-$(uname -m)"
3636

37-
_PEX_VERSION=2.1.42
37+
_PEX_VERSION=2.1.62
3838
_PEX_URL="https://github.com/pantsbuild/pex/releases/download/v${_PEX_VERSION}/pex"
39-
_PEX_EXPECTED_SHA256="69d6b1b1009b00dd14a3a9f19b72cff818a713ca44b3186c9b12074b2a31e51f"
39+
_PEX_EXPECTED_SHA256="56668b1ca147bd63141e586ffee97c7cc51ce8e6eac6c9b7a4bf1215b94396e5"
4040

4141
VIRTUALENV_VERSION=20.4.7
4242
VIRTUALENV_REQUIREMENTS=$(
@@ -87,13 +87,18 @@ function get_exe_path_or_die {
8787
fi
8888
}
8989

90-
function get_pants_config_value {
90+
function get_pants_config_string_value {
9191
local config_key="$1"
9292
local optional_space="[[:space:]]*"
9393
local prefix="^${config_key}${optional_space}=${optional_space}"
9494
local raw_value
95-
raw_value="$(sed -ne "/${prefix}/ s#${prefix}##p" "${PANTS_TOML}")"
96-
echo "${raw_value}" | tr -d \"\' && return 0
95+
raw_value="$(sed -ne "/${prefix}/ s|${prefix}||p" "${PANTS_TOML}")"
96+
local optional_suffix="${optional_space}(#.*)?$"
97+
echo "${raw_value}" \
98+
| sed -E \
99+
-e "s|^'([^']*)'${optional_suffix}|\1|" \
100+
-e 's|^"([^"]*)"'"${optional_suffix}"'$|\1|' \
101+
&& return 0
97102
return 0
98103
}
99104

@@ -125,7 +130,7 @@ function determine_pants_version {
125130
return
126131
fi
127132

128-
pants_version="$(get_pants_config_value 'pants_version')"
133+
pants_version="$(get_pants_config_string_value 'pants_version')"
129134
if [[ -z "${pants_version}" ]]; then
130135
die "Please explicitly specify the \`pants_version\` in your \`pants.toml\` under the \`[GLOBAL]\` scope.
131136
See https://pypi.org/project/pantsbuild.pants/#history for all released versions
@@ -191,8 +196,8 @@ function determine_default_python_exe {
191196
if [[ -z "${interpreter_path}" ]]; then
192197
continue
193198
fi
194-
# Check if the Python version is installed via Pyenv but not activated.
195-
if [[ "$("${interpreter_path}" --version 2>&1 > /dev/null)" == "pyenv: python${version}"* ]]; then
199+
# Check if a version is shimmed by pyenv or asdf but not configured.
200+
if ! "${interpreter_path}" --version >/dev/null 2>&1; then
196201
continue
197202
fi
198203
if [[ -n "$(check_python_exe_compatible_version "${interpreter_path}")" ]]; then
@@ -249,7 +254,12 @@ function bootstrap_pex {
249254
local staging_dir
250255
staging_dir=$(tempdir "${PANTS_BOOTSTRAP}")
251256
cd "${staging_dir}"
252-
curl -LO "${_PEX_URL}"
257+
curl --proto "=https" \
258+
--tlsv1.2 \
259+
--silent \
260+
--location \
261+
--remote-name \
262+
"${_PEX_URL}"
253263
fingerprint="$(compute_sha256 "${python}" "pex")"
254264
if [[ "${_PEX_EXPECTED_SHA256}" != "${fingerprint}" ]]; then
255265
die "SHA256 of ${_PEX_URL} is not as expected. Aborting."
@@ -307,7 +317,12 @@ function get_version_for_sha {
307317

308318
# Retrieve the Pants version associated with this commit.
309319
local pants_version
310-
pants_version="$(curl --fail -sL "https://raw.githubusercontent.com/pantsbuild/pants/${sha}/src/python/pants/VERSION")"
320+
pants_version="$(curl --proto "=https" \
321+
--tlsv1.2 \
322+
--fail \
323+
--silent \
324+
--location \
325+
"https://raw.githubusercontent.com/pantsbuild/pants/${sha}/src/python/pants/VERSION")"
311326

312327
# Construct the version as the release version from src/python/pants/VERSION, plus the string `+gitXXXXXXXX`,
313328
# where the XXXXXXXX is the first 8 characters of the SHA.
@@ -342,9 +357,11 @@ function bootstrap_pants {
342357
(
343358
scrub_PEX_env_vars
344359
# shellcheck disable=SC2086
345-
"${python}" "${virtualenv_path}" --no-download "${staging_dir}/install" && \
346-
"${staging_dir}/install/bin/pip" install -U pip && \
347-
"${staging_dir}/install/bin/pip" install ${maybe_find_links} --progress-bar off "${pants_requirement}"
360+
"${python}" "${virtualenv_path}" --quiet --no-download "${staging_dir}/install" && \
361+
# Grab the latest pip, but don't advance setuptools past 58 which drops support for the
362+
# `setup` kwarg `use_2to3` which Pants 1.x sdist dependencies (pystache) use.
363+
"${staging_dir}/install/bin/pip" install --quiet -U pip "setuptools<58" && \
364+
"${staging_dir}/install/bin/pip" install ${maybe_find_links} --quiet --progress-bar off "${pants_requirement}"
348365
) && \
349366
ln -s "${staging_dir}/install" "${staging_dir}/${target_folder_name}" && \
350367
mv "${staging_dir}/${target_folder_name}" "${bootstrapped}" && \

0 commit comments

Comments
 (0)