Skip to content
Closed
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ jobs:
cache-dependency-path: ${{env.python_dep_files}}

- name: Upgrade pip
run: python -m pip install --upgrade pip
run: python3 -m pip install --upgrade pip

- name: Install requirements
env:
Expand Down Expand Up @@ -214,7 +214,7 @@ jobs:
cache-dependency-path: ${{env.python_dep_files}}

- name: Upgrade pip
run: python -m pip install --upgrade pip
run: python3 -m pip install --upgrade pip

- name: Install requirements
run: |
Expand Down Expand Up @@ -249,7 +249,7 @@ jobs:
cache-dependency-path: ${{env.python_dep_files}}

- name: Upgrade pip
run: python -m pip install --upgrade pip
run: python3 -m pip install --upgrade pip

- name: Install requirements
run: |
Expand Down Expand Up @@ -280,7 +280,7 @@ jobs:
python-version: ${{env.python_compat_ver}}

- name: Upgrade pip
run: python -m pip install --upgrade pip
run: python3 -m pip install --upgrade pip

- name: Install requirements
run: pip install -r dev_tools/requirements/max_compat/pytest-max-compat.env.txt
Expand Down Expand Up @@ -310,7 +310,7 @@ jobs:
cache-dependency-path: ${{env.python_dep_files}}

- name: Upgrade pip
run: python -m pip install --upgrade pip
run: python3 -m pip install --upgrade pip

- name: Install requirements
run: pip install -r dev_tools/requirements/envs/pytest.env.txt
Expand Down Expand Up @@ -441,7 +441,7 @@ jobs:
cache-dependency-path: ${{env.python_dep_files}}

- name: Upgrade pip
run: python -m pip install --upgrade pip
run: python3 -m pip install --upgrade pip

- name: Install requirements
run: pip install -r dev_tools/requirements/envs/pytest.env.txt
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ To install the latest version of OpenFermion in development mode, run the follow
```shell
git clone https://github.com/quantumlib/OpenFermion
cd OpenFermion
python -m pip install -e .
python3 -m pip install -e .
```

## Plugins
Expand Down
2 changes: 1 addition & 1 deletion check/pytest-and-incremental-coverage
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ check/pytest . \
pytest_result=$?

# Analyze coverage files.
PYTHONPATH="$(pwd)" python dev_tools/check_incremental_coverage_annotations.py "${rev}"
PYTHONPATH="$(pwd)" python3 dev_tools/check_incremental_coverage_annotations.py "${rev}"
cover_result=$?

# Clean up generated coverage files.
Expand Down
2 changes: 1 addition & 1 deletion dev_tools/check_incremental_coverage_annotations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

# Copyright 2018 Google LLC
#
Expand Down
2 changes: 1 addition & 1 deletion dev_tools/packaging/produce-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ fi

# Python wheel.
echo -e "${GREEN}Producing Python package files...${RESET}"
python -m build --outdir "$out_dir"
python3 -m build --outdir "$out_dir"

echo -e "${GREEN}Finished – output is in $out_dir${RESET}"
6 changes: 3 additions & 3 deletions dev_tools/packaging/verify-published-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ PYTHON_VERSION=python3
RUNTIME_DEPS_FILE="${REPO_ROOT}/dev_tools/requirements/envs/pytest.env.txt"
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


# Install package.
if [ "${PYPI_REPO_NAME}" == "TEST" ]; then
Expand All @@ -76,8 +76,8 @@ echo Installing "${PROJECT_NAME}==${PROJECT_VERSION} from ${PYPI_REPO_NAME} pypi

# Check that code runs without dev deps.
echo Checking that code executes
"${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')))"
"${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')))"
Comment on lines +79 to +80
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')))"


# Run basic tests.
echo Installing Pytest
Expand Down
2 changes: 1 addition & 1 deletion dev_tools/requirements/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ COPY deps/ ./deps/
COPY run-pip-compiles.py ./

ARG PLATFORM="default"
RUN python run-pip-compiles.py --platform $PLATFORM
RUN python3 run-pip-compiles.py --platform $PLATFORM
Loading