Skip to content

Use python3 as interpreter instead of python#1326

Closed
mhucka wants to merge 1 commit into
quantumlib:mainfrom
mhucka:use-python3
Closed

Use python3 as interpreter instead of python#1326
mhucka wants to merge 1 commit into
quantumlib:mainfrom
mhucka:use-python3

Conversation

@mhucka
Copy link
Copy Markdown
Collaborator

@mhucka mhucka commented Jun 2, 2026

Style guidances and our own experiences with Python portability are such that invocations of python should be changed to use python3.

@mhucka mhucka marked this pull request as ready for review June 3, 2026 00:04
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates various scripts, configuration files, and documentation to explicitly invoke python3 instead of python. The feedback recommends reverting the changes inside virtual environments back to using the canonical bin/python executable, as it is more portable and guaranteed to exist across different platforms and virtualenv implementations compared to the bin/python3 symlink.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

echo "Working in a fresh virtualenv at ${tmp_dir}/${PYTHON_VERSION}"
virtualenv --quiet "${tmp_dir}/${PYTHON_VERSION}"
"${tmp_dir}/${PYTHON_VERSION}/bin/python" -m pip install --quiet --upgrade pip
"${tmp_dir}/${PYTHON_VERSION}/bin/python3" -m pip install --quiet --upgrade pip
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Inside a virtual environment, the canonical and guaranteed executable is always bin/python. While bin/python3 is often created as a symlink, it is not strictly guaranteed by all virtualenv/venv implementations or platforms. Since the virtual environment already isolates the Python interpreter to the correct version, using bin/python is safer and avoids potential issues with missing symlinks.

Suggested change
"${tmp_dir}/${PYTHON_VERSION}/bin/python3" -m pip install --quiet --upgrade pip
"${tmp_dir}/${PYTHON_VERSION}/bin/python" -m pip install --quiet --upgrade pip

Comment on lines +79 to +80
"${tmp_dir}/${PYTHON_VERSION}/bin/python3" -c "import openfermion; print(openfermion.FermionOperator((1, 1)))"
"${tmp_dir}/${PYTHON_VERSION}/bin/python3" -c "import openfermion; print(openfermion.QubitOperator((1, 'X')))"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

As with the pip installation step, using the canonical bin/python executable inside the virtual environment is safer and more portable than relying on the bin/python3 symlink.

Suggested change
"${tmp_dir}/${PYTHON_VERSION}/bin/python3" -c "import openfermion; print(openfermion.FermionOperator((1, 1)))"
"${tmp_dir}/${PYTHON_VERSION}/bin/python3" -c "import openfermion; print(openfermion.QubitOperator((1, 'X')))"
"${tmp_dir}/${PYTHON_VERSION}/bin/python" -c "import openfermion; print(openfermion.FermionOperator((1, 1)))"
"${tmp_dir}/${PYTHON_VERSION}/bin/python" -c "import openfermion; print(openfermion.QubitOperator((1, 'X')))"

@mhucka mhucka marked this pull request as draft June 3, 2026 00:07
@mhucka mhucka closed this Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant