Consider the following tree and files:
.
โโโ ffmpeg
โย ย โโโ conanfile.py
โโโ variant
โโโ conanfile.py
variant/conanfile.py:
class Meta(ConanFile):
name = "nano"
settings = "os", "arch", "compiler"
version = "1.0"
requires = (
"ffmpeg/1.0",
)
default_options = {"ffmpeg:variation": "nano"}
ffmpeg/conanfile.py (shortened):
class FfmpegConan(ConanFile):
name = "ffmpeg"
version = "1.0"
settings = "os", "compiler", "build_type", "arch"
options = {"variation": ["standard", "nano"]}
default_options = {"variation": "standard"}
def requirements(self):
variation = str(self.options.variation)
print(f"(requirements) variation = {variation}")
Script:
$ conan export ffmpeg
$ conan export variant
$ conan graph lock --build --lockfile . variant
$ conan graph build-order --build cascade --build outdated .
$ cat conan.lock
$ conan create --build ffmpeg/1.0 --test-folder=None -ne --lockfile . ffmpeg
Since in the root package ("variant") the ffmpeg variation option is overridden, I would expect it to take effect in the lockfile (it does) and to be applied when conan create is called (it isn't).
The following should be printed:
(requirements) variation = nano
(requirements) variation = standard
is printed; even though
conan graph lock and conan graph build-order) I also see the correct value.Repro: https://github.com/sztomi/default_options_not_applied
Here is the output I get with the above repo:
+ conan create --build ffmpeg/1.0 --test-folder=None -ne --lockfile . ffmpeg
Using lockfile: '/home/tamas/src/repros/conan/default_options_not_applied/conan.lock'
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++
compiler.version=9
os=Linux
os_build=Linux
[options]
[build_requires]
[env]
(requirements) variation = standard
ffmpeg/1.0: Forced build from source
Installing package: ffmpeg/1.0
Requirements
ffmpeg/1.0 from local cache - Cache
Packages
ffmpeg/1.0:65361091dd57a222f4dcb4ae2002f166d5b24a4b - Build
ffmpeg/1.0: Configuring sources in /home/tamas/src/repros/conan/default_options_not_applied/conan_cache/.conan/data/ffmpeg/1.0/_/_/source
(source) variation = nano
ffmpeg/1.0: Copying sources to build folder
ffmpeg/1.0: Building your package in /home/tamas/src/repros/conan/default_options_not_applied/conan_cache/.conan/data/ffmpeg/1.0/_/_/build/65361091dd57a222f4dcb4ae2002f166d5b24a4b
ffmpeg/1.0: Generator cmake created conanbuildinfo.cmake
ffmpeg/1.0: Calling build()
(build) variation = nano
ffmpeg/1.0: Package '65361091dd57a222f4dcb4ae2002f166d5b24a4b' built
ffmpeg/1.0: Build folder /home/tamas/src/repros/conan/default_options_not_applied/conan_cache/.conan/data/ffmpeg/1.0/_/_/build/65361091dd57a222f4dcb4ae2002f166d5b24a4b
ffmpeg/1.0: Generated conaninfo.txt
ffmpeg/1.0: Generated conanbuildinfo.txt
ffmpeg/1.0: Generating the package
ffmpeg/1.0: Package folder /home/tamas/src/repros/conan/default_options_not_applied/conan_cache/.conan/data/ffmpeg/1.0/_/_/package/65361091dd57a222f4dcb4ae2002f166d5b24a4b
ffmpeg/1.0: Calling package()
(package) variation = nano
ffmpeg/1.0 package(): Packaged 1 '.so' file: libavcodec.so
ffmpeg/1.0: Package '65361091dd57a222f4dcb4ae2002f166d5b24a4b' created
ffmpeg/1.0: Created package revision 0e64452a73e502bfc68a5721034b80ac
+ exit
As you can see, each step outputs the value of the option, and it's the right value for all methods except requirements.
These are the contents of the lockfile:
{
"profile_host": "[settings]\narch=x86_64\narch_build=x86_64\nbuild_type=Release\ncompiler=gcc\ncompiler.libcxx=libstdc++\ncompiler.version=9\nos=Linux\nos_build=Linux\n[options]\n[build_requires]\n[env]\n",
"graph_lock": {
"nodes": {
"0": {
"pref": "nano/1.0:1655ff033a387cae609616374f0c895a75dd0ebe",
"options": "ffmpeg:variation=nano",
"requires": {
"ffmpeg/1.0#5f4c64a73aeee652526ad5df2d0bf843": "1"
},
"path": "/home/tamas/src/repros/conan/default_options_not_applied/variant/conanfile.py"
},
"1": {
"pref": "ffmpeg/1.0#5f4c64a73aeee652526ad5df2d0bf843:65361091dd57a222f4dcb4ae2002f166d5b24a4b#0e64452a73e502bfc68a5721034b80ac",
"options": "variation=nano",
"modified": "Build"
}
}
},
"version": "0.2"
}
I tried the above branch in our build and this appears to fix the issue ^
Merged, will be in Conan 1.22
Thank you very much for addressing this so quickly, much appreciated!