-
Notifications
You must be signed in to change notification settings - Fork 988
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* simplify parallel jobs * add missing files * import multiprocessing * review * fix tests * fix tests * fix tests
- Loading branch information
1 parent
cbc9586
commit bc83dfa
Showing
20 changed files
with
99 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,4 +105,5 @@ cacert.pem | |
|
||
# add excluded | ||
!conans/client/build | ||
!conan/tools/build | ||
!conans/test/unittests/client/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from conan.tools.build.cpu import build_jobs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import math | ||
import multiprocessing | ||
|
||
from conans.util.files import load | ||
|
||
|
||
def build_jobs(conanfile): | ||
njobs = conanfile.conf["tools.build:jobs"] | ||
if njobs is not None: | ||
result = int(njobs) | ||
if result == 0: | ||
return None | ||
return result | ||
return _cpu_count() | ||
|
||
|
||
def _cpu_count(): | ||
try: | ||
try: | ||
# This is necessary to deduce docker cpu_count | ||
cfs_quota_us = int(load("/sys/fs/cgroup/cpu/cpu.cfs_quota_us")) | ||
cfs_period_us = int(load("/sys/fs/cgroup/cpu/cpu.cfs_period_us")) | ||
if cfs_quota_us > 0 and cfs_period_us > 0: | ||
return int(math.ceil(cfs_quota_us / cfs_period_us)) | ||
except (OSError, TypeError): | ||
pass | ||
return multiprocessing.cpu_count() | ||
except NotImplementedError: | ||
# print("multiprocessing.cpu_count() not implemented. Defaulting to 1 cpu") | ||
return 1 # Safe guess |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.