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

[bug] some conan tools (e.g. conan.tools.apple.is_apple_os) don't work correctly from validate/validate_build #12135

Open
SSE4 opened this issue Sep 16, 2022 · 2 comments
Assignees

Comments

@SSE4
Copy link
Contributor

SSE4 commented Sep 16, 2022

Environment Details (include every applicable attribute)

Operating System+version: macOS 12.3
Compiler+version: Apple clang version 13.1.6 (clang-1316.0.21.2.5)
Conan version: Conan version 1.51.3
Python version: Python 3.7.1

Steps to reproduce (Include if Applicable)

run simple recipe doing:

def validate_build(self):
    from conan.errors import ConanInvalidConfiguration
    from conan.tools.apple import is_apple_os
    if is_apple_os(self):
        raise ConanInvalidConfiguration("xxx")

as a result, sometimes it may raise ConanException instead of returning True/False as documented - it's not documented it can raise in any circumstances

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

	if is_apple_os(self):
	ConanException: 'self.settings' access in 'validate()' method is forbidden
@lasote lasote self-assigned this Sep 16, 2022
@lasote
Copy link
Contributor

lasote commented Sep 16, 2022

I cannot reproduce, Would you mind sending me a recipe and the command you are running?

@SSE4
Copy link
Contributor Author

SSE4 commented Sep 16, 2022

$ cat conanfile.py 
from conan import ConanFile

class ConanFile1(ConanFile):
    name = "dummy"
    version = "1.0"
    def validate_build(self):
        from conan.tools.apple import is_apple_os
        from conan.errors import ConanInvalidConfiguration
        if is_apple_os(self):
            raise ConanInvalidConfiguration("xxx")
    def validate(self):
        from conan.tools.apple import is_apple_os
        from conan.errors import ConanInvalidConfiguration
        if is_apple_os(self):
            raise ConanInvalidConfiguration("xxx")
$ conan export . && conan install . --build=*
dummy/1.0: Exporting package recipe
dummy/1.0: Using the exported files summary hash as the recipe revision: 0ad93b2d3fb89162b6344ada30e388b3 
dummy/1.0: A new conanfile.py version was exported
dummy/1.0: Folder: /home/conan/.conan2/p/a0d1a1c1d0eeed7f/e
dummy/1.0: Exported revision: 0ad93b2d3fb89162b6344ada30e388b3
Exported recipe: dummy/1.0#0ad93b2d3fb89162b6344ada30e388b3 (2022-09-16 14:11:28 UTC)

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

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


-------- Computing dependency graph --------
Graph root
    conanfile.py (dummy/1.0): /home/conan/conanfile.py

-------- Computing necessary packages --------
ERROR: conanfile.py (dummy/1.0): Error in validate() method, line 14
	if is_apple_os(self):
	ConanException: 'self.settings' access in 'validate()' method is forbidden

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants