CQCL / tket

Source code for the TKET quantum compiler, Python bindings and utilities
https://tket.quantinuum.com/
Apache License 2.0
248 stars 48 forks source link

Dependencies between the libraries when building with conan #1529

Open zrho opened 1 month ago

zrho commented 1 month ago

When attempting to build the conan dependencies from scratch, the tkassert library can not find the previously compiled tklog library when running the following (as per the build instructions):

conan create libs/tklog --build=missing -o "boost/*":header_only=True
conan create libs/tkassert --build=missing -o "boost/*":header_only=True

The error message is as follows:

======== Computing dependency graph ========
tklog/0.3.3@tket/stable: Not found in local cache, looking in remotes...
tklog/0.3.3@tket/stable: Checking remote: conancenter
Graph root
    cli
Requirements
    tkassert/0.3.4#2cfc80038a75060c846725e057731488 - Cache
ERROR: Package 'tklog/0.3.3@tket/stable' not resolved: Unable to find 'tklog/0.3.3@tket/stable' in remotes.

Note that this only occurs when the precompiled tket remote is not set; otherwise conan will not find the locally compiled tklog but will happily use the published one.

This can be fixed by adding the user and channel field to the conanfile for tklog as follows:

class TklogConan(ConanFile):
       name = "tklog"
       version = "0.3.3"
       user = "tket"
       channel = "stable"
       # ... rest of the file remains the same

Similar changes would also be required for the conanfiles of the other libraries.

I have never used conan before, so I don't know if that change would have unintended consequences.

A workaround is to use the CLI arguments --user tket --channel stable when using conan create for the libraries. I see that this has been indicated in the docs for building the main tket library in https://github.com/CQCL/tket/pull/1303

cqc-alec commented 4 weeks ago

I think that the "workaround" is actually the right answer. We should fix the documentation in libs/README.md to reflect this.

zrho commented 2 weeks ago

The tests for the libraries require the library without the @tket/stable suffix, while the libraries and tket itself require each other with the @tket/stable suffix. So when a library is built using --user tket --channel stable, so that it can be found as a dependency, it in turn can no longer be found by its own test.