MCPcopy Create free account
hub / github.com/numpy/numpy / get_num_build_jobs

Function get_num_build_jobs

numpy/distutils/misc_util.py:76–110  ·  view source on GitHub ↗

Get number of parallel build jobs set by the --parallel command line argument of setup.py If the command did not receive a setting the environment variable NPY_NUM_BUILD_JOBS is checked. If that is unset, return the number of processors on the system, with a maximum of 8 (to pre

()

Source from the content-addressed store, hash-verified

74
75
76def get_num_build_jobs():
77 """
78 Get number of parallel build jobs set by the --parallel command line
79 argument of setup.py
80 If the command did not receive a setting the environment variable
81 NPY_NUM_BUILD_JOBS is checked. If that is unset, return the number of
82 processors on the system, with a maximum of 8 (to prevent
83 overloading the system if there a lot of CPUs).
84
85 Returns
86 -------
87 out : int
88 number of parallel jobs that can be run
89
90 """
91 from numpy.distutils.core import get_distribution
92 try:
93 cpu_count = len(os.sched_getaffinity(0))
94 except AttributeError:
95 cpu_count = multiprocessing.cpu_count()
96 cpu_count = min(cpu_count, 8)
97 envjobs = int(os.environ.get("NPY_NUM_BUILD_JOBS", cpu_count))
98 dist = get_distribution()
99 # may be None during configuration
100 if dist is None:
101 return envjobs
102
103 # any of these three may have the job set, take the largest
104 cmdattr = (getattr(dist.get_command_obj('build'), 'parallel', None),
105 getattr(dist.get_command_obj('build_ext'), 'parallel', None),
106 getattr(dist.get_command_obj('build_clib'), 'parallel', None))
107 if all(x is None for x in cmdattr):
108 return envjobs
109 else:
110 return max(x for x in cmdattr if x is not None)
111
112def quote_args(args):
113 """Quote list of arguments.

Callers 1

CCompiler_compileFunction · 0.90

Calls 5

get_distributionFunction · 0.90
minFunction · 0.50
allFunction · 0.50
maxFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected