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] Conan 1.X: prefer build_requires from direct/indirect dependencies over build_requires from profiles

See original GitHub issue

Environment Details (include every applicable attribute)

  • Operating System+version: Ubuntu 20.04
  • Compiler+version: clang-13
  • Conan version: 1.44.1
  • Python version: 3.8.10

Steps to reproduce (Include if Applicable)

==> mybin.py <==

import os

from conans import ConanFile

class ConanRecipe(ConanFile):
    name = "mybin"
    version = "1.0.0"

    def build(self):
        pass
        
    def package(self):
        os.makedirs(os.path.join(self.package_folder, "bin"), exist_ok=True)
        self.run("cd %s/bin && echo 'echo mybin' > mybin; chmod +x mybin" % self.package_folder)

==> myproject.py <==

import os

from conans import ConanFile

class ConanRecipe(ConanFile):
    name = "myproject"
    version = "1.0.0"

    def build_requirements(self):
        self.build_requires("mybin/1.0.0")
    
    def build(self):
        print("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
        self.run("mybin")
        print("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
        self.run("which -a mybin")

==> sysroot.py <==

import os

from conans import ConanFile

class ConanRecipe(ConanFile):
    name = "sysroot"
    version = "1.0.0"

    def build(self):
        pass
        
    def package(self):
        os.makedirs(os.path.join(self.package_folder, "bin"), exist_ok=True)
        self.run("cd %s/bin && echo 'echo sysroot' > mybin; chmod +x mybin" % self.package_folder)

==> sysroot.profile <==

[build_requires]
sysroot/1.0.0

==> run.sh <==

#!/bin/bash

set -ex

conan export sysroot.py
conan export mybin.py
conan export myproject.py test/test

rm -rf build && mkdir build
cd build

conan install myproject/1.0.0@test/test -pr:h=../sysroot.profile -pr:b=../sysroot.profile --build=missing --build=myproject

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

myproject/1.0.0@test/test: Calling build()
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
sysroot
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
/home/EU.BSHG.COM/kleint/.docker-build-scripts/conan_cache/.conan/data/sysroot/1.0.0/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/bin/mybin
/home/EU.BSHG.COM/kleint/.docker-build-scripts/conan_cache/.conan/data/mybin/1.0.0/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/bin/mybin

As you can see the mybin executable from sysroot/1.0.0 (profile) is first in PATH although a package containing mybin was specified as a build_requirement in the conanfile.py.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
thorsten-kleincommented, Oct 19, 2022

+1

0reactions
czoidocommented, Oct 19, 2022

-c tools.env.virtualenv:auto_use=True seems to do the trick. can I do it also anyhow without this but specifying generators = "virtualenv" in the conanfile.py? This seems not to work then 😦

@thorsten-klein you could use:

  • generators = "VirtualBuildEnv" in myproject
  • or set tools.env.virtualenv:auto_use=True in the global.conf

You can read more about that in the Conan v2 migration guide

Read more comments on GitHub >

github_iconTop Results From Across the Web

[bug] Recipe self.dependencies does not contain any elements
I am trying to externalise build requirements through profiles, ... from conans import ConanFile class DependenciesCheck(ConanFile): def ...
Read more >
RPM Packaging Guide
The rpm package manager uses this metadata to determine dependencies, where to install files, and other information. There are two types of RPM...
Read more >
Packaging guidelines - Mageia wiki
Every package in Mageia needs a maintainer (AKA owner, bug owner). ... The automatic dependency on libfubar.so.1 is insufficient, # as we strictly...
Read more >
Howto modify/affect/adapt conan dependencies - Stack Overflow
The obvious recommendation: Update Conan to the latest version (1.35.1). pip install -U conan. Packages in Conan Center Index (all official) ...
Read more >
qt/qtwebengine.git - Qt WebEngine
50, # When constructor initializers do not fit on one line, put them each on a ... 511, MESSAGE "Build requires Khronos development...
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