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

[related:7120] self.deps_user_info and/or self.env_info not working with build & host profiles combo #7203

Closed
saimusdev opened this issue Jun 17, 2020 · 6 comments

Comments

@saimusdev
Copy link

saimusdev commented Jun 17, 2020

Environment Details

  • Operating System: Ubuntu 16.04.6 LTS
  • Compiler+version: gcc 6.4.0 (but should be irrelevant)
  • Conan version: 1.26.0
  • Python version: 3.5.2

Steps to reproduce

1. Create a build-context and a host-context profile

Sample: build-context profile: build/linux64:
[settings]
os=Linux
arch=x86_64
Sample: host-context profile: native64:
[settings]
os=Linux
arch=x86_64
build_type=Release

[env]
PLATFORM=native64

2. Create a simple package and a test-package, that propagates a self.user_info and/or self.env_info variable(s) from the package -> test-package.

Sample: Package recipe
from conans import ConanFile


class SomePackage(ConanFile):
    name = "mypkg"
    version = "0.0.0-rev1"
    generators = "virtualenv", "cmake", "cmake_multi"
    settings = "os", "arch", "build_type"

    def official_version(self):
        return self.version.split('-')[0]

    def package_info(self):
        super().package_info()
        self.user_info.foo = self.official_version()
Sample: Test package recipe
from conans import ConanFile


class TestPackage(ConanFile):
    name = "mypkg-test"
    version = "0.0.0"
    generators = "virtualenv", "cmake", "cmake_multi"
    settings = "os", "arch", "build_type"

    def build(self):
        self.output.warn(self.deps_user_info["mypkg"].foo)

    def test(self):
        self.output.warn("something")

3. Try to create the package with the build & host context profiles:

user@host: ~$ conan create . --profile:build build/linux64 --profile:host host/native64

4. Failure

Either you get an AttributeError for user_info or a KeyError for env_info...

Logs

user@host: ~$ conan create . --profile:build build/linux64 --profile:host host/native64
Exporting package recipe
mypkg/0.0.0-rev1 exports: Copied 1 '.json' file: repo_metadata.json
mypkg/0.0.0-rev1: A new conanfile.py version was exported
mypkg/0.0.0-rev1: Folder: ~/.conan/datamypkg/0.0.0-rev1/_/_/export
mypkg/0.0.0-rev1: Package recipe modified in export, forcing source folder removal
mypkg/0.0.0-rev1: Use the --keep-source, -k option to skip it
mypkg/0.0.0-rev1: Exported revision: 2d2abc7f5b717a6dad7aca189b031951
Configuration (profile_host):
[settings]
arch=x86_64
build_type=Release
os=Linux
[options]
[build_requires]
[env]
PLATFORM=native64
Configuration (profile_build):
[settings]
arch=x86_64
os=Linux
[options]
[build_requires]
[env]

mypkg/0.0.0-rev1: Forced build from source
mypkg/0.0.0-rev1 (test package): Installing package
Requirements
    mypkg/0.0.0-rev1 from local cache - Cache
Packages
    mypkg/0.0.0-rev1:24647d9fe8ec489125dfbae4b3ebefaf7581674c - Build

Installing (downloading, building) binaries...
mypkg/0.0.0-rev1: Configuring sources in ~/.conan/datamypkg/0.0.0-rev1/_/_/source
mypkg/0.0.0-rev1: Copying sources to build folder
mypkg/0.0.0-rev1: Building your package in ~/.conan/datamypkg/0.0.0-rev1/_/_/build/24647d9fe8ec489125dfbae4b3ebefaf7581674c
mypkg/0.0.0-rev1: Generator cmake_multi created conanbuildinfo_release.cmake
mypkg/0.0.0-rev1: Generator cmake_multi created conanbuildinfo_multi.cmake
mypkg/0.0.0-rev1: Generator virtualenv created environment.sh.env
mypkg/0.0.0-rev1: Generator virtualenv created activate.sh
mypkg/0.0.0-rev1: Generator virtualenv created deactivate.sh
mypkg/0.0.0-rev1: Generator cmake created conanbuildinfo.cmake
mypkg/0.0.0-rev1: Calling build()
mypkg/0.0.0-rev1: WARN: This conanfile has no build step
mypkg/0.0.0-rev1: Package '24647d9fe8ec489125dfbae4b3ebefaf7581674c' built
mypkg/0.0.0-rev1: Build folder ~/.conan/datamypkg/0.0.0-rev1/_/_/build/24647d9fe8ec489125dfbae4b3ebefaf7581674c
mypkg/0.0.0-rev1: Generated conaninfo.txt
mypkg/0.0.0-rev1: Generated conanbuildinfo.txt
mypkg/0.0.0-rev1: Generating the package
mypkg/0.0.0-rev1: Package folder ~/.conan/datamypkg/0.0.0-rev1/_/_/package/24647d9fe8ec489125dfbae4b3ebefaf7581674c
mypkg/0.0.0-rev1: Calling package()
mypkg/0.0.0-rev1: WARN: This conanfile has no package step
mypkg/0.0.0-rev1 package(): WARN: No files in this package!
mypkg/0.0.0-rev1: Package '24647d9fe8ec489125dfbae4b3ebefaf7581674c' created
mypkg/0.0.0-rev1: Created package revision 09024764673c8af1177685801534e926
mypkg/0.0.0-rev1 (test package): Generator cmake_multi created conanbuildinfo_release.cmake
mypkg/0.0.0-rev1 (test package): Generator cmake_multi created conanbuildinfo_multi.cmake
mypkg/0.0.0-rev1 (test package): Generator txt created conanbuildinfo.txt
mypkg/0.0.0-rev1 (test package): Generator virtualenv created environment.sh.env
mypkg/0.0.0-rev1 (test package): Generator virtualenv created activate.sh
mypkg/0.0.0-rev1 (test package): Generator virtualenv created deactivate.sh
mypkg/0.0.0-rev1 (test package): Generator cmake created conanbuildinfo.cmake
mypkg/0.0.0-rev1 (test package): Generated conaninfo.txt
mypkg/0.0.0-rev1 (test package): Generated graphinfo
Using lockfile: '/home/lwp/dev/conan_user_info_test/test_package/build/06c5d3e7ca5ce66096074b868ff1371774c867da/conan.lock'
Using cached profile from lockfile
mypkg/0.0.0-rev1 (test package): Calling build()
ERROR: mypkg/0.0.0-rev1 (test package): Error in build() method, line 11
	self.output.warn(self.deps_user_info["mypkg"].foo)
	AttributeError:
@theodelrieu
Copy link
Contributor

@jsgogo This does look like the issue we talked about with the android_ndk_installer recipe, right?

@jgsogo
Copy link
Contributor

jgsogo commented Jun 18, 2020

Hi! Yes, this is totally related to #7120 and the information we want (we need) to propagate from the build context to the host one... It was a conscious decision not to propagate user_info in this new cross-building approach because we really wanted to receive feedback and example use cases.

So, right now, this is by design, but it has to be analyzed carefully and we might make this information accessible from the other contexts.

We need to think about how to do it. The problem is not straightforward with the model we have right now. for example: in the graph you can have now the same package in the host context and in the build context (protobuf, you want the library in the host context and the executable in the build context), both packages can provide different information in the user_info field, how can we disambiguate that information when using self.deps_user_info["protobuf"]? If we are to propagate that information, we need and extra field? and extra key in the dictionary?

@jgsogo jgsogo changed the title [bug] self.deps_user_info and/or self.env_info not working with build & host profiles combo [related:7120] self.deps_user_info and/or self.env_info not working with build & host profiles combo Jun 18, 2020
@theodelrieu
Copy link
Contributor

I have to admit I didn't realize about user_info being used here. Is it the same issue with env_info? IIRC that is the main problem with "toolchain" packages such as android_ndk_installer

@jgsogo
Copy link
Contributor

jgsogo commented Jun 18, 2020

It is not exactly 100% the same problem, but probably the solution will be pretty similar.

@saimusdev
Copy link
Author

Thanks for looking into this!

@memsharded
Copy link
Member

Closing this issue as outdated:

  • user_info has been replaced by conf_info and buildenv_info in 1.X and removed in 2.0
  • deps_user_info no longer exist
  • env_info also replaced by buildenv_info and runenv_info in 1.X, and removed in 2.0

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

4 participants