Merge commit '92304597bd06531c0139db9dd8766562f38cf19e' into python3-ci
* commit '92304597bd06531c0139db9dd8766562f38cf19e': Replacing unbuffered 'os.fdopen' by proxy object to have a unbuffered stdout solution for Windows and AppVeyor that works on Python 3
This commit is contained in:
@@ -22,3 +22,20 @@ class BuildSkipper(object):
|
|||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return 'BuildSkipper(%r)' % ' '.join(self.patterns)
|
return 'BuildSkipper(%r)' % ' '.join(self.patterns)
|
||||||
|
|
||||||
|
|
||||||
|
# Taken from https://stackoverflow.com/a/107717
|
||||||
|
class Unbuffered(object):
|
||||||
|
def __init__(self, stream):
|
||||||
|
self.stream = stream
|
||||||
|
|
||||||
|
def write(self, data):
|
||||||
|
self.stream.write(data)
|
||||||
|
self.stream.flush()
|
||||||
|
|
||||||
|
def writelines(self, datas):
|
||||||
|
self.stream.writelines(datas)
|
||||||
|
self.stream.flush()
|
||||||
|
|
||||||
|
def __getattr__(self, attr):
|
||||||
|
return getattr(self.stream, attr)
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ except ImportError:
|
|||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from glob import glob
|
from glob import glob
|
||||||
|
|
||||||
from .util import prepare_command
|
from .util import prepare_command, Unbuffered
|
||||||
|
|
||||||
|
|
||||||
def build(project_dir, package_name, output_dir, test_command, test_requires, before_build, skip):
|
def build(project_dir, package_name, output_dir, test_command, test_requires, before_build, skip):
|
||||||
# Python under AppVeyor/Windows seems to be buffering by default, giving problems interleaving subprocess call output with unflushed calls to 'print'
|
# Python under AppVeyor/Windows seems to be buffering by default, giving problems interleaving subprocess call output with unflushed calls to 'print'
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
|
sys.stdout = Unbuffered(sys.stdout)
|
||||||
|
|
||||||
# run_with_env is a cmd file that sets the right environment variables to
|
# run_with_env is a cmd file that sets the right environment variables to
|
||||||
run_with_env = os.path.join(tempfile.gettempdir(), 'appveyor_run_with_env.cmd')
|
run_with_env = os.path.join(tempfile.gettempdir(), 'appveyor_run_with_env.cmd')
|
||||||
|
|||||||
Reference in New Issue
Block a user