mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
setup.py build now runs under python3
This commit is contained in:
parent
e125996ee6
commit
3c10a86c65
@ -47,7 +47,7 @@ def run_pkgconfig(name, envvar, default, flag, prefix):
|
|||||||
if not ans:
|
if not ans:
|
||||||
try:
|
try:
|
||||||
raw = subprocess.Popen([PKGCONFIG, flag, name],
|
raw = subprocess.Popen([PKGCONFIG, flag, name],
|
||||||
stdout=subprocess.PIPE).stdout.read()
|
stdout=subprocess.PIPE).stdout.read().decode('utf-8')
|
||||||
ans = [x.strip() for x in raw.split(prefix)]
|
ans = [x.strip() for x in raw.split(prefix)]
|
||||||
ans = [x for x in ans if x and (prefix=='-l' or os.path.exists(x))]
|
ans = [x for x in ans if x and (prefix=='-l' or os.path.exists(x))]
|
||||||
except:
|
except:
|
||||||
|
@ -16,6 +16,7 @@ from setup import iswindows
|
|||||||
if iswindows:
|
if iswindows:
|
||||||
from ctypes import windll, Structure, POINTER, c_size_t
|
from ctypes import windll, Structure, POINTER, c_size_t
|
||||||
from ctypes.wintypes import WORD, DWORD, LPVOID
|
from ctypes.wintypes import WORD, DWORD, LPVOID
|
||||||
|
|
||||||
class SYSTEM_INFO(Structure):
|
class SYSTEM_INFO(Structure):
|
||||||
_fields_ = [
|
_fields_ = [
|
||||||
("wProcessorArchitecture", WORD),
|
("wProcessorArchitecture", WORD),
|
||||||
@ -44,22 +45,29 @@ else:
|
|||||||
|
|
||||||
cpu_count = min(16, max(1, cpu_count))
|
cpu_count = min(16, max(1, cpu_count))
|
||||||
|
|
||||||
|
|
||||||
def run_worker(job, decorate=True):
|
def run_worker(job, decorate=True):
|
||||||
cmd, human_text = job
|
cmd, human_text = job
|
||||||
human_text = human_text or b' '.join(cmd)
|
human_text = human_text or ' '.join(cmd)
|
||||||
try:
|
try:
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
return False, human_text, unicode(err)
|
return False, human_text, unicode(err)
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
|
if stdout:
|
||||||
|
stdout = stdout.decode('utf-8')
|
||||||
|
if stderr:
|
||||||
|
stderr = stderr.decode('utf-8')
|
||||||
if decorate:
|
if decorate:
|
||||||
stdout = bytes(human_text) + b'\n' + (stdout or b'')
|
stdout = human_text + '\n' + (stdout or '')
|
||||||
ok = p.returncode == 0
|
ok = p.returncode == 0
|
||||||
return ok, stdout, (stderr or b'')
|
return ok, stdout, (stderr or '')
|
||||||
|
|
||||||
|
|
||||||
def create_job(cmd, human_text=None):
|
def create_job(cmd, human_text=None):
|
||||||
return (cmd, human_text)
|
return (cmd, human_text)
|
||||||
|
|
||||||
|
|
||||||
def parallel_build(jobs, log, verbose=True):
|
def parallel_build(jobs, log, verbose=True):
|
||||||
p = Pool(cpu_count)
|
p = Pool(cpu_count)
|
||||||
with closing(p):
|
with closing(p):
|
||||||
@ -72,6 +80,7 @@ def parallel_build(jobs, log, verbose=True):
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def parallel_check_output(jobs, log):
|
def parallel_check_output(jobs, log):
|
||||||
p = Pool(cpu_count)
|
p = Pool(cpu_count)
|
||||||
with closing(p):
|
with closing(p):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user