Qiskit / qiskit-aer

Aer is a high performance simulator for quantum circuits that includes noise models
https://qiskit.github.io/qiskit-aer/
Apache License 2.0
502 stars 361 forks source link

Aer is not compatible with Conan 2.0 API #1730

Open hhorii opened 1 year ago

hhorii commented 1 year ago

Informations

What is the current behavior?

When Conan 2.0 is used to compile Aer, conan command fails with following message:

conan install: error: unrecognized arguments: -e=CONAN_CMAKE_PROGRAM=/tmp/pip-build-env-2heyx8vq/overlay/lib/python3.11/site-packages/cmake/data/bin/cmake

Steps to reproduce the problem

  1. Install the latest conan
  2. Build Aer

What is the expected behavior?

Install finishes without errors.

Suggested solutions

Migrate Conan from 1.X to 2.X.

mdepasca commented 1 year ago

Same issue here

hhorii commented 1 year ago

One of the reasons is an environment variable CONAN_CMAKE_PROGRAM is set here: https://github.com/Qiskit/qiskit-aer/blob/ce9a8605545c671b653c07562d8283ca98fc951b/cmake/conan_utils.cmake#L25

CONAN_CMAKE_PROGRAM is not available in 2.0

hhorii commented 1 year ago

CONAN_CMAKE_PROGRAM was introduced here to solve compilation if cmake is not installed in the system and is installed on the fly. https://github.com/Qiskit/qiskit-aer/pull/777

I'm guessing that this issue may be resolved with Conan 2.0. So, just taking CONAN_CMAKE_PROGRAM may resolve this issue.

This is related discussion: https://github.com/conan-io/conan/issues/12701#issuecomment-1349941926

kechen666 commented 1 year ago

Thank you for raising this issue. Same issue I met today.

The environment is:

I run the python ./setup.py bdist_wheel to build the Aer, but get:

conan install: error: unrecognized arguments: -e=CONAN_CMAKE_PROGRAM=D:/anaconda/envs/ibm-qiskit/Lib/site-packages/cmake/data/bin/cmake.exe

Conan2.x did not find support for the conan install -eparameter. Because I am not good at cmake and conan, I only can deal with it by installing the conan1.x: pip uninstall conan pip install conan==1.*

I hope someone can deal with it in cmake\conan_utils.cmake and update the CONTRIBUTING.md.

In addition, I also found that according to the current installation tutorial, the pybind11 library has not been installed and needs to be installed through pip install pybind11.

JanLahmann commented 1 year ago

Same issue, when installing Aer on Raspberry Pi. pip install qiskit breaks with

conan install: error: unrecognized arguments: -e=CONAN_CMAKE_PROGRAM=/tmp/pip-build-env-tojhgqm2/overlay/lib/python3.9/site-packages/cmake/data/bin/cmake

Building from current GitHub source (including #1729 ) works well.

The workaround mentioned above (https://github.com/Qiskit/qiskit-aer/issues/1730#issuecomment-1443461176) did not work to build Aer 0.11.2 on Raspberry Pi OS. Somehow the install procedure does not use the pre-installed Conan 1.x, but seems to force an install of Conan 2.x. Is there a workaround to build current (0.11.2) and previous versions of Aer?

kechen666 commented 1 year ago

I am sorry that I confuse you. The pip to install Conan means that you should do that.

If you use the pip install ., which means you will reinstall the conan by pyproject.toml. Newer versions of pip will use the pyproject.toml file instead of set.py to build your environment. If you want to understand more, you can get something from this Build System Interface.

I used the pip install conan==1.59.0 and changed the pyproject.toml file.

[build-system]
requires = [
  "setuptools",
  "wheel",
  "conan==1.59.0",
    .....
]

Then you will install the conan 1.59.0 instead of forcing an install of conan 2.x. This is the easy way to deal with it.

hhorii commented 1 year ago

@JanLahmann Current pyproject.toml is set as follows: https://github.com/Qiskit/qiskit-aer/blob/897e51e7a697a57404e9b6b5b92bfca1ede191cf/pyproject.toml#L5

I guess that your pip install qiskit downloadded source codes of qiskit-aer 0.11.2, which try to use latest of conan. Please install qiskit-aer from main branch with conan 1.X and then run pip install qiskit.

0.12.0 will be released in this week. After the release, I believe that, pip install qiskit will work with compilation of source codes of qiskit-aer 0.12.

JanLahmann commented 1 year ago

This thread was very helpful to me!

I actually implemented the solution you described and automated the Qiskit Aer install on Raspberry Pi (for Aer 0.11.2 and 0.11.0 so far).

This is the code snipped used:

# install current version of rust
curl -o get_rustup.sh -s https://sh.rustup.rs
sh ./get_rustup.sh -y
source $HOME/.cargo/env

# workaround to force conan v1.x
git clone https://github.com/Qiskit/qiskit-aer/ --branch 0.11.2
cd qiskit-aer
sed -i "s/conan>=1.40.0/conan<2.0.0/" pyproject.toml
pip install --prefer-binary . 

FYI, this is being used as part of the "RasQberry" project, which builds a functional model of IBM Quantum System One, running Qiskit (Aer) on a Raspberry Pi that is integrated into a 3D printed housing that is modelled after the IBM Quantum System One, see http://rasqberry.org and https://www.youtube.com/watch?v=LZZDI9oBFN8

JanLahmann commented 1 year ago

Please install qiskit-aer from main branch with conan 1.X and then run pip install qiskit.

0.12.0 will be released in this week. After the release, I believe that, pip install qiskit will work with compilation of source codes of qiskit-aer 0.12.

Yes, I tried that and it works well. Good to hear that Aer 0.12.0 will be released soon.