setup.py build now runs under python3

This commit is contained in:
Kovid Goyal 2018-09-10 21:02:10 +05:30
parent e125996ee6
commit 3c10a86c65
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 13 additions and 4 deletions

View File

@ -47,7 +47,7 @@ def run_pkgconfig(name, envvar, default, flag, prefix):
if not ans:
try:
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 for x in ans if x and (prefix=='-l' or os.path.exists(x))]
except:

View File

@ -16,6 +16,7 @@ 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),
@ -44,22 +45,29 @@ else:
cpu_count = min(16, max(1, cpu_count))
def run_worker(job, decorate=True):
cmd, human_text = job
human_text = human_text or b' '.join(cmd)
human_text = human_text or ' '.join(cmd)
try:
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
except Exception as err:
return False, human_text, unicode(err)
stdout, stderr = p.communicate()
if stdout:
stdout = stdout.decode('utf-8')
if stderr:
stderr = stderr.decode('utf-8')
if decorate:
stdout = bytes(human_text) + b'\n' + (stdout or b'')
stdout = human_text + '\n' + (stdout or '')
ok = p.returncode == 0
return ok, stdout, (stderr or b'')
return ok, stdout, (stderr or '')
def create_job(cmd, human_text=None):
return (cmd, human_text)
def parallel_build(jobs, log, verbose=True):
p = Pool(cpu_count)
with closing(p):
@ -72,6 +80,7 @@ def parallel_build(jobs, log, verbose=True):
return False
return True
def parallel_check_output(jobs, log):
p = Pool(cpu_count)
with closing(p):