Skip to content

Commit

Permalink
Invoke pip install by module not executable (#9972)
Browse files Browse the repository at this point in the history
On some OSes and configurations (usually Windows), there can be problems
when a binary attempts to one that is in use, especially itself.  For
this reason, it is more reliable to use `python -m pip install ...` than
`pip install`.  We have seen some CI failures on Windows due to `pip`
failing to update itself because of the direct-executable `pip install`
form.

(cherry picked from commit 51fdb3c)

# Conflicts:
#	.azure/lint-linux.yml
#	.azure/test-linux.yml
#	.azure/test-macos.yml
#	.azure/test-windows.yml
#	.azure/tutorials-linux.yml
#	.github/workflows/coverage.yml
#	.github/workflows/randomized_tests.yml
#	.github/workflows/slow.yml
  • Loading branch information
jakelishman authored and mergify[bot] committed Apr 17, 2023
1 parent 32281ad commit 6842445
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .azure/docs-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- bash: |
set -e
python -m pip install --upgrade pip setuptools wheel
pip install -U "tox<4.4.0"
python -m pip install -U "tox<4.4.0"
sudo apt-get update
sudo apt-get install -y graphviz
displayName: 'Install dependencies'
Expand Down
9 changes: 9 additions & 0 deletions .azure/lint-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,19 @@ jobs:
python -m pip install --upgrade pip setuptools wheel virtualenv
virtualenv test-job
source test-job/bin/activate
<<<<<<< HEAD
pip install -U -r requirements.txt -r requirements-dev.txt -c constraints.txt
pip install -U -c constraints.txt -e .
pip install -U "qiskit-aer" -c constraints.txt
pip install -e .
=======
python -m pip install -U pip setuptools wheel
python -m pip install -U \
-c constraints.txt \
-r requirements.txt \
-r requirements-dev.txt \
-e .
>>>>>>> 51fdb3c86 (Invoke `pip install` by module not executable (#9972))
displayName: 'Install dependencies'
env:
SETUPTOOLS_ENABLE_FEATURES: "legacy-editable"
Expand Down
40 changes: 38 additions & 2 deletions .azure/test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,56 @@ jobs:
- bash: |
set -e
source test-job/bin/activate
<<<<<<< HEAD
pip install -U -r requirements.txt -r requirements-dev.txt -c constraints.txt
=======
python -m pip install -U pip setuptools wheel
>>>>>>> 51fdb3c86 (Invoke `pip install` by module not executable (#9972))
# Install setuptools-rust for building sdist
pip install -U -c constraints.txt setuptools-rust
python -m pip install -U -c constraints.txt setuptools-rust
python setup.py sdist
<<<<<<< HEAD
pip install -U -c constraints.txt dist/qiskit-terra*.tar.gz
=======
python -m pip install -U \
-c constraints.txt \
-r requirements.txt \
-r requirements-dev.txt \
dist/qiskit-terra*.tar.gz
>>>>>>> 51fdb3c86 (Invoke `pip install` by module not executable (#9972))
displayName: "Install Terra from sdist"

- ${{ if eq(parameters.installFromSdist, false) }}:
- bash: |
set -e
source test-job/bin/activate
<<<<<<< HEAD
pip install -U -r requirements.txt -r requirements-dev.txt -c constraints.txt
pip install -U -c constraints.txt -e .
=======
python -m pip install -U \
-c constraints.txt \
-r requirements.txt \
-r requirements-dev.txt \
-e .
>>>>>>> 51fdb3c86 (Invoke `pip install` by module not executable (#9972))
displayName: "Install Terra directly"
env:
SETUPTOOLS_ENABLE_FEATURES: "legacy-editable"

- bash: |
set -e
source test-job/bin/activate
<<<<<<< HEAD
pip install -U "cplex;python_version < '3.11'" "qiskit-aer" "z3-solver" -c constraints.txt
=======
python -m pip install -U \
-c constraints.txt \
"cplex ; python_version < '3.11'" \
"qiskit-aer" \
"tweedledum ; python_version < '3.11'" \
"z3-solver"
>>>>>>> 51fdb3c86 (Invoke `pip install` by module not executable (#9972))
mkdir -p /tmp/terra-tests
cp -r test /tmp/terra-tests/.
cp .stestr.conf /tmp/terra-tests/.
Expand All @@ -107,7 +136,7 @@ jobs:
set -e
source test-job/bin/activate
cp tools/subunit_to_junit.py /tmp/terra-tests/.
pip install -U junitxml
python -m pip install -U junitxml
pushd /tmp/terra-tests
mkdir -p junit
stestr last --subunit | ./subunit_to_junit.py -o junit/test-results.xml
Expand Down Expand Up @@ -162,8 +191,15 @@ jobs:
- bash: |
set -e
virtualenv image_tests
<<<<<<< HEAD
image_tests/bin/pip install -U -r requirements.txt -c constraints.txt
image_tests/bin/pip install -U -c constraints.txt -e ".[visualization]"
=======
image_tests/bin/python -m pip install -U \
-c constraints.txt \
-r requirements.txt \
-e ".[visualization]"
>>>>>>> 51fdb3c86 (Invoke `pip install` by module not executable (#9972))
sudo apt-get update
sudo apt-get install -y graphviz pandoc
image_tests/bin/pip check
Expand Down
11 changes: 10 additions & 1 deletion .azure/test-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,17 @@ jobs:
python -m pip install --upgrade pip setuptools wheel virtualenv
virtualenv test-job
source test-job/bin/activate
<<<<<<< HEAD
pip install -U -r requirements.txt -r requirements-dev.txt -c constraints.txt
pip install -U -c constraints.txt -e .
=======
python -m pip install -U pip setuptools wheel
python -m pip install -U \
-c constraints.txt \
-r requirements.txt \
-r requirements-dev.txt \
-e .
>>>>>>> 51fdb3c86 (Invoke `pip install` by module not executable (#9972))
pip check
displayName: 'Install dependencies'
env:
Expand All @@ -55,7 +64,7 @@ jobs:
- bash: |
set -e
source test-job/bin/activate
pip install -U junitxml
python -m pip install -U junitxml
mkdir -p junit
stestr last --subunit | tools/subunit_to_junit.py -o junit/test-results.xml
pushd .stestr
Expand Down
12 changes: 11 additions & 1 deletion .azure/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,19 @@ jobs:
python -m pip install --upgrade pip setuptools wheel virtualenv
virtualenv test-job
source test-job/Scripts/activate
<<<<<<< HEAD
pip install -r requirements.txt -r requirements-dev.txt -c constraints.txt
pip install -c constraints.txt -e .
pip install "z3-solver" -c constraints.txt
=======
python -m pip install -U pip setuptools wheel
python -m pip install -U \
-c constraints.txt \
-r requirements.txt \
-r requirements-dev.txt \
"z3-solver" \
-e .
>>>>>>> 51fdb3c86 (Invoke `pip install` by module not executable (#9972))
pip check
displayName: 'Install dependencies'
env:
Expand All @@ -59,7 +69,7 @@ jobs:
set -e
chcp.com 65001
source test-job/Scripts/activate
pip install -U junitxml
python -m pip install -U junitxml
mkdir -p junit
stestr last --subunit | python tools/subunit_to_junit.py -o junit/test-results.xml
pushd .stestr
Expand Down
19 changes: 19 additions & 0 deletions .azure/tutorials-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,29 @@ jobs:
- bash: |
set -e
git clone https://github.com/Qiskit/qiskit-tutorials --depth=1
<<<<<<< HEAD
python -m pip install --upgrade pip
pip install -U -r requirements.txt -r requirements-dev.txt -c constraints.txt
pip install -c constraints.txt -e .
pip install "qiskit-ibmq-provider" "qiskit-aer" "z3-solver" "networkx" "matplotlib>=3.3.0" sphinx nbsphinx sphinx_rtd_theme cvxpy -c constraints.txt
=======
python -m pip install --upgrade pip setuptools wheel
python -m pip install -U \
-c constraints.txt \
-r requirements.txt \
-r requirements-dev.txt \
"qiskit-ibmq-provider" \
"qiskit-aer" \
"z3-solver" \
"networkx" \
"matplotlib>=3.3.0" \
sphinx \
nbsphinx \
sphinx_rtd_theme \
"tweedledum ; python_version < '3.11'" \
cvxpy \
-e .
>>>>>>> 51fdb3c86 (Invoke `pip install` by module not executable (#9972))
sudo apt-get update
sudo apt-get install -y graphviz pandoc
pip check
Expand Down
4 changes: 2 additions & 2 deletions .azure/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ jobs:
- bash: |
set -e
python -m pip install --upgrade pip
pip install cibuildwheel==2.11.2
pip install -U twine
python -m pip install cibuildwheel==2.11.2
python -m pip install -U twine
cibuildwheel --output-dir wheelhouse .
- task: PublishBuildArtifacts@1
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,18 @@ jobs:
cargo install grcov
sudo apt-get install lcov
<<<<<<< HEAD
=======
# This is needed to support any requirements, particularly in the `optionals` set,
# that might not have 'pyproject.toml' files specifying their build requirements.
# Modern pip (23.1+) can error out if it doesn't have `wheel` and we ask for one
# of these legacy packages.
- name: Ensure basic build requirements
run: python -m pip install --upgrade pip setuptools wheel

>>>>>>> 51fdb3c86 (Invoke `pip install` by module not executable (#9972))
- name: Build and install qiskit-terra
run: pip install -e .
run: python -m pip install -e .
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-Cinstrument-coverage"
Expand All @@ -41,7 +51,7 @@ jobs:
- name: Generate unittest coverage report
run: |
set -e
pip install -r requirements-dev.txt qiskit-aer
python -m pip install -r requirements-dev.txt qiskit-aer
stestr run
# We set the --source-dir to '.' because we want all paths to appear relative to the repo
# root (we need to combine them with the Python ones), but we only care about `grcov`
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/randomized_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@ jobs:
python-version: '3.8'
- name: Install dependencies
run: |
<<<<<<< HEAD
pip install -U -r requirements.txt -c constraints.txt
pip install -U -r requirements-dev.txt coveralls -c constraints.txt
pip install -c constraints.txt -e .
pip install "qiskit-ibmq-provider" -c constraints.txt
pip install "qiskit-aer"
=======
python -m pip install -U pip setuptools wheel
python -m pip install -U -r requirements.txt -c constraints.txt
python -m pip install -U -r requirements-dev.txt coveralls -c constraints.txt
python -m pip install -c constraints.txt -e .
python -m pip install "qiskit-ibmq-provider" -c constraints.txt
python -m pip install "qiskit-aer"
>>>>>>> 51fdb3c86 (Invoke `pip install` by module not executable (#9972))
env:
SETUPTOOLS_ENABLE_FEATURES: "legacy-editable"
- name: Run randomized tests
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/slow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,18 @@ jobs:
python-version: '3.10'
- name: Install dependencies
run: |
<<<<<<< HEAD
pip install -U -r requirements.txt -c constraints.txt
pip install -U -r requirements-dev.txt -c constraints.txt
pip install -c constraints.txt -e .
pip install "qiskit-aer" "z3-solver" "cplex" -c constraints.txt
=======
python -m pip install -U pip setuptools wheel
python -m pip install -U -r requirements.txt -c constraints.txt
python -m pip install -U -r requirements-dev.txt -c constraints.txt
python -m pip install -c constraints.txt -e .
python -m pip install "qiskit-aer" "z3-solver" "cplex" -c constraints.txt
>>>>>>> 51fdb3c86 (Invoke `pip install` by module not executable (#9972))
env:
SETUPTOOLS_ENABLE_FEATURES: "legacy-editable"
- name: Run all tests including slow
Expand Down

0 comments on commit 6842445

Please sign in to comment.