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] Can't setup options of non-visible dependencies #13414

Closed
lo1ol opened this issue Mar 10, 2023 · 5 comments · Fixed by #14340
Closed

[bug] Can't setup options of non-visible dependencies #13414

lo1ol opened this issue Mar 10, 2023 · 5 comments · Fixed by #14340
Assignees
Milestone

Comments

@lo1ol
Copy link

lo1ol commented Mar 10, 2023

Environment details

  • Operating System+version: Arch Linux. Kernel 6.1.12-arch1-1:
  • Compiler+version: doesn't metter
  • Conan version: 2.0.1
  • Python version: 3.10.9

Steps to reproduce

pkgA:

from conan import ConanFile

class RtcryptConanfile(ConanFile):
    name = "pkg_a"
    version = "0.0.1"
    settings = "os", "compiler", "arch", "build_type", "libc"
    
    options = {"shared": [True, False] }
    default_options = {"shared": True }

pkgB.py

from conan import ConanFile

class RtcryptConanfile(ConanFile):
    name = "pkg_b"
    version = "0.0.1"
    settings = "os", "compiler", "arch", "build_type", "libc"

    def configure(self):
        self.options["pkg_a/*"].shared = False

    def requirements(self):
        self.requires("pkg_a/0.0.1", visible=False)
conan export-pkg pkgA.py -o shared=False
conan install pkgB.py

output:

======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu17
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
    pkgB.py (pkg_b/0.0.1): /home/lo1ol/Documents/work/test-conan/pkgB.py
Requirements
    pkg_a/0.0.1#a91d6891f1daa9ab5d8cc9c8c3f1bb5b - Cache

======== Computing necessary packages ========
pkg_a/0.0.1: Checking 11 compatible configurations:
pkg_a/0.0.1: 'b082102120a9c898a397be8147c103d56cac2e6c': compiler.cppstd=98
pkg_a/0.0.1: '484059f461f4d7051d76db080832716def56f0df': compiler.cppstd=gnu98
pkg_a/0.0.1: '575dca56032a0b6ed62c0de7d945dbe0085e0a90': compiler.cppstd=11
pkg_a/0.0.1: '642b6bbd320092221c4b8d2a29e7d73c71d97310': compiler.cppstd=gnu11
pkg_a/0.0.1: 'e38021eac4af49bbe19851bfd12859cf29741ca1': compiler.cppstd=14
pkg_a/0.0.1: 'e6160f0620b0d0ae9688ac9f1d26d7641134522f': compiler.cppstd=gnu14
pkg_a/0.0.1: 'ce9334680096ebc52254cf1dbccd51426b809aa8': compiler.cppstd=17
pkg_a/0.0.1: '51810a643c5275aeb9343b8c10d5d8e3b91a5b3e': compiler.cppstd=20
pkg_a/0.0.1: 'eeb62e397f68c0ca027f83909dfe305c1f166932': compiler.cppstd=gnu20
pkg_a/0.0.1: 'b2021bcaeac05ee4c742d918db0c18fc88f7f2b4': compiler.cppstd=23
pkg_a/0.0.1: 'd3017aacf223e1dbb4e17f096c6f249e89600f66': compiler.cppstd=gnu23
Requirements
    pkg_a/0.0.1#a91d6891f1daa9ab5d8cc9c8c3f1bb5b:43eb0f9449a482934b9b5092ef50d9bf9d1a317f - Missing

======== Installing packages ========
ERROR: Missing binary: pkg_a/0.0.1:43eb0f9449a482934b9b5092ef50d9bf9d1a317f

pkg_b/0.0.1: WARN: Can't find a 'pkg_a/0.0.1' package binary '43eb0f9449a482934b9b5092ef50d9bf9d1a317f' for the configuration:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=12
os=Linux
[options]
shared=True

ERROR: Missing prebuilt package for 'pkg_a/0.0.1'
Check the available packages using 'conan list pkg_a/0.0.1:* -r=remote'
or try to build locally from sources using the '--build=pkg_a/0.0.1' argument

More Info at 'https://docs.conan.io/2/knowledge/faq.html#error-missing-prebuilt-package'

If replace visible=False to visible=True -- everything is work

Logs

No response

@lo1ol
Copy link
Author

lo1ol commented Mar 10, 2023

But setting of options via args of require method is work

@memsharded
Copy link
Member

I haven't forgot about this, I have been investigating this, able to reproduce, not clear if it is expected or not.

What is clear is that the self.tool_requires(..., options={}) should work, and it is a clear and explicit way to define it, so very recommended to use it.

@memsharded
Copy link
Member

It works too for self.test_requires("gtest/1.0", options={"myoption": "2"})

@memsharded memsharded modified the milestones: 2.0.3, 2.0.4 Mar 31, 2023
@memsharded memsharded modified the milestones: 2.0.4, 2.0.5 Apr 11, 2023
@memsharded memsharded modified the milestones: 2.0.5, 2.0.6 May 10, 2023
@memsharded memsharded modified the milestones: 2.0.6, 2.0.7 May 24, 2023
@AbrilRBS AbrilRBS added bug and removed bug labels Jun 19, 2023
@memsharded memsharded modified the milestones: 2.0.7, 2.0.8 Jun 20, 2023
@memsharded memsharded modified the milestones: 2.0.8, 2.0.9 Jul 11, 2023
@memsharded memsharded modified the milestones: 2.0.9, 2.0.10 Jul 19, 2023
@memsharded
Copy link
Member

Proposing default_build_options in #14340 in case you want to give it a try

@memsharded
Copy link
Member

#14340 has been merged for next 2.0.10:

  • It will propagate default_options to the "host" requirements, visible, not visible, test-requires, etc, but not for requirements in the "build" context
  • For "build" context, a new, explicit default_build_options is introduced.

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

Successfully merging a pull request may close this issue.

3 participants