Skip to content

Commit

Permalink
fix: Refine install-dev.sh and the ./py wrapper (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregataa committed Jun 9, 2022
1 parent 5e80585 commit 38db104
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions changes/438.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Refine `scripts/install-dev.sh`, `./py`, and `./pants-local` scripts to better detect and use an existing CPython available in the host
2 changes: 1 addition & 1 deletion py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if [ ! -d dist/export/python/virtualenvs/python-default ]; then
>&2 echo "Please run './pants export ::' first and try again."
exit 1
fi
PYTHON_VERSION=$(cat pants.toml | python -c 'import sys,re;m=re.search("CPython==([^\"]+)", sys.stdin.read());print(m.group(1) if m else sys.exit(1))')
PYTHON_VERSION=$(cat pants.toml | python3 -c 'import sys,re;m=re.search("CPython==([^\"]+)", sys.stdin.read());print(m.group(1) if m else sys.exit(1))')
if [ $? -ne 0 ]; then
>&2 echo "Could not read the target CPython interpreter version from pants.toml"
exit 1
Expand Down
12 changes: 7 additions & 5 deletions scripts/install-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ else
show_info "Please send us a pull request or file an issue to support your environment!"
exit 1
fi
if [ $(has_python "python") -eq 1 ]; then
bpython=$(which "python")
elif [ $(has_python "python3") -eq 1 ]; then
if [ $(has_python "python3") -eq 1 ]; then
bpython=$(which "python3")
elif [ $(has_python "python") -eq 1 ]; then
bpython=$(which "python")
elif [ $(has_python "python2") -eq 1 ]; then
bpython=$(which "python2")
else
Expand Down Expand Up @@ -444,7 +444,7 @@ echo "${LGREEN}Backend.AI one-line installer for developers${NC}"
# Check prerequisites
show_info "Checking prerequisites and script dependencies..."
install_script_deps
$bpython -m pip --disable-pip-version-check install -q requests requests_unixsocket
$bpython -m pip --disable-pip-version-check install -q requests requests-unixsocket
$bpython scripts/check-docker.py
if [ $? -ne 0 ]; then
exit 1
Expand Down Expand Up @@ -521,7 +521,9 @@ show_info "Using the current working-copy directory as the installation path..."
mkdir -p ./wheelhouse
if [ "$DISTRO" = "Darwin" -a "$(uname -p)" = "arm" ]; then
show_info "Prebuild grpcio wheels for Apple Silicon..."
pyenv virtualenv "${PYTHON_VERSION}" tmp-grpcio-build
if [ -z "$(pyenv virtualenvs | grep "tmp-grpcio-build")" ]; then
pyenv virtualenv "${PYTHON_VERSION}" tmp-grpcio-build
fi
pyenv shell tmp-grpcio-build
if [ $(python -c 'import sys; print(1 if sys.version_info >= (3, 10) else 0)') -eq 0 ]; then
# ref: https://github.com/grpc/grpc/issues/25082
Expand Down
2 changes: 2 additions & 0 deletions tools/pants-local
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ fi
if [ -z "$PY" ]; then
echo "The Python version for source-built Pants is not configured in ./.pants.env"
exit 1
else
export PY=$PY
fi
PANTS_SOURCE="${PANTS_SOURCE:-$(pwd)/tools/pants-src}"

Expand Down

0 comments on commit 38db104

Please sign in to comment.