Skip to content

[bug|question] When package is editable runenv_info variables are taken from package_info method instead of layout #19266

@lyanovsk

Description

@lyanovsk

Describe the bug

env. variables defined in package_info (runenv_info), cannot be overriden in layout method using self.layouts.source.runenv_info.define_path("SOME_PATH", "src")

How to reproduce it

Let's we have two packages library:

from conan import ConanFile
from conan.tools.files import copy
from conan.tools.layout import basic_layout


class mylibRecipe(ConanFile):
    name = "mylib"
    version = "0.1"

    # Sources are located in the same place as this recipe, copy them to the recipe
    exports_sources = "src/*"

    def layout(self):
        basic_layout(self)
        self.layouts.build.runenv_info.define_path("SOME_PATH", "src")

    def build(self):
        pass

    def package(self):
        copy(self, "1.txt", self.source_folder, self.package_folder)

    def package_info(self):
        self.runenv_info.define_path("SOME_PATH", self.package_folder)

and there is a src folder with some files(1.txt for example).
Here is consumer package:

from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.env import VirtualBuildEnv, VirtualRunEnv
from conan.tools.layout import basic_layout


class consumerRecipe(ConanFile):
    name = "consumer"
    version = "0.1.0"

    requires = ("mylib/0.1",)

    def layout(self):
        basic_layout(self)

    def generate(self):
        env = VirtualBuildEnv(self)
        env.generate()
        run = VirtualRunEnv(self)
        run.generate()
    def build(self):
        pass

    def package(self):
        pass
  1. Add mylib as editable
  2. Run conan install . on consumer
  3. Look at build/conan/conanrunenv.sh
  4. SOME_PATH will be set root folder of mylib package
  5. Comment out package_info method and run above again
  6. SOME_PATH will be set correctly to mylib/src

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions