Skip to content

fix: enforce python version #1345

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

Merged
merged 1 commit into from
Nov 12, 2024
Merged
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
25 changes: 19 additions & 6 deletions install/install_requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,39 @@ set -eou pipefail

# Install required python dependencies for developing
# Dependencies are defined in .pyproject.toml
PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE:-python}
if [[ -z ${CONDA_DEFAULT_ENV:-} ]] || [[ ${CONDA_DEFAULT_ENV:-} == "base" ]] || [[ ! -x "$(command -v python)" ]];
if [ -z "${PYTHON_EXECUTABLE:-}" ];
then
PYTHON_EXECUTABLE=python3
if [[ -z ${CONDA_DEFAULT_ENV:-} ]] || [[ ${CONDA_DEFAULT_ENV:-} == "base" ]] || [[ ! -x "$(command -v python)" ]];
then
PYTHON_EXECUTABLE=python3
fi
fi
echo "Using python executable: $PYTHON_EXECUTABLE"

PYTHON_SYS_VERSION="$($PYTHON_EXECUTABLE -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")"
# Check python version. Expect 3.10.x or 3.11.x
printf "import sys\nif sys.version_info.major != 3 or sys.version_info.minor < 10 :\n\tprint('Please use Python >=3.10');sys.exit(1)\n" | $PYTHON_EXECUTABLE
if [[ $? -ne 0 ]]
if ! $PYTHON_EXECUTABLE -c "
import sys
if sys.version_info < (3, 10) or sys.version_info >= (3, 12):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's wrong with 3.12? that seems to be what I have on my Mac and I don't think I've updated recently.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was based on the existing comments (which we just happen to not enforce)

That said, let's open up 3.12 since that's been looking fine to me

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I get for reviewing code after 1AM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t see any issues with 3.12. The main question is less about whether it works on 3.12 and more about which version the project currently aims to support. Opened a followup PR to address this.

sys.exit(1)
";
then
echo "Python version must be 3.10.x or 3.11.x. Detected version: $PYTHON_SYS_VERSION"
exit 1
fi

if [[ "$PYTHON_EXECUTABLE" == "python" ]];
then
PIP_EXECUTABLE=pip
else
elif [[ "$PYTHON_EXECUTABLE" == "python3" ]];
then
PIP_EXECUTABLE=pip3
else
PIP_EXECUTABLE=pip${PYTHON_SYS_VERSION}
fi

echo "Using pip executable: $PIP_EXECUTABLE"

#
# First install requirements in install/requirements.txt. Older torch may be
# installed from the dependency of other models. It will be overridden by
Expand Down
Loading