|
35 | 35 | echo "Using virtual environment at $venv"
|
36 | 36 | fi
|
37 | 37 |
|
38 |
| -# Check if Qiskit package is installed. If yes, exit successfully. |
39 |
| -if [[ -x "$python_path" ]]; then |
40 |
| - if "$python_path" -c "import qiskit" &>/dev/null; then |
41 |
| - echo "Qiskit is installed" |
42 |
| - exit 0 |
| 38 | + |
| 39 | +# Install package dependencies. |
| 40 | +declare -a packages=("qiskit" "matplotlib" "pylatexenc") |
| 41 | +for i in "${packages[@]}"; do |
| 42 | + # Check if the package is installed. If yes, exit successfully. |
| 43 | + if [[ -x "$python_path" ]]; then |
| 44 | + if "$python_path" -c "import $i" &>/dev/null; then |
| 45 | + echo "$i is installed" |
| 46 | + continue |
| 47 | + fi |
| 48 | + else |
| 49 | + echo "Error: failed to execute $python_path" |
| 50 | + exit 1 |
43 | 51 | fi
|
44 |
| -else |
45 |
| - echo "Error: failed to execute $python_path" |
46 |
| - exit 1 |
47 |
| -fi |
48 | 52 |
|
49 |
| -# Install Qiskit within the virtual environment using pip. |
50 |
| -if [[ -x "$pip_path" ]]; then |
51 |
| - echo "Installing Qiskit..." |
52 |
| - if "$pip_path" install --quiet qiskit; then |
53 |
| - echo "Successfully installed Qiskit" |
| 53 | + # Install package within the virtual environment using pip. |
| 54 | + if [[ -x "$pip_path" ]]; then |
| 55 | + echo "Installing $i..." |
| 56 | + if "$pip_path" install --quiet "$i"; then |
| 57 | + echo "Successfully installed $i" |
| 58 | + else |
| 59 | + echo "Error: failed to install $i" |
| 60 | + continue |
| 61 | + fi |
54 | 62 | else
|
55 |
| - echo "Error: failed to install Qiskit" |
| 63 | + echo "Error: failed to execute $pip_path" |
56 | 64 | exit 1
|
57 | 65 | fi
|
58 |
| -else |
59 |
| - echo "Error: failed to execute $pip_path" |
60 |
| - exit 1 |
61 |
| -fi |
| 66 | +done |
0 commit comments