Skip to content

Commit 2564fa4

Browse files
Update building from source instructions (Qiskit/qiskit-metapackage#1439)
* Update building from source instructions With Qiskit#7658 and Qiskit#7702 not far behind the requiremetns for building terra from source will be changed. A C++ compiler is no longer required and instead a rust compiler is needed. This commit updates the instructions on building from source and also removes so old out of date notes from the document at the same time. * Apply suggestions from code review * Consistently capitalise "Rust" * Add section on modifying rust extension * Fix typos * Empty-Commit to retrigger ci after outage Co-authored-by: Jake Lishman <jake@binhbar.com>
1 parent 7fcf98a commit 2564fa4

1 file changed

Lines changed: 29 additions & 66 deletions

File tree

docs/contributing_to_qiskit.rst

Lines changed: 29 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -700,12 +700,6 @@ from system-wide packages. This way, we avoid inadvertently becoming dependent o
700700
particular system configuration. For developers, this also makes it easy to maintain multiple
701701
environments (e.g. one per supported Python version, for older versions of Qiskit, etc.).
702702

703-
.. note::
704-
705-
**M1 Mac users:** Some Qiskit dependencies may not yet be available in PyPI. Until they are,
706-
Conda is recommended.
707-
708-
709703
.. tabbed:: Python venv
710704

711705
All Python versions supported by Qiskit include built-in virtual environment module
@@ -750,39 +744,17 @@ environments (e.g. one per supported Python version, for older versions of Qiski
750744
Installing Terra from Source
751745
============================
752746

753-
Installing from source requires that you have a C++ compiler on your system that supports
754-
C++11.
755-
756-
757-
.. tabbed:: Compiler for Linux
758-
759-
On most Linux platforms, the necessary GCC compiler is already installed.
760-
761-
.. tabbed:: Compiler for macOS
762-
763-
If you use macOS, you can install the Clang compiler by installing XCode.
764-
Check if you have XCode and Clang installed by opening a terminal window and entering the
765-
following.
766-
767-
.. code:: sh
768-
769-
clang --version
770-
771-
Install XCode and Clang by using the following command.
772-
773-
.. code:: sh
774-
775-
xcode-select --install
776-
777-
.. tabbed:: Compiler for Windows
747+
Installing from source requires that you have the Rust compiler on your system.
748+
To install the Rust compiler the recommended path is to use rustup, which is
749+
a cross-platform Rust installer. To use rustup you can go to:
778750

779-
On Windows, it is easiest to install the Visual C++ compiler from the
780-
`Build Tools for Visual Studio 2017 <https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2017>`__.
781-
You can instead install Visual Studio version 2015 or 2017, making sure to select the
782-
options for installing the C++ compiler.
751+
https://rustup.rs/
783752

753+
which will provide instructions for how to install rust on your platform.
754+
Besides rustup there are
755+
`other installation methods <https://forge.rust-lang.org/infra/other-installation-methods.html>`__ available too.
784756

785-
Once the compilers are installed, you are ready to install Qiskit Terra.
757+
Once the Rust compiler is installed, you are ready to install Qiskit Terra.
786758

787759
1. Clone the Terra repository.
788760

@@ -796,19 +768,13 @@ Once the compilers are installed, you are ready to install Qiskit Terra.
796768
797769
cd qiskit-terra
798770
799-
3. Install the Python requirements libraries from your ``qiskit-terra`` directory.
800-
801-
.. code:: sh
802-
803-
pip install cython
804-
805-
4. If you want to run tests or linting checks, install the developer requirements.
771+
3. If you want to run tests or linting checks, install the developer requirements.
806772

807773
.. code:: sh
808774
809775
pip install -r requirements-dev.txt
810776
811-
5. Install ``qiskit-terra``.
777+
4. Install ``qiskit-terra``.
812778

813779
.. code:: sh
814780
@@ -821,31 +787,32 @@ project don't require a reinstall to be applied, you can do this with:
821787
822788
pip install -e .
823789
824-
You can then run the code examples after installing Terra. You can
825-
run the example with the following command.
790+
Installing in editable mode will build the compiled extensions in debug mode
791+
without optimizations. This will affect the runtime performance of the compiled
792+
code. If you'd like to use editable mode and build the compiled code in release
793+
with optimizations enabled you can run:
826794

827795
.. code:: sh
828796
829-
python examples/python/using_qiskit_terra_level_0.py
797+
python setup.py build_rust --release --inplace
830798
799+
after you run pip and that will rebuild the binary in release mode.
831800

832-
.. note::
801+
If you are working on Rust code in Qiskit you will need to rebuild the extension
802+
code every time you make a local change. ``pip install -e .`` will only build
803+
the Rust extension when it's called, so any local changes you make to the Rust
804+
code after running pip will not be reflected in the installed package unless
805+
you rebuild the extension. You can leverage the above ``build_rust`` command to
806+
do this (with or without ``--release`` based on whether you want to build in
807+
debug mode or release mode).
833808

834-
If you do not intend to install any other components, qiskit-terra will
835-
emit a ``RuntimeWarning`` warning that both qiskit-aer and
836-
qiskit-ibmq-provider are not installed. This is done because
837-
users commonly intend to use the additional elements,
838-
but do not realize they are not installed, or that the installation
839-
of either Aer or the IBM Quantum Provider failed for some reason. If you wish
840-
to suppress these warnings, add::
809+
You can then run the code examples after installing Terra. You can
810+
run an example script with the following command.
841811

842-
import warnings
843-
warnings.filterwarnings('ignore', category=RuntimeWarning,
844-
module='qiskit')
812+
.. code:: sh
813+
814+
python examples/python/using_qiskit_terra_level_0.py
845815
846-
before any ``qiskit`` imports in your code. This will suppress the
847-
warning about the missing qiskit-aer and qiskit-ibmq-provider, but
848-
will continue to display any other warnings from qiskit or other packages.
849816
850817
.. _install-qiskit-aer:
851818

@@ -862,7 +829,7 @@ Installing Aer from Source
862829

863830
.. code:: sh
864831
865-
pip install cmake scikit-build cython
832+
pip install cmake scikit-build
866833
867834
After this, the steps to install Aer depend on which operating system you are
868835
using. Since Aer is a compiled C++ program with a Python interface, there are
@@ -906,10 +873,6 @@ universally depending on operating system.
906873
907874
.. tabbed:: macOS
908875

909-
.. note::
910-
**Mac M1 Users:** There are ongoing issues with building Aer for AArch64 macOS.
911-
See `#1286 <https://github.com/Qiskit/qiskit-aer/issues/1286>`__ for discussion and
912-
workarounds before continuing.
913876

914877
3. Install dependencies.
915878

0 commit comments

Comments
 (0)