Install the Python API¶
Prerequisites¶
First, create a minimal environment with only Python installed in it. Use Python virtual environments.
python3 -m venv /path/to/virtual/environment
Activate your new environment.
source /path/to/virtual/environment/bin/activate
There are two primary ways to install this package: from PyPI or from source. The preferred method is to install from PyPI:
Install from PyPI¶
pip install qiskit-fermions
Install from source¶
If you plan to develop in the repository you should install from source.
First, Qiskit must be installed in the same Python environment that you install
qiskit-fermions in. The simplest way to do this is from PyPI, but you can
install Qiskit from source if you want to.
$ pip install qiskit
Next, clone the qiskit-fermions repository.
git clone git@github.com:Qiskit/qiskit-fermions.git
Now, install the Rust toolchain, upgrade pip, and enter the repository. Refer to the Rust documentation for instructions on installing the toolchain.
### <INSTALL RUST HERE> ###
pip install --upgrade pip
cd qiskit-fermions
Install the remaining build dependencies.
If you plan on developing in the repository, install the dev dependencies.
pip install --group build
pip install --group dev # optional
The next step is to install qiskit-fermions to the virtual environment.
pip install .
Hint
You can also perform an editable install while still compiling the
underlying Rust crate in release mode:
SETUPTOOLS_RUST_CARGO_PROFILE=release pip install -e .
Hint
Some features rely on optional dependencies. To install all of them,
use the all extra:
pip install ".[all]"
Refer to the [project.optional-dependencies] section of pyproject.toml
to see which dependency groups are available.
You can optionally verify that the installation was successful. The simplest
test is to try and import one of the classes provided by the qiskit-fermions
package, as in the following example:
python -c "from qiskit_fermions.circuit import FermionicCircuit"
If this completes successfully, your installation worked.
Hint
You can also run the entire Python test suite:
pip install --group test
make testpython
To additionally run the tests that exercise optional dependencies, install
the extras and use the testoptional target:
pip install -e ".[all]"
make testoptional