conan
conan copied to clipboard
[bug] pkg info doesn't contain VS toolset
On windows self.info.settings
sometimes doesn't contain toolset even if it exists at self.settings
Steps to reproduce (Include if Applicable)
from conans import ConanFile
class TestConanfile(ConanFile):
settings = "compiler"
def package_id(self):
print("Plain: ", self.settings.compiler.toolset)
print("Inside info: ", self.info.settings.compiler.toolset)
FAIL example:
$ mkdir -p test && conan export-pkg -bf test -s compiler.toolset=v142 -s compiler.version=16 test_conanfile.py test/test@ -f
[HOOK - attribute_checker.py] pre_export(): WARN: Conanfile doesn't have 'url'. It is recommended to add it as attribute
[HOOK - attribute_checker.py] pre_export(): WARN: Conanfile doesn't have 'license'. It is recommended to add it as attribute
[HOOK - attribute_checker.py] pre_export(): WARN: Conanfile doesn't have 'description'. It is recommended to add it as attribute
Exporting package recipe
test/test: The stored package has not changed
test/test: Using the exported files summary hash as the recipe revision: 993da9bf525696b286767d1071776a16
test/test: Exported revision: 993da9bf525696b286767d1071776a16
Plain: v142
Inside info: None
test/test: Forced build from source
Packaging to 798cc4912df31ee41af5ab6bbbd108bbdc6e34f9
test/test: Generating the package
test/test: Package folder C:\Users\lolol\.conan\data\test\test\_\_\package\798cc4912df31ee41af5ab6bbbd108bbdc6e34f9
test/test: Calling package()
test/test: WARN: This conanfile has no package step
test/test package(): WARN: No files in this package!
test/test: Package '798cc4912df31ee41af5ab6bbbd108bbdc6e34f9' created
test/test: Created package
OK example:
$ mkdir -p test && conan export-pkg -bf test -s compiler.toolset=v141_xp -s compiler.version=15 test_conanfile.py test/test@ -f
[HOOK - attribute_checker.py] pre_export(): WARN: Conanfile doesn't have 'url'. It is recommended to add it as attribute
[HOOK - attribute_checker.py] pre_export(): WARN: Conanfile doesn't have 'license'. It is recommended to add it as attribute
[HOOK - attribute_checker.py] pre_export(): WARN: Conanfile doesn't have 'description'. It is recommended to add it as attribute
Exporting package recipe
test/test: The stored package has not changed
test/test: Using the exported files summary hash as the recipe revision: 993da9bf525696b286767d1071776a16
test/test: Exported revision: 993da9bf525696b286767d1071776a16
Plain: v141_xp
Inside info: v141_xp
test/test: Forced build from source
Packaging to 3b9c638ca819bba9d9487e54266069533bfde242
test/test: Generating the package
test/test: Package folder C:\Users\lolol\.conan\data\test\test\_\_\package\3b9c638ca819bba9d9487e54266069533bfde242
test/test: Calling package()
test/test: WARN: This conanfile has no package step
test/test package(): WARN: No files in this package!
test/test: Package '3b9c638ca819bba9d9487e54266069533bfde242' created
test/test: Created package revision
self.info.vs_toolset_incompatible()
resolve my problem, but I noticed another bug:
$ mkdir -p test && conan export-pkg -bf test -s compiler.toolset=v142 -s compiler.version=15 test_conanfile.py test/test@ -f
[HOOK - attribute_checker.py] pre_export(): WARN: Conanfile doesn't have 'url'. It is recommended to add it as attribute
[HOOK - attribute_checker.py] pre_export(): WARN: Conanfile doesn't have 'license'. It is recommended to add it as attribute
[HOOK - attribute_checker.py] pre_export(): WARN: Conanfile doesn't have 'description'. It is recommended to add it as attribute
Exporting package recipe
test/test: The stored package has not changed
test/test: Using the exported files summary hash as the recipe revision: 958cc19abb3f8b5b9ae9f0154194f7ed
test/test: Exported revision: 958cc19abb3f8b5b9ae9f0154194f7ed
Plain: v142
Inside info: None
test/test: Forced build from source
Packaging to 798cc4912df31ee41af5ab6bbbd108bbdc6e34f9
test/test: Generating the package
test/test: Package folder C:\Users\lolol\.conan\data\test\test\_\_\package\798cc4912df31ee41af5ab6bbbd108bbdc6e34f9
test/test: Calling package()
test/test: WARN: This conanfile has no package step
test/test package(): WARN: No files in this package!
test/test: Package '798cc4912df31ee41af5ab6bbbd108bbdc6e34f9' created
test/test: Created package revision ca944cfe590304ce4bf74e3e4fe830dc
Hi @lo1ol and thank you for raising this question.
Indeed as you mention earlier, the default behaviour as per self.info.vs_toolset_compatible()
(docs here) - is to erase the compiler.toolset
setting if it matches the default toolchain for the specific version of Visual Studio. In this case, Visual Studio 16 uses v142
by default, and thus is erased. As you have rightly pointed out, you can call the \self.info.vs_toolset_incompatible()` method to retain this information if you would like this situation to give way to a different package ID.
As for your second question, if you have the following scenario:
-
compiler.toolset=v142
andcompiler.version=15
passed in settings - the default
self.info.vs_toolset_compatible()
behaviour
The compiler.toolset
setting will also be erased from self.info.settings
but the self.info.settings.compiler.version
will be bumped to 16
. You can test this by printing self.info.settings.compiler.version
in the original file:
def package_id(self):
print("Plain: ", self.settings.compiler.toolset)
print("Compiler version info: ", self.info.settings.compiler.version)
print("Inside info: ", self.info.settings.compiler.toolset)
which will print:
Plain: v142
Compiler version info: 16
Inside info: None
With the same rationale as before, the idea is that we know beforehand that the v142 toolchain will generate the same binaries regardless of the version of Visual Studio, so we map the v142 to the compiler.version=16
.
You would see both 15
and v142
retained if you call self.info.vs_toolset_incompatible()
.
I hope this clarifies the situation :)
Sorry for too late answer, I was at vocation)
I got you! Thanks!