mpusz / mp-units

The quantities and units library for C++
https://mpusz.github.io/mp-units/
MIT License
998 stars 79 forks source link

mpunits with conan 2.0 #440

Closed correaa closed 1 year ago

correaa commented 1 year ago

Hi, I don't know if this happened before because I used it only a couple of times and only once successfully.

Today, in my Fedora 37, I started from scratch and pip install conan seem to have installed Conan 2.0 (instead of 1.5x as I remember doing).

Then, when I try to use mpunits (defined as a dependency in a conanfile.txt) I get the following message, which seems to say mp-units' recipe is not compatible with Conan 2.

$ conan --version
Conan version 2.0.0
[correaa@PROART build]$ conan install .. -pr:b=default -s compiler.cppstd=20 -b=missing

======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=20
compiler.libcxx=libstdc++11
compiler.version=12
os=Linux

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=12
os=Linux

======== Computing dependency graph ========
Graph root
    conanfile.txt: /home/correaa/boron_hydride/ground_state/conanfile.txt
*********************************************************
Recipe 'mp-units/0.7.0' seems broken.
It is possible that this recipe is not Conan 2.0 ready
If the recipe comes from ConanCenter check: https://conan.io/cci-v2.html
If it is your recipe, check it is updated to 2.0
*********************************************************

ERROR: Package 'mp-units/0.7.0' not resolved: mp-units/0.7.0: Cannot load recipe.
Error loading conanfile at '/home/correaa/.conan2/p/mp-unb5b48022c2a49/e/conanfile.py': Unable to load conanfile in /home/correaa/.conan2/p/mp-unb5b48022c2a49/e/conanfile.py
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/correaa/.conan2/p/mp-unb5b48022c2a49/e/conanfile.py", line 1, in <module>
    from conans import ConanFile, CMake, tools
ImportError: cannot import name 'ConanFile' from 'conans' (/home/correaa/.local/lib/python3.11/site-packages/conans/__init__.py)

Is there a workaround for this?

mpusz commented 1 year ago

Hi, unfortunately, it seems that while moving to Conan 2.0, the Conan team did not upgrade the mp-units recipe for now. See more at: https://github.com/conan-io/conan-center-index/discussions/16196. Filing an issue on ConanCenter could help. I will try to look into it also ASAP but I am now busy with other work 😢

mpusz commented 1 year ago

I provided fixes to ConanCenter here: https://github.com/conan-io/conan-center-index/pull/16252.

correaa commented 1 year ago

What are the chances, I started using conan and the same week they upgrade to 2.0 :rofl:

I worked around this by doing pip install conan==1.56.

mpusz commented 1 year ago

It seems that it might take a while for ConanCenter. In the meantime, you can use the same package from our's artifactory. The only difference is that I named it mp-unit/0.7.0@mpusz/stable to make sure it does not collide with the ConanCenter's one. In order to download it, you will need to add our artifactory to your local Conan client with:

conan remote add conan-mpusz https://mpusz.jfrog.io/artifactory/api/conan/conan-oss

See more in https://mpusz.github.io/units/usage.html#conan-cmake-live-at-head.

I hope it helps and that ConanCenter will soon catch up with all broken packages.

NAThompson commented 1 year ago

@mpusz : Just tried your workaround for the conan problem, but got:

======== Computing dependency graph ========
ERROR: mp-units/0.8.0@mpusz/testing: Error in requirements() method, line 110
    if self._use_libfmt:
while calling '_use_libfmt', line 84
    compiler == "Visual Studio" and version >= 17 and compiler.cppstd == 23
    ConanException: Invalid setting 'Visual Studio' is not a valid 'settings.compiler' value.
Possible values are ['sun-cc', 'gcc', 'msvc', 'clang', 'apple-clang', 'intel-cc', 'qcc', 'mcst-lcc']
Read "http://docs.conan.io/en/latest/faq/troubleshooting.html#error-invalid-setting"
mpusz commented 1 year ago

Yes, 0.8.0 still does not work, and unfortunately, I cannot do anything about that. We have to wait for Conan 2.0.1 to be released with the necessary patches (https://github.com/conan-io/conan/issues/13187 and https://github.com/conan-io/conan/issues/13213).

mpusz commented 1 year ago

Even after that, the package will not be fully functional as some of our dependencies (doxygen and linear_algebra) are not Conan 2.0 ready. I hope they will catch up soon.

NAThompson commented 1 year ago

@mpusz : No worries; I can wait. Love your code btw.

correaa commented 1 year ago

we need a package manager for the package manager 😁

mpusz commented 1 year ago

After the release of Conan 2.0.1 and some more changes to our scripts, it seems that mp-units/0.8.0 is ready to be used with the following limitations:

mp-units/0.7.0 PR on CCI was accepted but is still not merged. It seems that the Conan team has some significant issues refactoring all scripts to work properly in their CI for 2.0 as well. I will keep you updated. Until then you can use mp-units/0.7.0@mpusz/stable from our local Artifactory server as described above.

correaa commented 1 year ago

I used these commands:

for a project with:

$ cat conanfile.txt 
[requires]
mp-unit/0.7.0@mpusz/stable

[generators]
CMakeToolchain
CMakeDeps

The output of the last command in the recipe above is this Unable to find 'mp-unit/0.7.0@mpusz/stable' in remotes this below. Am I missing something? (I tried with mpunit0.8.0 also but it doesn't work, so I went for the artifactory workaround).

$ conan install .. -pr:b=default -s compiler.cppstd=20 -b=missing

======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=20
compiler.libcxx=libstdc++11
compiler.version=12
os=Linux

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=12
os=Linux

======== Computing dependency graph ========
mp-unit/0.7.0@mpusz/stable: Not found in local cache, looking in remotes...
mp-unit/0.7.0@mpusz/stable: Checking remote: conancenter
mp-unit/0.7.0@mpusz/stable: Checking remote: conan-mpusz
Graph root
    conanfile.txt: /builds/project-0/ground_state/conanfile.txt
ERROR: Package 'mp-unit/0.7.0@mpusz/stable' not resolved: Unable to find 'mp-unit/0.7.0@mpusz/stable' in remotes
mpusz commented 1 year ago

Yes ;-) The package name is mp-units/0.7.0@mpusz/stable and not mp-unit/0.7.0@mpusz/stable.

mpusz commented 1 year ago

As of today, my artifactory hosts the following packages:

$ conan list mp-units -r conan-mpusz
conan-mpusz
  mp-units
    mp-units/0.7.0@mpusz/stable 
    mp-units/0.8.0@mpusz/testing
correaa commented 1 year ago

Yes ;-) The package name is mp-units/0.7.0@mpusz/stable and not mp-unit/0.7.0@mpusz/stable.

That was embarrassing. Sorry. All seems to be working now.

mpusz commented 1 year ago
$ conan list mp-units -r conancenter
conancenter
  mp-units
    mp-units/0.6.0
    mp-units/0.7.0
    mp-units/0.8.0

"mp-units/0.8.0" was added to ConanCenter today. It is the only revision compatible with the Conan 2.0.