[bug] `required_conan_version` is not evaluated before python imports
See original GitHub issueEnvironment 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 torequired_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:
- Created a year ago
- Comments:7 (7 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
https://github.com/conan-io/conan/pull/11908 merged, this will be in 1.52
Oh, that could be a better approach, indeed. We could give that a try 👍