question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[bug] `required_conan_version` is not evaluated before python imports

See original GitHub issue

Environment Details (include every applicable attribute)

  • Operating System+version: macOS Monterey
  • Compiler+version: apple-clang 13.1
  • Conan version: 1.48.0
  • Python version: 3.9.12

Steps to reproduce (Include if Applicable)

see https://github.com/conan-io/conan-center-index/pull/10633#issuecomment-1124783149

  • use conan < 1.45.0, for example 1.44.0
  • conan install yaml-cpp/0.6.3
  • Instead of the meaningful message ERROR: Error loading conanfile at (...): Current Conan version (1.44.0) does not satisfy the defined one (>=1.45.0). we could expect due to required_conan_version = ">=1.45.0", there are python imports error.

Logs (Executed commands with output) (Include/Attach if Applicable)

log from https://github.com/conan-io/conan-center-index/pull/10633#issuecomment-1124783149:

00:00:22  yaml-cpp/0.6.3: Retrieving from server 'conancenter'
00:00:22  yaml-cpp/0.6.3: Trying with 'conancenter'...
00:00:22  Downloading conanmanifest.txt
00:00:22  Downloading conanfile.py
00:00:22  Downloading conan_export.tgz
00:00:22  yaml-cpp/0.6.3: Downloaded recipe revision 0
00:00:22  ERROR: yaml-cpp/0.6.3: Cannot load recipe.
00:00:22  Error loading conanfile at '***/CONAN_CACHE_arm64/.conan/data/yaml-cpp/0.6.3/_/_/export/conanfile.py': Unable to load conanfile in ***/CONAN_CACHE_arm64/.conan/data/yaml-cpp/0.6.3/_/_/export/conanfile.py
00:00:22    File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/imp.py", line 171, in load_source
00:00:22      module = _load(spec)
00:00:22    File "<frozen importlib._bootstrap>", line 711, in _load
00:00:22    File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
00:00:22    File "<frozen importlib._bootstrap_external>", line 850, in exec_module
00:00:22    File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
00:00:22    File "***/CONAN_CACHE_arm64/.conan/data/yaml-cpp/0.6.3/_/_/export/conanfile.py", line 1, in <module>
00:00:22      from conan.tools.microsoft import is_msvc, is_msvc_static_runtime
00:00:22  ImportError: cannot import name 'is_msvc' from 'conan.tools.microsoft' (***/lib/python3.9/site-packages/conan/tools/microsoft/__init__.py)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
memshardedcommented, Aug 23, 2022

https://github.com/conan-io/conan/pull/11908 merged, this will be in 1.52

0reactions
memshardedcommented, May 18, 2022

I was thinking about trying to locate the required_conan_version “manually” only after getting an ImportError (to improve the error message if we locate the required_conan_version, or keep raising otherwise)

Oh, that could be a better approach, indeed. We could give that a try 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is Python running my module when I import it, and how ...
This module would just execute the main function when run, and not execute it if imported. It all depends on what you want...
Read more >
5. The import system — Python 3.11.1 documentation
Python code in one module gains access to the code in another module by the process of importing it. The import statement is...
Read more >
Python import: Advanced Techniques and Tips
Note that this places pi in the global namespace and not within a math namespace. You can also rename modules and attributes as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found