Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: excepting import error #11957

Closed
wants to merge 5 commits into from

Conversation

Anokhi1994
Copy link

@Anokhi1994 Anokhi1994 commented Jul 28, 2022

We get an error
from conan.tools.build import cross_building
ImportError: cannot import name 'cross_building'

and to fix this , we must except the error instead of crashing the program.

Hope it is okay.


  • I've read the guidelines for contributing.
  • I've followed the PEP8 style guides for Python code in the recipes.
  • I've used the latest Conan client version.
  • I've tried at least one configuration locally with the conan-center hook activated.

@CLAassistant
Copy link

CLAassistant commented Jul 28, 2022

CLA assistant check
All committers have signed the CLA.

@conan-center-bot

This comment has been minimized.

recipes/libcurl/all/conanfile.py Outdated Show resolved Hide resolved
Co-authored-by: Uilian Ries <uilianries@gmail.com>
@conan-center-bot

This comment has been minimized.

@prince-chrismc
Copy link
Contributor

Module 'conans.tools' has no 'Version' member.

Bah! new linter rules are flagging error, upgrade docs are here
https://github.com/conan-io/conan-center-index/blob/master/docs/v2_linter.md#import-tools-from-conan

@conan-center-bot

This comment has been minimized.

@conan-center-bot
Copy link
Collaborator

Failure in build 7 (ed432f7955b60e1d34ae4a09a90f8bf4dd3dcb01):

  • libcurl/7.83.1@:
    Error running command conan export recipes/libcurl/all/conanfile.py libcurl/7.83.1@:

    ERROR: Error loading conanfile at '/home/conan/w/prod_cci_PR-11957/recipes/libcurl/all/conanfile.py': Unable to load conanfile in /home/conan/w/prod_cci_PR-11957/recipes/libcurl/all/conanfile.py
      File "/opt/pyenv/versions/3.7.13/lib/python3.7/imp.py", line 171, in load_source
        module = _load(spec)
      File "<frozen importlib._bootstrap>", line 696, in _load
      File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 728, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/home/conan/w/prod_cci_PR-11957/recipes/libcurl/all/conanfile.py", line 5, in <module>
        from conan import ConanFile, AutoToolsBuildEnvironment, CMake, tools
    ImportError: cannot import name 'AutoToolsBuildEnvironment' from 'conan' (/opt/pyenv/versions/3.7.13/lib/python3.7/site-packages/conan/__init__.py)
    
  • libcurl/7.80.0@:
    Error running command conan export recipes/libcurl/all/conanfile.py libcurl/7.80.0@:

    ERROR: Error loading conanfile at '/home/conan/w/prod_cci_PR-11957/recipes/libcurl/all/conanfile.py': Unable to load conanfile in /home/conan/w/prod_cci_PR-11957/recipes/libcurl/all/conanfile.py
      File "/opt/pyenv/versions/3.7.13/lib/python3.7/imp.py", line 171, in load_source
        module = _load(spec)
      File "<frozen importlib._bootstrap>", line 696, in _load
      File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 728, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/home/conan/w/prod_cci_PR-11957/recipes/libcurl/all/conanfile.py", line 5, in <module>
        from conan import ConanFile, AutoToolsBuildEnvironment, CMake, tools
    ImportError: cannot import name 'AutoToolsBuildEnvironment' from 'conan' (/opt/pyenv/versions/3.7.13/lib/python3.7/site-packages/conan/__init__.py)
    
  • libcurl/7.82.0@:
    Error running command conan export recipes/libcurl/all/conanfile.py libcurl/7.82.0@:

    ERROR: Error loading conanfile at '/home/conan/w/prod_cci_PR-11957/recipes/libcurl/all/conanfile.py': Unable to load conanfile in /home/conan/w/prod_cci_PR-11957/recipes/libcurl/all/conanfile.py
      File "/opt/pyenv/versions/3.7.13/lib/python3.7/imp.py", line 171, in load_source
        module = _load(spec)
      File "<frozen importlib._bootstrap>", line 696, in _load
      File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 728, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/home/conan/w/prod_cci_PR-11957/recipes/libcurl/all/conanfile.py", line 5, in <module>
        from conan import ConanFile, AutoToolsBuildEnvironment, CMake, tools
    ImportError: cannot import name 'AutoToolsBuildEnvironment' from 'conan' (/opt/pyenv/versions/3.7.13/lib/python3.7/site-packages/conan/__init__.py)
    
  • libcurl/7.84.0@:
    Error running command conan export recipes/libcurl/all/conanfile.py libcurl/7.84.0@:

    ERROR: Error loading conanfile at '/home/conan/w/prod_cci_PR-11957/recipes/libcurl/all/conanfile.py': Unable to load conanfile in /home/conan/w/prod_cci_PR-11957/recipes/libcurl/all/conanfile.py
      File "/opt/pyenv/versions/3.7.13/lib/python3.7/imp.py", line 171, in load_source
        module = _load(spec)
      File "<frozen importlib._bootstrap>", line 696, in _load
      File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 728, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/home/conan/w/prod_cci_PR-11957/recipes/libcurl/all/conanfile.py", line 5, in <module>
        from conan import ConanFile, AutoToolsBuildEnvironment, CMake, tools
    ImportError: cannot import name 'AutoToolsBuildEnvironment' from 'conan' (/opt/pyenv/versions/3.7.13/lib/python3.7/site-packages/conan/__init__.py)
    
  • libcurl/7.79.1@:
    Error running command conan export recipes/libcurl/all/conanfile.py libcurl/7.79.1@:

    ERROR: Error loading conanfile at '/home/conan/w/prod_cci_PR-11957/recipes/libcurl/all/conanfile.py': Unable to load conanfile in /home/conan/w/prod_cci_PR-11957/recipes/libcurl/all/conanfile.py
      File "/opt/pyenv/versions/3.7.13/lib/python3.7/imp.py", line 171, in load_source
        module = _load(spec)
      File "<frozen importlib._bootstrap>", line 696, in _load
      File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 728, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/home/conan/w/prod_cci_PR-11957/recipes/libcurl/all/conanfile.py", line 5, in <module>
        from conan import ConanFile, AutoToolsBuildEnvironment, CMake, tools
    ImportError: cannot import name 'AutoToolsBuildEnvironment' from 'conan' (/opt/pyenv/versions/3.7.13/lib/python3.7/site-packages/conan/__init__.py)
    
  • libcurl/7.78.0@:
    Error running command conan export recipes/libcurl/all/conanfile.py libcurl/7.78.0@:

    ERROR: Error loading conanfile at '/home/conan/w/prod_cci_PR-11957/recipes/libcurl/all/conanfile.py': Unable to load conanfile in /home/conan/w/prod_cci_PR-11957/recipes/libcurl/all/conanfile.py
      File "/opt/pyenv/versions/3.7.13/lib/python3.7/imp.py", line 171, in load_source
        module = _load(spec)
      File "<frozen importlib._bootstrap>", line 696, in _load
      File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 728, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/home/conan/w/prod_cci_PR-11957/recipes/libcurl/all/conanfile.py", line 5, in <module>
        from conan import ConanFile, AutoToolsBuildEnvironment, CMake, tools
    ImportError: cannot import name 'AutoToolsBuildEnvironment' from 'conan' (/opt/pyenv/versions/3.7.13/lib/python3.7/site-packages/conan/__init__.py)
    
  • libcurl/7.77.0@:
    Error running command conan export recipes/libcurl/all/conanfile.py libcurl/7.77.0@:

    ERROR: Error loading conanfile at '/home/conan/w/prod_cci_PR-11957/recipes/libcurl/all/conanfile.py': Unable to load conanfile in /home/conan/w/prod_cci_PR-11957/recipes/libcurl/all/conanfile.py
      File "/opt/pyenv/versions/3.7.13/lib/python3.7/imp.py", line 171, in load_source
        module = _load(spec)
      File "<frozen importlib._bootstrap>", line 696, in _load
      File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 728, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/home/conan/w/prod_cci_PR-11957/recipes/libcurl/all/conanfile.py", line 5, in <module>
        from conan import ConanFile, AutoToolsBuildEnvironment, CMake, tools
    ImportError: cannot import name 'AutoToolsBuildEnvironment' from 'conan' (/opt/pyenv/versions/3.7.13/lib/python3.7/site-packages/conan/__init__.py)
    
  • libcurl/7.76.0@:
    Error running command conan export recipes/libcurl/all/conanfile.py libcurl/7.76.0@:

    ERROR: Error loading conanfile at '/home/conan/w/prod_cci_PR-11957/recipes/libcurl/all/conanfile.py': Unable to load conanfile in /home/conan/w/prod_cci_PR-11957/recipes/libcurl/all/conanfile.py
      File "/opt/pyenv/versions/3.7.13/lib/python3.7/imp.py", line 171, in load_source
        module = _load(spec)
      File "<frozen importlib._bootstrap>", line 696, in _load
      File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 728, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/home/conan/w/prod_cci_PR-11957/recipes/libcurl/all/conanfile.py", line 5, in <module>
        from conan import ConanFile, AutoToolsBuildEnvironment, CMake, tools
    ImportError: cannot import name 'AutoToolsBuildEnvironment' from 'conan' (/opt/pyenv/versions/3.7.13/lib/python3.7/site-packages/conan/__init__.py)
    

Note: To save resources, CI tries to finish as soon as an error is found. For this reason you might find that not all the references have been launched or not all the configurations for a given reference. Also, take into account that we cannot guarantee the order of execution as it depends on CI workload and workers availability.

@Anokhi1994
Copy link
Author

It looks conan.tools has no members that existed before as per Linter. Not sure what to do here.

@@ -2,12 +2,12 @@
import os
import re
import functools
from conans import ConanFile, AutoToolsBuildEnvironment, CMake, tools
from conan import ConanFile, AutoToolsBuildEnvironment, CMake, tools
Copy link
Contributor

@ericLemanissier ericLemanissier Aug 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from conan import ConanFile, AutoToolsBuildEnvironment, CMake, tools
from conan import ConanFile
from conan.tools.scm import Version
from conans import AutoToolsBuildEnvironment, CMake, tools

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -136,12 +136,12 @@ def _is_using_cmake_build(self):

@property
def _has_zstd_option(self):
return tools.Version(self.version) >= "7.72.0"
return tools.scm.Version(self.version) >= "7.72.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return tools.scm.Version(self.version) >= "7.72.0"
return Version(self.version) >= "7.72.0"


@property
def _has_metalink_option(self):
# Support for metalink was removed in version 7.78.0 https://github.com/curl/curl/pull/7176
return tools.Version(self.version) < "7.78.0" and not self._is_using_cmake_build
return tools.scm.Version(self.version) < "7.78.0" and not self._is_using_cmake_build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return tools.scm.Version(self.version) < "7.78.0" and not self._is_using_cmake_build
return Version(self.version) < "7.78.0" and not self._is_using_cmake_build

@@ -167,7 +167,7 @@ def configure(self):

# These options are not used in CMake build yet
if self._is_using_cmake_build:
if tools.Version(self.version) < "7.75.0":
if tools.scm.Version(self.version) < "7.75.0":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if tools.scm.Version(self.version) < "7.75.0":
if Version(self.version) < "7.75.0":

@@ -194,7 +194,7 @@ def validate(self):
raise ConanInvalidConfiguration("schannel only suppported on Windows.")
if self.options.with_ssl == "darwinssl" and not tools.is_apple_os(self.settings.os):
raise ConanInvalidConfiguration("darwinssl only suppported on Apple like OS (Macos, iOS, watchOS or tvOS).")
if self.options.with_ssl == "wolfssl" and self._is_using_cmake_build and tools.Version(self.version) < "7.70.0":
if self.options.with_ssl == "wolfssl" and self._is_using_cmake_build and tools.scm.Version(self.version) < "7.70.0":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if self.options.with_ssl == "wolfssl" and self._is_using_cmake_build and tools.scm.Version(self.version) < "7.70.0":
if self.options.with_ssl == "wolfssl" and self._is_using_cmake_build and Version(self.version) < "7.70.0":

@@ -327,7 +327,7 @@ def _patch_cmake(self):

# INTERFACE_LIBRARY (generated by the cmake_find_package generator) targets doesn't have the LOCATION property.
# So skipp the LOCATION check in the CMakeLists.txt
if tools.Version(self.version) >= "7.80.0":
if tools.scm.Version(self.version) >= "7.80.0":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if tools.scm.Version(self.version) >= "7.80.0":
if Version(self.version) >= "7.80.0":

cmake.definitions["CURL_USE_WOLFSSL"] = self.options.with_ssl == "wolfssl"
elif tools.Version(self.version) >= "7.70.0":
elif tools.scm.Version(self.version) >= "7.70.0":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
elif tools.scm.Version(self.version) >= "7.70.0":
elif Version(self.version) >= "7.70.0":

cmake.definitions["CMAKE_USE_WOLFSSL"] = self.options.with_ssl == "wolfssl"
cmake.definitions["USE_NGHTTP2"] = self.options.with_nghttp2
cmake.definitions["CURL_ZLIB"] = self.options.with_zlib
cmake.definitions["CURL_BROTLI"] = self.options.with_brotli
if self._has_zstd_option:
cmake.definitions["CURL_ZSTD"] = self.options.with_zstd
if tools.Version(self.version) >= "7.81.0":
if tools.scm.Version(self.version) >= "7.81.0":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if tools.scm.Version(self.version) >= "7.81.0":
if Version(self.version) >= "7.81.0":

@@ -560,15 +560,15 @@ def _configure_cmake(self):
cmake.definitions["ENABLE_THREADED_RESOLVER"] = self.options.with_threaded_resolver
cmake.definitions["CURL_DISABLE_PROXY"] = not self.options.with_proxy
cmake.definitions["USE_LIBRTMP"] = self.options.with_librtmp
if tools.Version(self.version) >= "7.75.0":
if tools.scm.Version(self.version) >= "7.75.0":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if tools.scm.Version(self.version) >= "7.75.0":
if Version(self.version) >= "7.75.0":

cmake.definitions["USE_LIBIDN2"] = self.options.with_libidn
cmake.definitions["CURL_DISABLE_RTSP"] = not self.options.with_rtsp
cmake.definitions["CURL_DISABLE_CRYPTO_AUTH"] = not self.options.with_crypto_auth
cmake.definitions["CURL_DISABLE_VERBOSE_STRINGS"] = not self.options.with_verbose_strings

# Also disables NTLM_WB if set to false
if not self.options.with_ntlm:
if tools.Version(self.version) <= "7.77.0":
if tools.scm.Version(self.version) <= "7.77.0":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if tools.scm.Version(self.version) <= "7.77.0":
if Version(self.version) <= "7.77.0":

@@ -639,7 +639,7 @@ def package_info(self):
if self.options.with_ssl == "schannel":
self.cpp_info.components["curl"].system_libs.append("crypt32")
elif tools.is_apple_os(self.settings.os):
if tools.Version(self.version) >= "7.77.0":
if tools.scm.Version(self.version) >= "7.77.0":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if tools.scm.Version(self.version) >= "7.77.0":
if Version(self.version) >= "7.77.0":

@prince-chrismc
Copy link
Contributor

Please do not force push 🙏 GitHub forces us to restart the review which is not fun!

@prince-chrismc
Copy link
Contributor

Please follow eric's suggestions 🙏

@stale
Copy link

stale bot commented Sep 4, 2022

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 4, 2022
@stale
Copy link

stale bot commented Oct 8, 2022

This pull request has been automatically closed because it has not had recent activity. Thank you for your contributions.

@stale stale bot closed this Oct 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants