question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[question] tools.build.build_jobs can not parse conf.tools.build:jobs

See original GitHub issue

When using Conan conf to extract build:jobs based on os.cpu_count(), Conan fails due an unexpected type, it wanted int, but received string.

This feature it’s documented on Docs:

https://docs.conan.io/en/latest/reference/config_files/global_conf.html#configuration-file-template

https://docs.conan.io/en/latest/reference/conanfile/tools/build.html#conan-tools-build-build-jobs

Related to https://github.com/conan-io/conan-center-index/issues/12737

/cc @blockspacer

Environment Details (include every applicable attribute)

  • Operating System+version: OSX
  • Compiler+version: N/A
  • Conan version: 1.52.0
  • Python version: 3.10

Steps to reproduce (Include if Applicable)

from conan import ConanFile
from conan.tools.build import build_jobs

class FooConan(ConanFile):
    def configure(self):
        cpucount = build_jobs(self)
        self.output.info(f"**** CPUCOUNT: {type(cpucount)}")
        self.output.info(f"**** CPUCOUNT: {cpucount}")
conan profile update 'conf.tools.build:jobs={{os.cpu_count()}}' default 
conan create . foo/0.1@  -pr:b=default -pr:h=default

Logs (Executed commands with output) (Include/Attach if Applicable)

foo/0.1: Exported revision: e32b23a17d67db859472a46a6ceb3e0b
Configuration (profile_host):
[settings]
arch=armv8
arch_build=armv8
build_type=Release
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=13
os=Macos
os_build=Macos
[options]
[build_requires]
[env]
[conf]
tools.build:jobs={{os.cpu_count()}}

Configuration (profile_build):
[settings]
arch=armv8
arch_build=armv8
build_type=Release
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=13
os=Macos
os_build=Macos
[options]
[build_requires]
[env]
[conf]
tools.build:jobs={{os.cpu_count()}}

ERROR: Traceback (most recent call last):
  File "/Users/uilian/.pyenv/versions/3.10.4/lib/python3.10/site-packages/conans/errors.py", line 34, in conanfile_exception_formatter
    yield
  File "/Users/uilian/.pyenv/versions/3.10.4/lib/python3.10/site-packages/conans/client/conanfile/configure.py", line 27, in run_configure_method
    conanfile.configure()
  File "/Users/uilian/.conan/data/foo/0.1/_/_/export/conanfile.py", line 10, in configure
    cpucount = build_jobs(self)
  File "/Users/uilian/.pyenv/versions/3.10.4/lib/python3.10/site-packages/conan/tools/build/cpu.py", line 9, in build_jobs
    njobs = conanfile.conf.get("tools.build:jobs",
  File "/Users/uilian/.pyenv/versions/3.10.4/lib/python3.10/site-packages/conans/model/conf.py", line 246, in get
    raise ConanException("[conf] {name} must be a {type}-like object. "
conans.errors.ConanException: [conf] tools.build:jobs must be a int-like object. The value '{{os.cpu_count()}}' introduced is a str object

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
blockspacercommented, Sep 1, 2022

Thanks, ill try to use myprofile.jinja

BTW, it may be good idea to link https://docs.conan.io/en/latest/reference/profiles.html#profile-templates near info about global.conf in documentation.

1reaction
memshardedcommented, Sep 1, 2022

Hi @blockspacer

yes, sorry I failed to properly explain. I mean the file extension. You need to opt-in using something like myprofile.jinja (this will not be necessary in 2.0, but it was necessary in 1.X to avoid breaking).

The docs are in https://docs.conan.io/en/latest/reference/profiles.html#profile-templates

Read more comments on GitHub >

github_iconTop Results From Across the Web

[bug] tools.build.build_jobs can not parse conf. ...
Package and Environment Details Package Name/Version: boost/1.71.0 Operating System+version: Windows 10 Compiler+version: clang-cl Docker ...
Read more >
Could not parse configuration: hibernate.cfg.xml
Didn't you think that your <property name="connection.url">jdbc:oracle//localhost/5432/newdatabase</property>. must look like:
Read more >
Project Configuration | User Guide
Each project has a project configuration which defines the setup of the build system. Usually it is empty and you do not need...
Read more >
Changelog — conan 1.50.2 documentation
Docs here; Fix: The CMakeToolchain will fail if settings.build_type is specified in the 'tools.cmake.cmake_layout:build_folder' conf because the build_type ...
Read more >
verilator Arguments — Verilator 5.005 documentation
Specify the level of parallelism for --build if --build-jobs isn't provided. If zero, uses the number of threads in the current hardware. Otherwise,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found