Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -u numpy-1.12.1/numpy/distutils/ccompiler.py numpy-1.13.0.orig/numpy/distutils/ccompiler.py
- --- numpy-1.12.1/numpy/distutils/ccompiler.py 2017-03-05 13:13:50.000000000 -0500
- +++ numpy-1.13.0.orig/numpy/distutils/ccompiler.py 2017-06-07 09:21:24.000000000 -0400
- @@ -4,11 +4,13 @@
- import re
- import sys
- import types
- +import shlex
- +import time
- from copy import copy
- from distutils import ccompiler
- from distutils.ccompiler import *
- from distutils.errors import DistutilsExecError, DistutilsModuleError, \
- - DistutilsPlatformError
- + DistutilsPlatformError, CompileError
- from distutils.sysconfig import customize_compiler
- from distutils.version import LooseVersion
- @@ -16,8 +18,67 @@
- from numpy.distutils.compat import get_exception
- from numpy.distutils.exec_command import exec_command
- from numpy.distutils.misc_util import cyg2win32, is_sequence, mingw32, \
- - quote_args, get_num_build_jobs
- + quote_args, get_num_build_jobs, \
- + _commandline_dep_string
- +# globals for parallel build management
- +try:
- + import threading
- +except ImportError:
- + import dummy_threading as threading
- +_job_semaphore = None
- +_global_lock = threading.Lock()
- +_processing_files = set()
- +
- +
- +def _needs_build(obj, cc_args, extra_postargs, pp_opts):
- + """
- + Check if an objects needs to be rebuild based on its dependencies
- +
- + Parameters
- + ----------
- + obj : str
- + object file
- +
- + Returns
- + -------
- + bool
- + """
- + # defined in unixcompiler.py
- + dep_file = obj + '.d'
- + if not os.path.exists(dep_file):
- + return True
- +
- + # dep_file is a makefile containing 'object: dependencies'
- + # formated like posix shell (spaces escaped, \ line continuations)
- + # the last line contains the compiler commandline arguments as some
- + # projects may compile an extension multiple times with different
- + # arguments
- + with open(dep_file, "r") as f:
- + lines = f.readlines()
- +
- + cmdline =_commandline_dep_string(cc_args, extra_postargs, pp_opts)
- + last_cmdline = lines[-1]
- + if last_cmdline != cmdline:
- + return True
- +
- + contents = ''.join(lines[:-1])
- + deps = [x for x in shlex.split(contents, posix=True)
- + if x != "\n" and not x.endswith(":")]
- +
- + try:
- + t_obj = os.stat(obj).st_mtime
- +
- + # check if any of the dependencies is newer than the object
- + # the dependencies includes the source used to create the object
- + for f in deps:
- + if os.stat(f).st_mtime > t_obj:
- + return True
- + except OSError:
- + # no object counts as newer (shouldn't happen if dep_file exists)
- + return True
- +
- + return False
- def replace_method(klass, method_name, func):
- if sys.version_info[0] < 3:
- @@ -160,6 +221,16 @@
- # This method is effective only with Python >=2.3 distutils.
- # Any changes here should be applied also to fcompiler.compile
- # method to support pre Python 2.3 distutils.
- + global _job_semaphore
- +
- + jobs = get_num_build_jobs()
- +
- + # setup semaphore to not exceed number of compile jobs when parallelized at
- + # extension level (python >= 3.5)
- + with _global_lock:
- + if _job_semaphore is None:
- + _job_semaphore = threading.Semaphore(jobs)
- +
- if not sources:
- return []
- # FIXME:RELATIVE_IMPORT
- @@ -191,7 +262,30 @@
- def single_compile(args):
- obj, (src, ext) = args
- - self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
- + if not _needs_build(obj, cc_args, extra_postargs, pp_opts):
- + return
- +
- + # check if we are currently already processing the same object
- + # happens when using the same source in multiple extensions
- + while True:
- + # need explicit lock as there is no atomic check and add with GIL
- + with _global_lock:
- + # file not being worked on, start working
- + if obj not in _processing_files:
- + _processing_files.add(obj)
- + break
- + # wait for the processing to end
- + time.sleep(0.1)
- +
- + try:
- + # retrieve slot from our #job semaphore and build
- + with _job_semaphore:
- + self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
- + finally:
- + # register being done processing
- + with _global_lock:
- + _processing_files.remove(obj)
- +
- if isinstance(self, FCompiler):
- objects_to_build = list(build.keys())
- @@ -217,7 +311,6 @@
- else:
- build_items = build.items()
- - jobs = get_num_build_jobs()
- if len(build) > 1 and jobs > 1:
- # build parallel
- import multiprocessing.pool
- @@ -389,6 +482,30 @@
- log.warn("#### %s #######" % (self.compiler,))
- if not hasattr(self, 'compiler_cxx'):
- log.warn('Missing compiler_cxx fix for ' + self.__class__.__name__)
- +
- +
- + # check if compiler supports gcc style automatic dependencies
- + # run on every extension so skip for known good compilers
- + if hasattr(self, 'compiler') and ('gcc' in self.compiler[0] or
- + 'g++' in self.compiler[0] or
- + 'clang' in self.compiler[0]):
- + self._auto_depends = True
- + elif os.name == 'posix':
- + import tempfile
- + import shutil
- + tmpdir = tempfile.mkdtemp()
- + try:
- + fn = os.path.join(tmpdir, "file.c")
- + with open(fn, "w") as f:
- + f.write("int a;\n")
- + self.compile([fn], output_dir=tmpdir,
- + extra_preargs=['-MMD', '-MF', fn + '.d'])
- + self._auto_depends = True
- + except CompileError:
- + self._auto_depends = False
- + finally:
- + shutil.rmtree(tmpdir)
- +
- return
- replace_method(CCompiler, 'customize', CCompiler_customize)
- Common subdirectories: numpy-1.12.1/numpy/distutils/command and numpy-1.13.0.orig/numpy/distutils/command
- diff -u numpy-1.12.1/numpy/distutils/conv_template.py numpy-1.13.0.orig/numpy/distutils/conv_template.py
- --- numpy-1.12.1/numpy/distutils/conv_template.py 2017-03-18 09:23:22.000000000 -0400
- +++ numpy-1.13.0.orig/numpy/distutils/conv_template.py 2017-06-02 20:20:06.000000000 -0400
- @@ -1,4 +1,4 @@
- -#!/usr/bin/python
- +#!/usr/bin/env python
- """
- takes templated file .xxx.src and produces .xxx file where .xxx is
- .i or .c or .h, using the following template rules
- @@ -186,8 +186,8 @@
- if nsub is None :
- nsub = size
- elif nsub != size :
- - msg = "Mismatch in number of values:\n%s = %s" % (name, vals)
- - raise ValueError(msg)
- + msg = "Mismatch in number of values, %d != %d\n%s = %s"
- + raise ValueError(msg % (nsub, size, name, vals))
- names.append((name, vals))
- diff -u numpy-1.12.1/numpy/distutils/exec_command.py numpy-1.13.0.orig/numpy/distutils/exec_command.py
- --- numpy-1.12.1/numpy/distutils/exec_command.py 2017-03-18 09:23:22.000000000 -0400
- +++ numpy-1.13.0.orig/numpy/distutils/exec_command.py 2017-06-02 20:20:06.000000000 -0400
- @@ -1,4 +1,3 @@
- -#!/usr/bin/env python
- """
- exec_command
- @@ -56,13 +55,10 @@
- import os
- import sys
- -import shlex
- +import subprocess
- from numpy.distutils.misc_util import is_sequence, make_temp_file
- from numpy.distutils import log
- -from numpy.distutils.compat import get_exception
- -
- -from numpy.compat import open_latin1
- def temp_file_name():
- fo, name = make_temp_file()
- @@ -147,7 +143,7 @@
- """
- if hasattr(stream, 'fileno'):
- try:
- - r = stream.fileno()
- + stream.fileno()
- return True
- except IOError:
- return False
- @@ -211,28 +207,10 @@
- _update_environment( **env )
- try:
- - # _exec_command is robust but slow, it relies on
- - # usable sys.std*.fileno() descriptors. If they
- - # are bad (like in win32 Idle, PyCrust environments)
- - # then _exec_command_python (even slower)
- - # will be used as a last resort.
- - #
- - # _exec_command_posix uses os.system and is faster
- - # but not on all platforms os.system will return
- - # a correct status.
- - if (_with_python and _supports_fileno(sys.stdout) and
- - sys.stdout.fileno() == -1):
- - st = _exec_command_python(command,
- - exec_command_dir = exec_dir,
- - **env)
- - elif os.name=='posix':
- - st = _exec_command_posix(command,
- - use_shell=use_shell,
- - use_tee=use_tee,
- - **env)
- - else:
- - st = _exec_command(command, use_shell=use_shell,
- - use_tee=use_tee,**env)
- + st = _exec_command(command,
- + use_shell=use_shell,
- + use_tee=use_tee,
- + **env)
- finally:
- if oldcwd!=execute_in:
- os.chdir(oldcwd)
- @@ -241,419 +219,57 @@
- return st
- -def _exec_command_posix( command,
- - use_shell = None,
- - use_tee = None,
- - **env ):
- - log.debug('_exec_command_posix(...)')
- -
- - if is_sequence(command):
- - command_str = ' '.join(list(command))
- - else:
- - command_str = command
- -
- - tmpfile = temp_file_name()
- - stsfile = None
- - if use_tee:
- - stsfile = temp_file_name()
- - filter = ''
- - if use_tee == 2:
- - filter = r'| tr -cd "\n" | tr "\n" "."; echo'
- - command_posix = '( %s ; echo $? > %s ) 2>&1 | tee %s %s'\
- - % (command_str, stsfile, tmpfile, filter)
- - else:
- - stsfile = temp_file_name()
- - command_posix = '( %s ; echo $? > %s ) > %s 2>&1'\
- - % (command_str, stsfile, tmpfile)
- - #command_posix = '( %s ) > %s 2>&1' % (command_str,tmpfile)
- -
- - log.debug('Running os.system(%r)' % (command_posix))
- - status = os.system(command_posix)
- -
- - if use_tee:
- - if status:
- - # if command_tee fails then fall back to robust exec_command
- - log.warn('_exec_command_posix failed (status=%s)' % status)
- - return _exec_command(command, use_shell=use_shell, **env)
- -
- - if stsfile is not None:
- - f = open_latin1(stsfile, 'r')
- - status_text = f.read()
- - status = int(status_text)
- - f.close()
- - os.remove(stsfile)
- -
- - f = open_latin1(tmpfile, 'r')
- - text = f.read()
- - f.close()
- - os.remove(tmpfile)
- -
- - if text[-1:]=='\n':
- - text = text[:-1]
- -
- - return status, text
- -
- -
- -def _exec_command_python(command,
- - exec_command_dir='', **env):
- - log.debug('_exec_command_python(...)')
- -
- - python_exe = get_pythonexe()
- - cmdfile = temp_file_name()
- - stsfile = temp_file_name()
- - outfile = temp_file_name()
- -
- - f = open(cmdfile, 'w')
- - f.write('import os\n')
- - f.write('import sys\n')
- - f.write('sys.path.insert(0,%r)\n' % (exec_command_dir))
- - f.write('from exec_command import exec_command\n')
- - f.write('del sys.path[0]\n')
- - f.write('cmd = %r\n' % command)
- - f.write('os.environ = %r\n' % (os.environ))
- - f.write('s,o = exec_command(cmd, _with_python=0, **%r)\n' % (env))
- - f.write('f=open(%r,"w")\nf.write(str(s))\nf.close()\n' % (stsfile))
- - f.write('f=open(%r,"w")\nf.write(o)\nf.close()\n' % (outfile))
- - f.close()
- -
- - cmd = '%s %s' % (python_exe, cmdfile)
- - status = os.system(cmd)
- - if status:
- - raise RuntimeError("%r failed" % (cmd,))
- - os.remove(cmdfile)
- -
- - f = open_latin1(stsfile, 'r')
- - status = int(f.read())
- - f.close()
- - os.remove(stsfile)
- -
- - f = open_latin1(outfile, 'r')
- - text = f.read()
- - f.close()
- - os.remove(outfile)
- -
- - return status, text
- -
- -def quote_arg(arg):
- - if arg[0]!='"' and ' ' in arg:
- - return '"%s"' % arg
- - return arg
- -
- -def _exec_command( command, use_shell=None, use_tee = None, **env ):
- - log.debug('_exec_command(...)')
- +def _exec_command(command, use_shell=None, use_tee = None, **env):
- + """
- + Internal workhorse for exec_command().
- + """
- if use_shell is None:
- use_shell = os.name=='posix'
- if use_tee is None:
- use_tee = os.name=='posix'
- - using_command = 0
- - if use_shell:
- - # We use shell (unless use_shell==0) so that wildcards can be
- - # used.
- +
- + if os.name == 'posix' and use_shell:
- + # On POSIX, subprocess always uses /bin/sh, override
- sh = os.environ.get('SHELL', '/bin/sh')
- if is_sequence(command):
- - argv = [sh, '-c', ' '.join(list(command))]
- + command = [sh, '-c', ' '.join(command)]
- else:
- - argv = [sh, '-c', command]
- - else:
- - # On NT, DOS we avoid using command.com as it's exit status is
- - # not related to the exit status of a command.
- - if is_sequence(command):
- - argv = command[:]
- - else:
- - argv = shlex.split(command)
- + command = [sh, '-c', command]
- + use_shell = False
- - # `spawn*p` family with path (vp, vpe, ...) are not available on windows.
- - # Also prefer spawn{v,vp} in favor of spawn{ve,vpe} if no env
- - # modification is actually requested as the *e* functions are not thread
- - # safe on windows (https://bugs.python.org/issue6476)
- - if hasattr(os, 'spawnvpe'):
- - spawn_command = os.spawnvpe if env else os.spawnvp
- - else:
- - spawn_command = os.spawnve if env else os.spawnv
- - argv[0] = find_executable(argv[0]) or argv[0]
- - if not os.path.isfile(argv[0]):
- - log.warn('Executable %s does not exist' % (argv[0]))
- - if os.name in ['nt', 'dos']:
- - # argv[0] might be internal command
- - argv = [os.environ['COMSPEC'], '/C'] + argv
- - using_command = 1
- -
- - _so_has_fileno = _supports_fileno(sys.stdout)
- - _se_has_fileno = _supports_fileno(sys.stderr)
- - so_flush = sys.stdout.flush
- - se_flush = sys.stderr.flush
- - if _so_has_fileno:
- - so_fileno = sys.stdout.fileno()
- - so_dup = os.dup(so_fileno)
- - if _se_has_fileno:
- - se_fileno = sys.stderr.fileno()
- - se_dup = os.dup(se_fileno)
- -
- - outfile = temp_file_name()
- - fout = open(outfile, 'w')
- - if using_command:
- - errfile = temp_file_name()
- - ferr = open(errfile, 'w')
- -
- - log.debug('Running %s(%s,%r,%r,os.environ)' \
- - % (spawn_command.__name__, os.P_WAIT, argv[0], argv))
- -
- - if env and sys.version_info[0] >= 3 and os.name == 'nt':
- - # Pre-encode os.environ, discarding un-encodable entries,
- - # to avoid it failing during encoding as part of spawn. Failure
- - # is possible if the environment contains entries that are not
- - # encoded using the system codepage as windows expects.
- - #
- - # This is not necessary on unix, where os.environ is encoded
- - # using the surrogateescape error handler and decoded using
- - # it as part of spawn.
- - encoded_environ = {}
- - for k, v in os.environ.items():
- - try:
- - encoded_environ[k.encode(sys.getfilesystemencoding())] = v.encode(
- - sys.getfilesystemencoding())
- - except UnicodeEncodeError:
- - log.debug("ignoring un-encodable env entry %s", k)
- - else:
- - encoded_environ = os.environ
- + elif os.name == 'nt' and is_sequence(command):
- + # On Windows, join the string for CreateProcess() ourselves as
- + # subprocess does it a bit differently
- + command = ' '.join(_quote_arg(arg) for arg in command)
- - argv0 = argv[0]
- - if not using_command:
- - argv[0] = quote_arg(argv0)
- -
- - so_flush()
- - se_flush()
- - if _so_has_fileno:
- - os.dup2(fout.fileno(), so_fileno)
- -
- - if _se_has_fileno:
- - if using_command:
- - #XXX: disabled for now as it does not work from cmd under win32.
- - # Tests fail on msys
- - os.dup2(ferr.fileno(), se_fileno)
- - else:
- - os.dup2(fout.fileno(), se_fileno)
- + # Inherit environment by default
- + env = env or None
- try:
- - # Use spawnv in favor of spawnve, unless necessary
- - if env:
- - status = spawn_command(os.P_WAIT, argv0, argv, encoded_environ)
- - else:
- - status = spawn_command(os.P_WAIT, argv0, argv)
- - except Exception:
- - errmess = str(get_exception())
- - status = 999
- - sys.stderr.write('%s: %s'%(errmess, argv[0]))
- -
- - so_flush()
- - se_flush()
- - if _so_has_fileno:
- - os.dup2(so_dup, so_fileno)
- - os.close(so_dup)
- - if _se_has_fileno:
- - os.dup2(se_dup, se_fileno)
- - os.close(se_dup)
- -
- - fout.close()
- - fout = open_latin1(outfile, 'r')
- - text = fout.read()
- - fout.close()
- - os.remove(outfile)
- -
- - if using_command:
- - ferr.close()
- - ferr = open_latin1(errfile, 'r')
- - errmess = ferr.read()
- - ferr.close()
- - os.remove(errfile)
- - if errmess and not status:
- - # Not sure how to handle the case where errmess
- - # contains only warning messages and that should
- - # not be treated as errors.
- - #status = 998
- - if text:
- - text = text + '\n'
- - #text = '%sCOMMAND %r FAILED: %s' %(text,command,errmess)
- - text = text + errmess
- - print (errmess)
- - if text[-1:]=='\n':
- + proc = subprocess.Popen(command, shell=use_shell, env=env,
- + stdout=subprocess.PIPE,
- + stderr=subprocess.STDOUT,
- + universal_newlines=True)
- + except EnvironmentError:
- + # Return 127, as os.spawn*() and /bin/sh do
- + return 127, ''
- + text, err = proc.communicate()
- + # Another historical oddity
- + if text[-1:] == '\n':
- text = text[:-1]
- - if status is None:
- - status = 0
- -
- - if use_tee:
- - print (text)
- -
- - return status, text
- -
- -
- -def test_nt(**kws):
- - pythonexe = get_pythonexe()
- - echo = find_executable('echo')
- - using_cygwin_echo = echo != 'echo'
- - if using_cygwin_echo:
- - log.warn('Using cygwin echo in win32 environment is not supported')
- -
- - s, o=exec_command(pythonexe\
- - +' -c "import os;print os.environ.get(\'AAA\',\'\')"')
- - assert s==0 and o=='', (s, o)
- -
- - s, o=exec_command(pythonexe\
- - +' -c "import os;print os.environ.get(\'AAA\')"',
- - AAA='Tere')
- - assert s==0 and o=='Tere', (s, o)
- -
- - os.environ['BBB'] = 'Hi'
- - s, o=exec_command(pythonexe\
- - +' -c "import os;print os.environ.get(\'BBB\',\'\')"')
- - assert s==0 and o=='Hi', (s, o)
- -
- - s, o=exec_command(pythonexe\
- - +' -c "import os;print os.environ.get(\'BBB\',\'\')"',
- - BBB='Hey')
- - assert s==0 and o=='Hey', (s, o)
- -
- - s, o=exec_command(pythonexe\
- - +' -c "import os;print os.environ.get(\'BBB\',\'\')"')
- - assert s==0 and o=='Hi', (s, o)
- - elif 0:
- - s, o=exec_command('echo Hello')
- - assert s==0 and o=='Hello', (s, o)
- -
- - s, o=exec_command('echo a%AAA%')
- - assert s==0 and o=='a', (s, o)
- -
- - s, o=exec_command('echo a%AAA%', AAA='Tere')
- - assert s==0 and o=='aTere', (s, o)
- + if use_tee and text:
- + print(text)
- + return proc.returncode, text
- - os.environ['BBB'] = 'Hi'
- - s, o=exec_command('echo a%BBB%')
- - assert s==0 and o=='aHi', (s, o)
- - s, o=exec_command('echo a%BBB%', BBB='Hey')
- - assert s==0 and o=='aHey', (s, o)
- - s, o=exec_command('echo a%BBB%')
- - assert s==0 and o=='aHi', (s, o)
- -
- - s, o=exec_command('this_is_not_a_command')
- - assert s and o!='', (s, o)
- -
- - s, o=exec_command('type not_existing_file')
- - assert s and o!='', (s, o)
- -
- - s, o=exec_command('echo path=%path%')
- - assert s==0 and o!='', (s, o)
- -
- - s, o=exec_command('%s -c "import sys;sys.stderr.write(sys.platform)"' \
- - % pythonexe)
- - assert s==0 and o=='win32', (s, o)
- -
- - s, o=exec_command('%s -c "raise \'Ignore me.\'"' % pythonexe)
- - assert s==1 and o, (s, o)
- -
- - s, o=exec_command('%s -c "import sys;sys.stderr.write(\'0\');sys.stderr.write(\'1\');sys.stderr.write(\'2\')"'\
- - % pythonexe)
- - assert s==0 and o=='012', (s, o)
- -
- - s, o=exec_command('%s -c "import sys;sys.exit(15)"' % pythonexe)
- - assert s==15 and o=='', (s, o)
- -
- - s, o=exec_command('%s -c "print \'Heipa\'"' % pythonexe)
- - assert s==0 and o=='Heipa', (s, o)
- -
- - print ('ok')
- -
- -def test_posix(**kws):
- - s, o=exec_command("echo Hello",**kws)
- - assert s==0 and o=='Hello', (s, o)
- -
- - s, o=exec_command('echo $AAA',**kws)
- - assert s==0 and o=='', (s, o)
- -
- - s, o=exec_command('echo "$AAA"',AAA='Tere',**kws)
- - assert s==0 and o=='Tere', (s, o)
- -
- -
- - s, o=exec_command('echo "$AAA"',**kws)
- - assert s==0 and o=='', (s, o)
- -
- - os.environ['BBB'] = 'Hi'
- - s, o=exec_command('echo "$BBB"',**kws)
- - assert s==0 and o=='Hi', (s, o)
- -
- - s, o=exec_command('echo "$BBB"',BBB='Hey',**kws)
- - assert s==0 and o=='Hey', (s, o)
- -
- - s, o=exec_command('echo "$BBB"',**kws)
- - assert s==0 and o=='Hi', (s, o)
- -
- -
- - s, o=exec_command('this_is_not_a_command',**kws)
- - assert s!=0 and o!='', (s, o)
- -
- - s, o=exec_command('echo path=$PATH',**kws)
- - assert s==0 and o!='', (s, o)
- -
- - s, o=exec_command('python -c "import sys,os;sys.stderr.write(os.name)"',**kws)
- - assert s==0 and o=='posix', (s, o)
- -
- - s, o=exec_command('python -c "raise \'Ignore me.\'"',**kws)
- - assert s==1 and o, (s, o)
- -
- - s, o=exec_command('python -c "import sys;sys.stderr.write(\'0\');sys.stderr.write(\'1\');sys.stderr.write(\'2\')"',**kws)
- - assert s==0 and o=='012', (s, o)
- -
- - s, o=exec_command('python -c "import sys;sys.exit(15)"',**kws)
- - assert s==15 and o=='', (s, o)
- -
- - s, o=exec_command('python -c "print \'Heipa\'"',**kws)
- - assert s==0 and o=='Heipa', (s, o)
- -
- - print ('ok')
- -
- -def test_execute_in(**kws):
- - pythonexe = get_pythonexe()
- - tmpfile = temp_file_name()
- - fn = os.path.basename(tmpfile)
- - tmpdir = os.path.dirname(tmpfile)
- - f = open(tmpfile, 'w')
- - f.write('Hello')
- - f.close()
- -
- - s, o = exec_command('%s -c "print \'Ignore the following IOError:\','\
- - 'open(%r,\'r\')"' % (pythonexe, fn),**kws)
- - assert s and o!='', (s, o)
- - s, o = exec_command('%s -c "print open(%r,\'r\').read()"' % (pythonexe, fn),
- - execute_in = tmpdir,**kws)
- - assert s==0 and o=='Hello', (s, o)
- - os.remove(tmpfile)
- - print ('ok')
- -
- -def test_svn(**kws):
- - s, o = exec_command(['svn', 'status'],**kws)
- - assert s, (s, o)
- - print ('svn ok')
- -
- -def test_cl(**kws):
- - if os.name=='nt':
- - s, o = exec_command(['cl', '/V'],**kws)
- - assert s, (s, o)
- - print ('cl ok')
- -
- -if os.name=='posix':
- - test = test_posix
- -elif os.name in ['nt', 'dos']:
- - test = test_nt
- -else:
- - raise NotImplementedError('exec_command tests for ', os.name)
- +def _quote_arg(arg):
- + """
- + Quote the argument for safe use in a shell command line.
- + """
- + # If there is a quote in the string, assume relevants parts of the
- + # string are already quoted (e.g. '-I"C:\\Program Files\\..."')
- + if '"' not in arg and ' ' in arg:
- + return '"%s"' % arg
- + return arg
- ############################################################
- -
- -if __name__ == "__main__":
- -
- - test(use_tee=0)
- - test(use_tee=1)
- - test_execute_in(use_tee=0)
- - test_execute_in(use_tee=1)
- - test_svn(use_tee=1)
- - test_cl(use_tee=1)
- Common subdirectories: numpy-1.12.1/numpy/distutils/fcompiler and numpy-1.13.0.orig/numpy/distutils/fcompiler
- diff -u numpy-1.12.1/numpy/distutils/from_template.py numpy-1.13.0.orig/numpy/distutils/from_template.py
- --- numpy-1.12.1/numpy/distutils/from_template.py 2017-03-18 09:23:22.000000000 -0400
- +++ numpy-1.13.0.orig/numpy/distutils/from_template.py 2017-06-02 20:20:06.000000000 -0400
- @@ -1,4 +1,4 @@
- -#!/usr/bin/python
- +#!/usr/bin/env python
- """
- process_file(filename)
- diff -u numpy-1.12.1/numpy/distutils/intelccompiler.py numpy-1.13.0.orig/numpy/distutils/intelccompiler.py
- --- numpy-1.12.1/numpy/distutils/intelccompiler.py 2017-03-12 15:36:42.000000000 -0400
- +++ numpy-1.13.0.orig/numpy/distutils/intelccompiler.py 2017-06-02 20:20:06.000000000 -0400
- @@ -17,9 +17,13 @@
- def __init__(self, verbose=0, dry_run=0, force=0):
- UnixCCompiler.__init__(self, verbose, dry_run, force)
- +
- + v = self.get_version()
- + mpopt = 'openmp' if v and int(v.split('.')[0]) < 15 else 'qopenmp'
- self.cc_exe = ('icc -fPIC -fp-model strict -O3 '
- - '-fomit-frame-pointer -openmp')
- + '-fomit-frame-pointer -{}').format(mpopt)
- compiler = self.cc_exe
- +
- if platform.system() == 'Darwin':
- shared_flag = '-Wl,-undefined,dynamic_lookup'
- else:
- @@ -53,9 +57,13 @@
- def __init__(self, verbose=0, dry_run=0, force=0):
- UnixCCompiler.__init__(self, verbose, dry_run, force)
- +
- + v = self.get_version()
- + mpopt = 'openmp' if v and int(v.split('.')[0]) < 15 else 'qopenmp'
- self.cc_exe = ('icc -m64 -fPIC -fp-model strict -O3 '
- - '-fomit-frame-pointer -openmp')
- + '-fomit-frame-pointer -{}').format(mpopt)
- compiler = self.cc_exe
- +
- if platform.system() == 'Darwin':
- shared_flag = '-Wl,-undefined,dynamic_lookup'
- else:
- Common subdirectories: numpy-1.12.1/numpy/distutils/mingw and numpy-1.13.0.orig/numpy/distutils/mingw
- diff -u numpy-1.12.1/numpy/distutils/mingw32ccompiler.py numpy-1.13.0.orig/numpy/distutils/mingw32ccompiler.py
- --- numpy-1.12.1/numpy/distutils/mingw32ccompiler.py 2017-03-18 09:23:22.000000000 -0400
- +++ numpy-1.13.0.orig/numpy/distutils/mingw32ccompiler.py 2017-06-02 20:20:06.000000000 -0400
- @@ -35,8 +35,19 @@
- from distutils.errors import (DistutilsExecError, CompileError,
- UnknownFileError)
- from numpy.distutils.misc_util import (msvc_runtime_library,
- + msvc_runtime_version,
- + msvc_runtime_major,
- get_build_architecture)
- +def get_msvcr_replacement():
- + """Replacement for outdated version of get_msvcr from cygwinccompiler"""
- + msvcr = msvc_runtime_library()
- + return [] if msvcr is None else [msvcr]
- +
- +# monkey-patch cygwinccompiler with our updated version from misc_util
- +# to avoid getting an exception raised on Python 3.5
- +distutils.cygwinccompiler.get_msvcr = get_msvcr_replacement
- +
- # Useful to generate table of symbols from a dll
- _START = re.compile(r'\[Ordinal/Name Pointer\] Table')
- _TABLE = re.compile(r'^\s+\[([\s*[0-9]*)\] ([a-zA-Z0-9_]*)')
- @@ -100,8 +111,9 @@
- self.define_macro('NPY_MINGW_USE_CUSTOM_MSVCR')
- # Define the MSVC version as hint for MinGW
- - msvcr_version = '0x%03i0' % int(msvc_runtime_library().lstrip('msvcr'))
- - self.define_macro('__MSVCRT_VERSION__', msvcr_version)
- + msvcr_version = msvc_runtime_version()
- + if msvcr_version:
- + self.define_macro('__MSVCRT_VERSION__', '0x%04i' % msvcr_version)
- # MS_WIN64 should be defined when building for amd64 on windows,
- # but python headers define it only for MS compilers, which has all
- @@ -236,24 +248,37 @@
- def find_python_dll():
- - maj, min, micro = [int(i) for i in sys.version_info[:3]]
- - dllname = 'python%d%d.dll' % (maj, min)
- - print("Looking for %s" % dllname)
- -
- # We can't do much here:
- - # - find it in python main dir
- + # - find it in the virtualenv (sys.prefix)
- + # - find it in python main dir (sys.base_prefix, if in a virtualenv)
- # - in system32,
- # - ortherwise (Sxs), I don't know how to get it.
- - lib_dirs = [sys.prefix, os.path.join(sys.prefix, 'lib')]
- - try:
- - lib_dirs.append(os.path.join(os.environ['SYSTEMROOT'], 'system32'))
- - except KeyError:
- - pass
- -
- - for d in lib_dirs:
- - dll = os.path.join(d, dllname)
- - if os.path.exists(dll):
- - return dll
- + stems = [sys.prefix]
- + if sys.base_prefix != sys.prefix:
- + stems.append(sys.base_prefix)
- +
- + sub_dirs = ['', 'lib', 'bin']
- + # generate possible combinations of directory trees and sub-directories
- + lib_dirs = []
- + for stem in stems:
- + for folder in sub_dirs:
- + lib_dirs = os.path.join(stem, folder)
- +
- + # add system directory as well
- + if 'SYSTEMROOT' in os.environ:
- + lib_dirs.append(os.path.join(os.environ['SYSTEMROOT'], 'System32'))
- +
- + # search in the file system for possible candidates
- + major_version, minor_version = tuple(sys.version_info[:2])
- + patterns = ['python%d%d.dll']
- +
- + for pat in patterns:
- + dllname = pat % (major_version, minor_version)
- + print("Looking for %s" % dllname)
- + for folder in lib_dirs:
- + dll = os.path.join(folder, dllname)
- + if os.path.exists(dll):
- + return dll
- raise ValueError("%s not found in %s" % (dllname, lib_dirs))
- @@ -323,14 +348,24 @@
- if os.name != 'nt':
- return False
- - msvcr_name = msvc_runtime_library()
- + # If the version number is None, then we couldn't find the MSVC runtime at
- + # all, because we are running on a Python distribution which is customed
- + # compiled; trust that the compiler is the same as the one available to us
- + # now, and that it is capable of linking with the correct runtime without
- + # any extra options.
- + msvcr_ver = msvc_runtime_major()
- + if msvcr_ver is None:
- + log.debug('Skip building import library: '
- + 'Runtime is not compiled with MSVC')
- + return False
- # Skip using a custom library for versions < MSVC 8.0
- - if int(msvcr_name.lstrip('msvcr')) < 80:
- + if msvcr_ver < 80:
- log.debug('Skip building msvcr library:'
- ' custom functionality not present')
- return False
- + msvcr_name = msvc_runtime_library()
- if debug:
- msvcr_name += 'd'
- @@ -380,41 +415,80 @@
- else:
- raise ValueError("Unhandled arch %s" % arch)
- -def _build_import_library_amd64():
- - dll_file = find_python_dll()
- +def _check_for_import_lib():
- + """Check if an import library for the Python runtime already exists."""
- + major_version, minor_version = tuple(sys.version_info[:2])
- +
- + # patterns for the file name of the library itself
- + patterns = ['libpython%d%d.a',
- + 'libpython%d%d.dll.a',
- + 'libpython%d.%d.dll.a']
- +
- + # directory trees that may contain the library
- + stems = [sys.prefix]
- + if sys.base_prefix != sys.prefix:
- + stems.append(sys.base_prefix)
- +
- + # possible subdirectories within those trees where it is placed
- + sub_dirs = ['libs', 'lib']
- +
- + # generate a list of candidate locations
- + candidates = []
- + for pat in patterns:
- + filename = pat % (major_version, minor_version)
- + for stem_dir in stems:
- + for folder in sub_dirs:
- + candidates.append(os.path.join(stem_dir, folder, filename))
- +
- + # test the filesystem to see if we can find any of these
- + for fullname in candidates:
- + if os.path.isfile(fullname):
- + # already exists, in location given
- + return (True, fullname)
- - out_name = "libpython%d%d.a" % tuple(sys.version_info[:2])
- - out_file = os.path.join(sys.prefix, 'libs', out_name)
- - if os.path.isfile(out_file):
- - log.debug('Skip building import library: "%s" exists' %
- - (out_file))
- - return
- + # needs to be built, preferred location given first
- + return (False, candidates[0])
- - def_name = "python%d%d.def" % tuple(sys.version_info[:2])
- - def_file = os.path.join(sys.prefix, 'libs', def_name)
- +def _build_import_library_amd64():
- + out_exists, out_file = _check_for_import_lib()
- + if out_exists:
- + log.debug('Skip building import library: "%s" exists', out_file)
- + return
- + # get the runtime dll for which we are building import library
- + dll_file = find_python_dll()
- log.info('Building import library (arch=AMD64): "%s" (from %s)' %
- (out_file, dll_file))
- + # generate symbol list from this library
- + def_name = "python%d%d.def" % tuple(sys.version_info[:2])
- + def_file = os.path.join(sys.prefix, 'libs', def_name)
- generate_def(dll_file, def_file)
- + # generate import library from this symbol list
- cmd = ['dlltool', '-d', def_file, '-l', out_file]
- subprocess.Popen(cmd)
- def _build_import_library_x86():
- """ Build the import libraries for Mingw32-gcc on Windows
- """
- + out_exists, out_file = _check_for_import_lib()
- + if out_exists:
- + log.debug('Skip building import library: "%s" exists', out_file)
- + return
- +
- lib_name = "python%d%d.lib" % tuple(sys.version_info[:2])
- lib_file = os.path.join(sys.prefix, 'libs', lib_name)
- - out_name = "libpython%d%d.a" % tuple(sys.version_info[:2])
- - out_file = os.path.join(sys.prefix, 'libs', out_name)
- if not os.path.isfile(lib_file):
- - log.warn('Cannot build import library: "%s" not found' % (lib_file))
- - return
- - if os.path.isfile(out_file):
- - log.debug('Skip building import library: "%s" exists' % (out_file))
- - return
- - log.info('Building import library (ARCH=x86): "%s"' % (out_file))
- + # didn't find library file in virtualenv, try base distribution, too,
- + # and use that instead if found there
- + base_lib = os.path.join(sys.base_prefix, 'libs', lib_name)
- + if os.path.isfile(base_lib):
- + lib_file = base_lib
- + else:
- + log.warn('Cannot build import library: "%s" not found', lib_file)
- + return
- + log.info('Building import library (ARCH=x86): "%s"', out_file)
- from numpy.distutils import lib2def
- @@ -425,9 +499,9 @@
- dlist, flist = lib2def.parse_nm(nm_output)
- lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))
- - dll_name = "python%d%d.dll" % tuple(sys.version_info[:2])
- + dll_name = find_python_dll ()
- args = (dll_name, def_file, out_file)
- - cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args
- + cmd = 'dlltool --dllname "%s" --def "%s" --output-lib "%s"' % args
- status = os.system(cmd)
- # for now, fail silently
- if status:
- @@ -532,12 +606,8 @@
- """msver is the ms runtime version used for the MANIFEST."""
- # check msvcr major version are the same for linking and
- # embedding
- - msvcv = msvc_runtime_library()
- - if msvcv:
- - assert msvcv.startswith("msvcr"), msvcv
- - # Dealing with something like "mscvr90" or "mscvr100", the last
- - # last digit is the minor release, want int("9") or int("10"):
- - maj = int(msvcv[5:-1])
- + maj = msvc_runtime_major()
- + if maj:
- if not maj == int(msver):
- raise ValueError(
- "Discrepancy between linked msvcr " \
- diff -u numpy-1.12.1/numpy/distutils/misc_util.py numpy-1.13.0.orig/numpy/distutils/misc_util.py
- --- numpy-1.12.1/numpy/distutils/misc_util.py 2017-03-18 09:23:22.000000000 -0400
- +++ numpy-1.13.0.orig/numpy/distutils/misc_util.py 2017-06-07 09:21:24.000000000 -0400
- @@ -12,6 +12,7 @@
- import distutils
- from distutils.errors import DistutilsError
- +from distutils.msvccompiler import get_build_architecture
- try:
- from threading import local as tlocal
- except ImportError:
- @@ -390,21 +391,36 @@
- return True
- return False
- -def msvc_runtime_library():
- - "Return name of MSVC runtime library if Python was built with MSVC >= 7"
- +def msvc_runtime_version():
- + "Return version of MSVC runtime library, as defined by __MSC_VER__ macro"
- msc_pos = sys.version.find('MSC v.')
- if msc_pos != -1:
- - msc_ver = sys.version[msc_pos+6:msc_pos+10]
- - lib = {'1300': 'msvcr70', # MSVC 7.0
- - '1310': 'msvcr71', # MSVC 7.1
- - '1400': 'msvcr80', # MSVC 8
- - '1500': 'msvcr90', # MSVC 9 (VS 2008)
- - '1600': 'msvcr100', # MSVC 10 (aka 2010)
- - }.get(msc_ver, None)
- + msc_ver = int(sys.version[msc_pos+6:msc_pos+10])
- + else:
- + msc_ver = None
- + return msc_ver
- +
- +def msvc_runtime_library():
- + "Return name of MSVC runtime library if Python was built with MSVC >= 7"
- + ver = msvc_runtime_major ()
- + if ver:
- + if ver < 140:
- + return "msvcr%i" % ver
- + else:
- + return "vcruntime%i" % ver
- else:
- - lib = None
- - return lib
- + return None
- +def msvc_runtime_major():
- + "Return major version of MSVC runtime coded like get_build_msvc_version"
- + major = {1300: 70, # MSVC 7.0
- + 1310: 71, # MSVC 7.1
- + 1400: 80, # MSVC 8
- + 1500: 90, # MSVC 9 (aka 2008)
- + 1600: 100, # MSVC 10 (aka 2010)
- + 1900: 140, # MSVC 14 (aka 2015)
- + }.get(msvc_runtime_version(), None)
- + return major
- #########################
- @@ -525,6 +541,18 @@
- direcs.append(d[0])
- return direcs
- +def _commandline_dep_string(cc_args, extra_postargs, pp_opts):
- + """
- + Return commandline representation used to determine if a file needs
- + to be recompiled
- + """
- + cmdline = 'commandline: '
- + cmdline += ' '.join(cc_args)
- + cmdline += ' '.join(extra_postargs)
- + cmdline += ' '.join(pp_opts) + '\n'
- + return cmdline
- +
- +
- def get_dependencies(sources):
- #XXX scan sources for include statements
- return _get_headers(_get_directories(sources))
- @@ -2287,21 +2315,3 @@
- raise ValueError("Compiler instance is not msvc (%s)"\
- % compiler.compiler_type)
- return compiler._MSVCCompiler__version
- -
- -if sys.version[:3] >= '2.5':
- - def get_build_architecture():
- - from distutils.msvccompiler import get_build_architecture
- - return get_build_architecture()
- -else:
- - #copied from python 2.5.1 distutils/msvccompiler.py
- - def get_build_architecture():
- - """Return the processor architecture.
- -
- - Possible results are "Intel", "Itanium", or "AMD64".
- - """
- - prefix = " bit ("
- - i = sys.version.find(prefix)
- - if i == -1:
- - return "Intel"
- - j = sys.version.find(")", i)
- - return sys.version[i+len(prefix):j]
- diff -u numpy-1.12.1/numpy/distutils/msvc9compiler.py numpy-1.13.0.orig/numpy/distutils/msvc9compiler.py
- --- numpy-1.12.1/numpy/distutils/msvc9compiler.py 2017-03-05 13:13:50.000000000 -0500
- +++ numpy-1.13.0.orig/numpy/distutils/msvc9compiler.py 2017-06-07 09:45:06.000000000 -0400
- @@ -11,15 +11,15 @@
- Here `old` is the environment string before the base class initialize
- function is called and `new` is the string after the call. The new string
- - will be a fixed string if it is not obtained from the current enviroment,
- - or the same as the old string if obtained from the same enviroment. The aim
- + will be a fixed string if it is not obtained from the current environment,
- + or the same as the old string if obtained from the same environment. The aim
- here is not to append the new string if it is already contained in the old
- string so as to limit the growth of the environment string.
- Parameters
- ----------
- old : string
- - Previous enviroment string.
- + Previous environment string.
- new : string
- New environment string.
- @@ -29,10 +29,10 @@
- Updated environment string.
- """
- - if new in old:
- - return old
- if not old:
- return new
- + if new in old:
- + return old
- # Neither new nor old is empty. Give old priority.
- return ';'.join([old, new])
- diff -u numpy-1.12.1/numpy/distutils/msvccompiler.py numpy-1.13.0.orig/numpy/distutils/msvccompiler.py
- --- numpy-1.12.1/numpy/distutils/msvccompiler.py 2017-03-18 09:23:22.000000000 -0400
- +++ numpy-1.13.0.orig/numpy/distutils/msvccompiler.py 2017-06-02 20:20:06.000000000 -0400
- @@ -42,12 +42,12 @@
- def __init__(self, verbose=0, dry_run=0, force=0):
- _MSVCCompiler.__init__(self, verbose, dry_run, force)
- - def initialize(self, plat_name=None):
- + def initialize(self):
- # The 'lib' and 'include' variables may be overwritten
- # by MSVCCompiler.initialize, so save them for later merge.
- environ_lib = os.getenv('lib', '')
- environ_include = os.getenv('include', '')
- - _MSVCCompiler.initialize(self, plat_name)
- + _MSVCCompiler.initialize(self)
- # Merge current and previous values of 'lib' and 'include'
- os.environ['lib'] = _merge(environ_lib, os.environ['lib'])
- diff -u numpy-1.12.1/numpy/distutils/system_info.py numpy-1.13.0.orig/numpy/distutils/system_info.py
- --- numpy-1.12.1/numpy/distutils/system_info.py 2017-03-18 09:23:22.000000000 -0400
- +++ numpy-1.13.0.orig/numpy/distutils/system_info.py 2017-06-07 09:21:24.000000000 -0400
- @@ -1667,6 +1667,8 @@
- info = self.check_libs(lib_dirs, blas_libs, [])
- if info is None:
- return
- + else:
- + info['include_dirs'] = self.get_include_dirs()
- if platform.system() == 'Windows':
- # The check for windows is needed because has_cblas uses the
- # same compiler that was used to compile Python and msvc is
- Common subdirectories: numpy-1.12.1/numpy/distutils/tests and numpy-1.13.0.orig/numpy/distutils/tests
- diff -u numpy-1.12.1/numpy/distutils/unixccompiler.py numpy-1.13.0.orig/numpy/distutils/unixccompiler.py
- --- numpy-1.12.1/numpy/distutils/unixccompiler.py 2016-12-21 16:46:24.000000000 -0500
- +++ numpy-1.13.0.orig/numpy/distutils/unixccompiler.py 2017-06-02 20:20:06.000000000 -0400
- @@ -10,6 +10,7 @@
- from distutils.unixccompiler import *
- from numpy.distutils.ccompiler import replace_method
- from numpy.distutils.compat import get_exception
- +from numpy.distutils.misc_util import _commandline_dep_string
- if sys.version_info[0] < 3:
- from . import log
- @@ -44,13 +45,25 @@
- self.linker_so = llink_s.split() + opt.split()
- display = '%s: %s' % (os.path.basename(self.compiler_so[0]), src)
- +
- + # gcc style automatic dependencies, outputs a makefile (-MF) that lists
- + # all headers needed by a c file as a side effect of compilation (-MMD)
- + if getattr(self, '_auto_depends', False):
- + deps = ['-MMD', '-MF', obj + '.d']
- + else:
- + deps = []
- +
- try:
- - self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
- + self.spawn(self.compiler_so + cc_args + [src, '-o', obj] + deps +
- extra_postargs, display = display)
- except DistutilsExecError:
- msg = str(get_exception())
- raise CompileError(msg)
- + # add commandline flags to dependency file
- + with open(obj + '.d', 'a') as f:
- + f.write(_commandline_dep_string(cc_args, extra_postargs, pp_opts))
- +
- replace_method(UnixCCompiler, '_compile', UnixCCompiler__compile)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement