mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Do not use pywin32 to get cpu_count while building
This commit is contained in:
parent
3387a70887
commit
6ca56ccdcf
@ -40,16 +40,6 @@ PKGCONFIG = os.environ.get('PKG_CONFIG', PKGCONFIG)
|
|||||||
if islinux and not PKGCONFIG:
|
if islinux and not PKGCONFIG:
|
||||||
raise SystemExit('Failed to find pkg-config on your system. You can use the environment variable PKG_CONFIG to point to the pkg-config executable')
|
raise SystemExit('Failed to find pkg-config on your system. You can use the environment variable PKG_CONFIG to point to the pkg-config executable')
|
||||||
|
|
||||||
if iswindows:
|
|
||||||
import win32api
|
|
||||||
cpu_count = win32api.GetSystemInfo()[5]
|
|
||||||
else:
|
|
||||||
from multiprocessing import cpu_count
|
|
||||||
try:
|
|
||||||
cpu_count = cpu_count()
|
|
||||||
except NotImplementedError:
|
|
||||||
cpu_count = 1
|
|
||||||
|
|
||||||
def run_pkgconfig(name, envvar, default, flag, prefix):
|
def run_pkgconfig(name, envvar, default, flag, prefix):
|
||||||
ans = []
|
ans = []
|
||||||
if envvar:
|
if envvar:
|
||||||
|
@ -13,10 +13,10 @@ from setup import Command, islinux, isbsd, isosx, SRC, iswindows, __version__
|
|||||||
from setup.build_environment import (
|
from setup.build_environment import (
|
||||||
chmlib_inc_dirs, podofo_inc, podofo_lib, podofo_error, pyqt, NMAKE, QMAKE,
|
chmlib_inc_dirs, podofo_inc, podofo_lib, podofo_error, pyqt, NMAKE, QMAKE,
|
||||||
msvc, win_inc, win_lib, chmlib_lib_dirs, sqlite_inc_dirs, icu_inc_dirs,
|
msvc, win_inc, win_lib, chmlib_lib_dirs, sqlite_inc_dirs, icu_inc_dirs,
|
||||||
icu_lib_dirs, ft_libs, ft_lib_dirs, ft_inc_dirs, cpu_count, is64bit,
|
icu_lib_dirs, ft_libs, ft_lib_dirs, ft_inc_dirs, is64bit,
|
||||||
glib_flags, fontconfig_flags, openssl_inc_dirs, openssl_lib_dirs,
|
glib_flags, fontconfig_flags, openssl_inc_dirs, openssl_lib_dirs,
|
||||||
zlib_inc_dirs, zlib_lib_dirs, zlib_libs, qmakespec)
|
zlib_inc_dirs, zlib_lib_dirs, zlib_libs, qmakespec)
|
||||||
from setup.parallel_build import create_job, parallel_build
|
from setup.parallel_build import create_job, parallel_build, cpu_count
|
||||||
isunix = islinux or isosx or isbsd
|
isunix = islinux or isosx or isbsd
|
||||||
|
|
||||||
make = 'make' if isunix else NMAKE
|
make = 'make' if isunix else NMAKE
|
||||||
|
@ -11,7 +11,37 @@ from multiprocessing.dummy import Pool
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
|
|
||||||
from setup.build_environment import cpu_count
|
from setup import iswindows
|
||||||
|
|
||||||
|
if iswindows:
|
||||||
|
from ctypes import windll, Structure, POINTER, c_size_t
|
||||||
|
from ctypes.wintypes import WORD, DWORD, LPVOID
|
||||||
|
class SYSTEM_INFO(Structure):
|
||||||
|
_fields_ = [
|
||||||
|
("wProcessorArchitecture", WORD),
|
||||||
|
("wReserved", WORD),
|
||||||
|
("dwPageSize", DWORD),
|
||||||
|
("lpMinimumApplicationAddress", LPVOID),
|
||||||
|
("lpMaximumApplicationAddress", LPVOID),
|
||||||
|
("dwActiveProcessorMask", c_size_t),
|
||||||
|
("dwNumberOfProcessors", DWORD),
|
||||||
|
("dwProcessorType", DWORD),
|
||||||
|
("dwAllocationGranularity", DWORD),
|
||||||
|
("wProcessorLevel", WORD),
|
||||||
|
("wProcessorRevision", WORD)]
|
||||||
|
gsi = windll.kernel32.GetSystemInfo
|
||||||
|
gsi.argtypes = [POINTER(SYSTEM_INFO)]
|
||||||
|
gsi.restype = None
|
||||||
|
si = SYSTEM_INFO()
|
||||||
|
gsi(si)
|
||||||
|
cpu_count = min(16, max(1, si.dwNumberOfProcessors))
|
||||||
|
else:
|
||||||
|
from multiprocessing import cpu_count
|
||||||
|
try:
|
||||||
|
cpu_count = cpu_count()
|
||||||
|
except NotImplementedError:
|
||||||
|
cpu_count = 1
|
||||||
|
|
||||||
|
|
||||||
def run_worker(job, decorate=True):
|
def run_worker(job, decorate=True):
|
||||||
cmd, human_text = job
|
cmd, human_text = job
|
||||||
|
Loading…
x
Reference in New Issue
Block a user