Gentoo Archives: gentoo-dev

From: Nathan Zachary <nathanzachary@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH 2/3] multiprocessing.eclass: Introduce get_nproc() to get no of CPUs
Date: Wed, 14 Dec 2016 17:49:04
Message-Id: 4483d670-104d-a1e5-85b5-bc07fef37b80@gentoo.org
In Reply to: Re: [gentoo-dev] [PATCH 2/3] multiprocessing.eclass: Introduce get_nproc() to get no of CPUs by Doug Freed
1 On 14/12/16 10:11, Doug Freed wrote:
2 > On Wed, Dec 14, 2016 at 11:04 AM, Michał Górny <mgorny@g.o> wrote:
3 >> On Wed, 14 Dec 2016 15:27:25 +0300
4 >> Andrew Savchenko <bircoph@g.o> wrote:
5 >>
6 >>> On Tue, 13 Dec 2016 10:36:15 +0100 Michał Górny wrote:
7 >>>> + nproc=$(python -c 'import multiprocessing; print(multiprocessing.cpu_count());' 2>/dev/null)
8 >>> This is not portable. E.g. paludis users can have python-less
9 >>> system. Adding dev-lang/python to DEPEND will be also a bad idea,
10 >>> since this is quite heavy dependency.
11 >> You can bikeshed potential circumstances where it wouldn't work for
12 >> the next year. Which doesn't change that it would work quite reliably
13 >> for the most of Gentoo users.
14 >>
15 >>> Since on Linux boxes nproc is from coreutils, which is in @system,
16 >>> so looks like only *bsd setups are the problem. On FreeBSD
17 >> ...and all other operating systems (see: Prefix).
18 >>
19 >>> sysctl -a | egrep -i 'hw.ncpu'
20 >> I somehow doubt that would give me the expected number only, and I lack
21 >> a BSD install handy to test it.
22 > $(sysctl -n hw.ncpu)
23 >
24 I don't know that the sysctl command works universally:
25
26 # sysctl -n hw.ncpu
27 sysctl: cannot stat /proc/sys/hw/ncpu: No such file or directory

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies