Repository: Qiskit/qiskit

Issue:
Installing `qiskit-terra[bip-mapper]` fails on Python 3.9
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues -->

### Information

- **Qiskit Terra version**: 0.18.0 (released)
- **Python version**: 3.9
- **Operating system**: certainly Mac, probably any

### What is the current behavior?

The Terra extra 'bip_mapper' requirements cannot be satisfied on Python 3.9, which means `pip install 'qiskit-terra[all]>=0.18'` cannot succeed.

### Steps to reproduce the problem

```bash
jake@ninetales$ python -mpip install qiskit >/dev/null
jake@ninetales$ python --version
Python 3.9.5
jake@ninetales$ python -c 'import qiskit; print(qiskit.__version__)'
0.18.0
jake@ninetales$ python -mpip install -U 'qiskit-terra[bip-mapper]>=0.18'
Requirement already satisfied: qiskit-terra[bip-mapper]>=0.18 in ./.miniconda3/envs/tmp/lib/python3.9/site-packages (0.18.0)
Requirement already satisfied: jsonschema>=2.6 in ./.miniconda3/envs/tmp/lib/python3.9/site-packages (from qiskit-terra[bip-mapper]>=0.18) (3.2.0)
Requirement already satisfied: python-constraint>=1.4 in ./.miniconda3/envs/tmp/lib/python3.9/site-packages (from qiskit-terra[bip-mapper]>=0.18) (1.4.0)
Requirement already satisfied: retworkx>=0.9.0 in ./.miniconda3/envs/tmp/lib/python3.9/site-packages (from qiskit-terra[bip-mapper]>=0.18) (0.9.0)
Requirement already satisfied: dill>=0.3 in ./.miniconda3/envs/tmp/lib/python3.9/site-packages (from qiskit-terra[bip-mapper]>=0.18) (0.3.4)
Requirement already satisfied: scipy>=1.4 in ./.miniconda3/envs/tmp/lib/python3.9/site-packages (from qiskit-terra[bip-mapper]>=0.18) (1.7.0)
Requirement already satisfied: sympy>=1.3 in ./.miniconda3/envs/tmp/lib/python3.9/site-packages (from qiskit-terra[bip-mapper]>=0.18) (1.8)
Requirement already satisfied: symengine>0.7 in ./.miniconda3/envs/tmp/lib/python3.9/site-packages (from qiskit-terra[bip-mapper]>=0.18) (0.7.2)
Requirement already satisfied: tweedledum<2.0,>=1.1 in ./.miniconda3/envs/tmp/lib/python3.9/site-packages (from qiskit-terra[bip-mapper]>=0.18) (1.1.0)
Requirement already satisfied: numpy>=1.17 in ./.miniconda3/envs/tmp/lib/python3.9/site-packages (from qiskit-terra[bip-mapper]>=0.18) (1.20.3)
Requirement already satisfied: python-dateutil>=2.8.0 in ./.miniconda3/envs/tmp/lib/python3.9/site-packages (from qiskit-terra[bip-mapper]>=0.18) (2.8.2)
Requirement already satisfied: psutil>=5 in ./.miniconda3/envs/tmp/lib/python3.9/site-packages (from qiskit-terra[bip-mapper]>=0.18) (5.8.0)
Requirement already satisfied: ply>=3.10 in ./.miniconda3/envs/tmp/lib/python3.9/site-packages (from qiskit-terra[bip-mapper]>=0.18) (3.11)
Requirement already satisfied: fastjsonschema>=2.10 in ./.miniconda3/envs/tmp/lib/python3.9/site-packages (from qiskit-terra[bip-mapper]>=0.18) (2.15.1)
Requirement already satisfied: docplex in ./.miniconda3/envs/tmp/lib/python3.9/site-packages (from qiskit-terra[bip-mapper]>=0.18) (2.21.207)
ERROR: Could not find a version that satisfies the requirement cplex; extra == "bip-mapper" (from qiskit-terra[bip-mapper]) (from versions: none)
ERROR: No matching distribution found for cplex; extra == "bip-mapper"
```


### What is the expected behavior?

The installation should succeed on Python 3.9 anyway, and raise a runtime error if the behaviour is used.


### Suggested solutions

Set the extra to have `; python<3.9` in its requirement.  Not certain if this has further knock-on effects. 



Discussion:
Yeah, CPLEX doesn't work on python 3.6 or python 3.9 on any platform, they also don't support 32bit platforms or aarch64. THe list of wheels is available at: https://pypi.org/project/cplex/#files

Resolving patch:
diff --git a/qiskit/transpiler/passes/routing/bip_mapping.py b/qiskit/transpiler/passes/routing/bip_mapping.py
--- a/qiskit/transpiler/passes/routing/bip_mapping.py
+++ b/qiskit/transpiler/passes/routing/bip_mapping.py
@@ -104,6 +104,7 @@ def __init__(
                 libname="bip-mapper",
                 name="BIP-based mapping pass",
                 pip_install="pip install 'qiskit-terra[bip-mapper]'",
+                msg="This may not be possible for all Python versions and OSes",
             )
         super().__init__()
         self.coupling_map = coupling_map
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -87,13 +87,9 @@
     "seaborn>=0.9.0",
     "pygments>=2.4",
 ]
-
-
 z3_requirements = [
     "z3-solver>=4.7",
 ]
-
-
 bip_requirements = ["cplex", "docplex"]
 
 
@@ -132,7 +128,10 @@
         "visualization": visualization_extras,
         "bip-mapper": bip_requirements,
         "crosstalk-pass": z3_requirements,
-        "all": visualization_extras + z3_requirements + bip_requirements,
+        # Note: 'all' does not include 'bip-mapper' because cplex is too fiddly and too little
+        # supported on various Python versions and OSes compared to Terra.  You have to ask for it
+        # explicitly.
+        "all": visualization_extras + z3_requirements,
     },
     project_urls={
         "Bug Tracker": "https://github.com/Qiskit/qiskit-terra/issues",


Test patch: