Conan: [bug] (lockfiles in CI) sources are not retrieved properly when building multiple configurations

Created on 13 Nov 2020  路  3Comments  路  Source: conan-io/conan

I have a recipe for a toolchain which retrieves sources based on the compiler.version setting:

    def source(self):
        git_user = tools.get_env("GIT_USER")
        git_pass = tools.get_env("GIT_PASS")
        git = tools.Git(username=git_user, password=git_pass)
        git.clone("https://scm/my_compiler_src/%s" % self.settings.get_safe("compiler.version"), "master")

In my CI job for this package, I want to build packages for different versions. I am doing this by deriving different lockfiles from a base:

// create base lockfile
conan lock create ../conanfile.py --user=user --channel=testing --lockfile-out=base.lock --build --base
conan export .. my_compiler_installer/1.0.0@user/testing --lockfile=base.lock --lockfile-out=base.lock

// derive lockfile for 6.2r1 and create package
conan lock create --reference=my_compiler_installer/1.0.0@user/testing --lockfile=base.lock --lockfile-out=6_2r1.lock -s compiler.version=6.2r1 --build=missing
conan install ${package_ref} --build=${package_ref} --lockfile=6_2r1.lock --lockfile-out=6_2r1.lock --build=missing

// derive lockfile for 6.2r2p2 and create package
conan lock create --reference=my_compiler_installer/1.0.0@user/testing --lockfile=base.lock --lockfile-out=6_2r2p2.lock -s compiler.version=6.2r2p2 --build=missing
conan install my_compiler_installer/1.0.0@user/testing --build=my_compiler_installer/1.0.0@user/testing --lockfile=6_2r2p2.lock --lockfile-out=6_2r2p2.lock --build=missing

When building the second package, the sources of the first configuration are not updated. It seems the Configuring sources in ... step is skipped and the sources from the first build are copied and reused.

Environment Details (include every applicable attribute)

  • Operating System+version: Windows 10 64-bit
  • Compiler+version: n/a
  • Conan version: 1.30.2
  • Python version: 3.7.3
triaging question

All 3 comments

Hi @GordonJess

This doesn't look a lockfiles problem, but a model problem: you are doing different builds based on a different compiler versions, right? The source() method is common for all different builds of the same recipe version. It cannot be parameterized based on settings (and this will raise errors in Conan 2.0 or enabling CONAN_V2_BEHAVIOR (experimental)). If you have different code for different settings, you need to fetch it in the build() method. Please read the note in https://docs.conan.io/en/latest/reference/conanfile/methods.html#source

Ah! Thanks a lot! I didn't notice that note. I'll give it a try!

It works fine. Thanks a lot, I'll close this now!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zlalanne picture zlalanne  路  3Comments

db4 picture db4  路  3Comments

niosHD picture niosHD  路  3Comments

tonka3000 picture tonka3000  路  3Comments

Polibif picture Polibif  路  3Comments