Advertisement
Guest User

Untitled

a guest
Jun 12th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 44.14 KB | None | 0 0
  1. diff -u numpy-1.12.1/numpy/distutils/ccompiler.py numpy-1.13.0.orig/numpy/distutils/ccompiler.py
  2. --- numpy-1.12.1/numpy/distutils/ccompiler.py 2017-03-05 13:13:50.000000000 -0500
  3. +++ numpy-1.13.0.orig/numpy/distutils/ccompiler.py 2017-06-07 09:21:24.000000000 -0400
  4. @@ -4,11 +4,13 @@
  5. import re
  6. import sys
  7. import types
  8. +import shlex
  9. +import time
  10. from copy import copy
  11. from distutils import ccompiler
  12. from distutils.ccompiler import *
  13. from distutils.errors import DistutilsExecError, DistutilsModuleError, \
  14. - DistutilsPlatformError
  15. + DistutilsPlatformError, CompileError
  16. from distutils.sysconfig import customize_compiler
  17. from distutils.version import LooseVersion
  18.  
  19. @@ -16,8 +18,67 @@
  20. from numpy.distutils.compat import get_exception
  21. from numpy.distutils.exec_command import exec_command
  22. from numpy.distutils.misc_util import cyg2win32, is_sequence, mingw32, \
  23. - quote_args, get_num_build_jobs
  24. + quote_args, get_num_build_jobs, \
  25. + _commandline_dep_string
  26.  
  27. +# globals for parallel build management
  28. +try:
  29. + import threading
  30. +except ImportError:
  31. + import dummy_threading as threading
  32. +_job_semaphore = None
  33. +_global_lock = threading.Lock()
  34. +_processing_files = set()
  35. +
  36. +
  37. +def _needs_build(obj, cc_args, extra_postargs, pp_opts):
  38. + """
  39. + Check if an objects needs to be rebuild based on its dependencies
  40. +
  41. + Parameters
  42. + ----------
  43. + obj : str
  44. + object file
  45. +
  46. + Returns
  47. + -------
  48. + bool
  49. + """
  50. + # defined in unixcompiler.py
  51. + dep_file = obj + '.d'
  52. + if not os.path.exists(dep_file):
  53. + return True
  54. +
  55. + # dep_file is a makefile containing 'object: dependencies'
  56. + # formated like posix shell (spaces escaped, \ line continuations)
  57. + # the last line contains the compiler commandline arguments as some
  58. + # projects may compile an extension multiple times with different
  59. + # arguments
  60. + with open(dep_file, "r") as f:
  61. + lines = f.readlines()
  62. +
  63. + cmdline =_commandline_dep_string(cc_args, extra_postargs, pp_opts)
  64. + last_cmdline = lines[-1]
  65. + if last_cmdline != cmdline:
  66. + return True
  67. +
  68. + contents = ''.join(lines[:-1])
  69. + deps = [x for x in shlex.split(contents, posix=True)
  70. + if x != "\n" and not x.endswith(":")]
  71. +
  72. + try:
  73. + t_obj = os.stat(obj).st_mtime
  74. +
  75. + # check if any of the dependencies is newer than the object
  76. + # the dependencies includes the source used to create the object
  77. + for f in deps:
  78. + if os.stat(f).st_mtime > t_obj:
  79. + return True
  80. + except OSError:
  81. + # no object counts as newer (shouldn't happen if dep_file exists)
  82. + return True
  83. +
  84. + return False
  85.  
  86. def replace_method(klass, method_name, func):
  87. if sys.version_info[0] < 3:
  88. @@ -160,6 +221,16 @@
  89. # This method is effective only with Python >=2.3 distutils.
  90. # Any changes here should be applied also to fcompiler.compile
  91. # method to support pre Python 2.3 distutils.
  92. + global _job_semaphore
  93. +
  94. + jobs = get_num_build_jobs()
  95. +
  96. + # setup semaphore to not exceed number of compile jobs when parallelized at
  97. + # extension level (python >= 3.5)
  98. + with _global_lock:
  99. + if _job_semaphore is None:
  100. + _job_semaphore = threading.Semaphore(jobs)
  101. +
  102. if not sources:
  103. return []
  104. # FIXME:RELATIVE_IMPORT
  105. @@ -191,7 +262,30 @@
  106.  
  107. def single_compile(args):
  108. obj, (src, ext) = args
  109. - self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
  110. + if not _needs_build(obj, cc_args, extra_postargs, pp_opts):
  111. + return
  112. +
  113. + # check if we are currently already processing the same object
  114. + # happens when using the same source in multiple extensions
  115. + while True:
  116. + # need explicit lock as there is no atomic check and add with GIL
  117. + with _global_lock:
  118. + # file not being worked on, start working
  119. + if obj not in _processing_files:
  120. + _processing_files.add(obj)
  121. + break
  122. + # wait for the processing to end
  123. + time.sleep(0.1)
  124. +
  125. + try:
  126. + # retrieve slot from our #job semaphore and build
  127. + with _job_semaphore:
  128. + self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
  129. + finally:
  130. + # register being done processing
  131. + with _global_lock:
  132. + _processing_files.remove(obj)
  133. +
  134.  
  135. if isinstance(self, FCompiler):
  136. objects_to_build = list(build.keys())
  137. @@ -217,7 +311,6 @@
  138. else:
  139. build_items = build.items()
  140.  
  141. - jobs = get_num_build_jobs()
  142. if len(build) > 1 and jobs > 1:
  143. # build parallel
  144. import multiprocessing.pool
  145. @@ -389,6 +482,30 @@
  146. log.warn("#### %s #######" % (self.compiler,))
  147. if not hasattr(self, 'compiler_cxx'):
  148. log.warn('Missing compiler_cxx fix for ' + self.__class__.__name__)
  149. +
  150. +
  151. + # check if compiler supports gcc style automatic dependencies
  152. + # run on every extension so skip for known good compilers
  153. + if hasattr(self, 'compiler') and ('gcc' in self.compiler[0] or
  154. + 'g++' in self.compiler[0] or
  155. + 'clang' in self.compiler[0]):
  156. + self._auto_depends = True
  157. + elif os.name == 'posix':
  158. + import tempfile
  159. + import shutil
  160. + tmpdir = tempfile.mkdtemp()
  161. + try:
  162. + fn = os.path.join(tmpdir, "file.c")
  163. + with open(fn, "w") as f:
  164. + f.write("int a;\n")
  165. + self.compile([fn], output_dir=tmpdir,
  166. + extra_preargs=['-MMD', '-MF', fn + '.d'])
  167. + self._auto_depends = True
  168. + except CompileError:
  169. + self._auto_depends = False
  170. + finally:
  171. + shutil.rmtree(tmpdir)
  172. +
  173. return
  174.  
  175. replace_method(CCompiler, 'customize', CCompiler_customize)
  176. Common subdirectories: numpy-1.12.1/numpy/distutils/command and numpy-1.13.0.orig/numpy/distutils/command
  177. diff -u numpy-1.12.1/numpy/distutils/conv_template.py numpy-1.13.0.orig/numpy/distutils/conv_template.py
  178. --- numpy-1.12.1/numpy/distutils/conv_template.py 2017-03-18 09:23:22.000000000 -0400
  179. +++ numpy-1.13.0.orig/numpy/distutils/conv_template.py 2017-06-02 20:20:06.000000000 -0400
  180. @@ -1,4 +1,4 @@
  181. -#!/usr/bin/python
  182. +#!/usr/bin/env python
  183. """
  184. takes templated file .xxx.src and produces .xxx file where .xxx is
  185. .i or .c or .h, using the following template rules
  186. @@ -186,8 +186,8 @@
  187. if nsub is None :
  188. nsub = size
  189. elif nsub != size :
  190. - msg = "Mismatch in number of values:\n%s = %s" % (name, vals)
  191. - raise ValueError(msg)
  192. + msg = "Mismatch in number of values, %d != %d\n%s = %s"
  193. + raise ValueError(msg % (nsub, size, name, vals))
  194. names.append((name, vals))
  195.  
  196.  
  197. diff -u numpy-1.12.1/numpy/distutils/exec_command.py numpy-1.13.0.orig/numpy/distutils/exec_command.py
  198. --- numpy-1.12.1/numpy/distutils/exec_command.py 2017-03-18 09:23:22.000000000 -0400
  199. +++ numpy-1.13.0.orig/numpy/distutils/exec_command.py 2017-06-02 20:20:06.000000000 -0400
  200. @@ -1,4 +1,3 @@
  201. -#!/usr/bin/env python
  202. """
  203. exec_command
  204.  
  205. @@ -56,13 +55,10 @@
  206.  
  207. import os
  208. import sys
  209. -import shlex
  210. +import subprocess
  211.  
  212. from numpy.distutils.misc_util import is_sequence, make_temp_file
  213. from numpy.distutils import log
  214. -from numpy.distutils.compat import get_exception
  215. -
  216. -from numpy.compat import open_latin1
  217.  
  218. def temp_file_name():
  219. fo, name = make_temp_file()
  220. @@ -147,7 +143,7 @@
  221. """
  222. if hasattr(stream, 'fileno'):
  223. try:
  224. - r = stream.fileno()
  225. + stream.fileno()
  226. return True
  227. except IOError:
  228. return False
  229. @@ -211,28 +207,10 @@
  230. _update_environment( **env )
  231.  
  232. try:
  233. - # _exec_command is robust but slow, it relies on
  234. - # usable sys.std*.fileno() descriptors. If they
  235. - # are bad (like in win32 Idle, PyCrust environments)
  236. - # then _exec_command_python (even slower)
  237. - # will be used as a last resort.
  238. - #
  239. - # _exec_command_posix uses os.system and is faster
  240. - # but not on all platforms os.system will return
  241. - # a correct status.
  242. - if (_with_python and _supports_fileno(sys.stdout) and
  243. - sys.stdout.fileno() == -1):
  244. - st = _exec_command_python(command,
  245. - exec_command_dir = exec_dir,
  246. - **env)
  247. - elif os.name=='posix':
  248. - st = _exec_command_posix(command,
  249. - use_shell=use_shell,
  250. - use_tee=use_tee,
  251. - **env)
  252. - else:
  253. - st = _exec_command(command, use_shell=use_shell,
  254. - use_tee=use_tee,**env)
  255. + st = _exec_command(command,
  256. + use_shell=use_shell,
  257. + use_tee=use_tee,
  258. + **env)
  259. finally:
  260. if oldcwd!=execute_in:
  261. os.chdir(oldcwd)
  262. @@ -241,419 +219,57 @@
  263.  
  264. return st
  265.  
  266. -def _exec_command_posix( command,
  267. - use_shell = None,
  268. - use_tee = None,
  269. - **env ):
  270. - log.debug('_exec_command_posix(...)')
  271. -
  272. - if is_sequence(command):
  273. - command_str = ' '.join(list(command))
  274. - else:
  275. - command_str = command
  276. -
  277. - tmpfile = temp_file_name()
  278. - stsfile = None
  279. - if use_tee:
  280. - stsfile = temp_file_name()
  281. - filter = ''
  282. - if use_tee == 2:
  283. - filter = r'| tr -cd "\n" | tr "\n" "."; echo'
  284. - command_posix = '( %s ; echo $? > %s ) 2>&1 | tee %s %s'\
  285. - % (command_str, stsfile, tmpfile, filter)
  286. - else:
  287. - stsfile = temp_file_name()
  288. - command_posix = '( %s ; echo $? > %s ) > %s 2>&1'\
  289. - % (command_str, stsfile, tmpfile)
  290. - #command_posix = '( %s ) > %s 2>&1' % (command_str,tmpfile)
  291. -
  292. - log.debug('Running os.system(%r)' % (command_posix))
  293. - status = os.system(command_posix)
  294. -
  295. - if use_tee:
  296. - if status:
  297. - # if command_tee fails then fall back to robust exec_command
  298. - log.warn('_exec_command_posix failed (status=%s)' % status)
  299. - return _exec_command(command, use_shell=use_shell, **env)
  300. -
  301. - if stsfile is not None:
  302. - f = open_latin1(stsfile, 'r')
  303. - status_text = f.read()
  304. - status = int(status_text)
  305. - f.close()
  306. - os.remove(stsfile)
  307. -
  308. - f = open_latin1(tmpfile, 'r')
  309. - text = f.read()
  310. - f.close()
  311. - os.remove(tmpfile)
  312. -
  313. - if text[-1:]=='\n':
  314. - text = text[:-1]
  315. -
  316. - return status, text
  317. -
  318. -
  319. -def _exec_command_python(command,
  320. - exec_command_dir='', **env):
  321. - log.debug('_exec_command_python(...)')
  322. -
  323. - python_exe = get_pythonexe()
  324. - cmdfile = temp_file_name()
  325. - stsfile = temp_file_name()
  326. - outfile = temp_file_name()
  327. -
  328. - f = open(cmdfile, 'w')
  329. - f.write('import os\n')
  330. - f.write('import sys\n')
  331. - f.write('sys.path.insert(0,%r)\n' % (exec_command_dir))
  332. - f.write('from exec_command import exec_command\n')
  333. - f.write('del sys.path[0]\n')
  334. - f.write('cmd = %r\n' % command)
  335. - f.write('os.environ = %r\n' % (os.environ))
  336. - f.write('s,o = exec_command(cmd, _with_python=0, **%r)\n' % (env))
  337. - f.write('f=open(%r,"w")\nf.write(str(s))\nf.close()\n' % (stsfile))
  338. - f.write('f=open(%r,"w")\nf.write(o)\nf.close()\n' % (outfile))
  339. - f.close()
  340. -
  341. - cmd = '%s %s' % (python_exe, cmdfile)
  342. - status = os.system(cmd)
  343. - if status:
  344. - raise RuntimeError("%r failed" % (cmd,))
  345. - os.remove(cmdfile)
  346. -
  347. - f = open_latin1(stsfile, 'r')
  348. - status = int(f.read())
  349. - f.close()
  350. - os.remove(stsfile)
  351. -
  352. - f = open_latin1(outfile, 'r')
  353. - text = f.read()
  354. - f.close()
  355. - os.remove(outfile)
  356. -
  357. - return status, text
  358. -
  359. -def quote_arg(arg):
  360. - if arg[0]!='"' and ' ' in arg:
  361. - return '"%s"' % arg
  362. - return arg
  363. -
  364. -def _exec_command( command, use_shell=None, use_tee = None, **env ):
  365. - log.debug('_exec_command(...)')
  366.  
  367. +def _exec_command(command, use_shell=None, use_tee = None, **env):
  368. + """
  369. + Internal workhorse for exec_command().
  370. + """
  371. if use_shell is None:
  372. use_shell = os.name=='posix'
  373. if use_tee is None:
  374. use_tee = os.name=='posix'
  375. - using_command = 0
  376. - if use_shell:
  377. - # We use shell (unless use_shell==0) so that wildcards can be
  378. - # used.
  379. +
  380. + if os.name == 'posix' and use_shell:
  381. + # On POSIX, subprocess always uses /bin/sh, override
  382. sh = os.environ.get('SHELL', '/bin/sh')
  383. if is_sequence(command):
  384. - argv = [sh, '-c', ' '.join(list(command))]
  385. + command = [sh, '-c', ' '.join(command)]
  386. else:
  387. - argv = [sh, '-c', command]
  388. - else:
  389. - # On NT, DOS we avoid using command.com as it's exit status is
  390. - # not related to the exit status of a command.
  391. - if is_sequence(command):
  392. - argv = command[:]
  393. - else:
  394. - argv = shlex.split(command)
  395. + command = [sh, '-c', command]
  396. + use_shell = False
  397.  
  398. - # `spawn*p` family with path (vp, vpe, ...) are not available on windows.
  399. - # Also prefer spawn{v,vp} in favor of spawn{ve,vpe} if no env
  400. - # modification is actually requested as the *e* functions are not thread
  401. - # safe on windows (https://bugs.python.org/issue6476)
  402. - if hasattr(os, 'spawnvpe'):
  403. - spawn_command = os.spawnvpe if env else os.spawnvp
  404. - else:
  405. - spawn_command = os.spawnve if env else os.spawnv
  406. - argv[0] = find_executable(argv[0]) or argv[0]
  407. - if not os.path.isfile(argv[0]):
  408. - log.warn('Executable %s does not exist' % (argv[0]))
  409. - if os.name in ['nt', 'dos']:
  410. - # argv[0] might be internal command
  411. - argv = [os.environ['COMSPEC'], '/C'] + argv
  412. - using_command = 1
  413. -
  414. - _so_has_fileno = _supports_fileno(sys.stdout)
  415. - _se_has_fileno = _supports_fileno(sys.stderr)
  416. - so_flush = sys.stdout.flush
  417. - se_flush = sys.stderr.flush
  418. - if _so_has_fileno:
  419. - so_fileno = sys.stdout.fileno()
  420. - so_dup = os.dup(so_fileno)
  421. - if _se_has_fileno:
  422. - se_fileno = sys.stderr.fileno()
  423. - se_dup = os.dup(se_fileno)
  424. -
  425. - outfile = temp_file_name()
  426. - fout = open(outfile, 'w')
  427. - if using_command:
  428. - errfile = temp_file_name()
  429. - ferr = open(errfile, 'w')
  430. -
  431. - log.debug('Running %s(%s,%r,%r,os.environ)' \
  432. - % (spawn_command.__name__, os.P_WAIT, argv[0], argv))
  433. -
  434. - if env and sys.version_info[0] >= 3 and os.name == 'nt':
  435. - # Pre-encode os.environ, discarding un-encodable entries,
  436. - # to avoid it failing during encoding as part of spawn. Failure
  437. - # is possible if the environment contains entries that are not
  438. - # encoded using the system codepage as windows expects.
  439. - #
  440. - # This is not necessary on unix, where os.environ is encoded
  441. - # using the surrogateescape error handler and decoded using
  442. - # it as part of spawn.
  443. - encoded_environ = {}
  444. - for k, v in os.environ.items():
  445. - try:
  446. - encoded_environ[k.encode(sys.getfilesystemencoding())] = v.encode(
  447. - sys.getfilesystemencoding())
  448. - except UnicodeEncodeError:
  449. - log.debug("ignoring un-encodable env entry %s", k)
  450. - else:
  451. - encoded_environ = os.environ
  452. + elif os.name == 'nt' and is_sequence(command):
  453. + # On Windows, join the string for CreateProcess() ourselves as
  454. + # subprocess does it a bit differently
  455. + command = ' '.join(_quote_arg(arg) for arg in command)
  456.  
  457. - argv0 = argv[0]
  458. - if not using_command:
  459. - argv[0] = quote_arg(argv0)
  460. -
  461. - so_flush()
  462. - se_flush()
  463. - if _so_has_fileno:
  464. - os.dup2(fout.fileno(), so_fileno)
  465. -
  466. - if _se_has_fileno:
  467. - if using_command:
  468. - #XXX: disabled for now as it does not work from cmd under win32.
  469. - # Tests fail on msys
  470. - os.dup2(ferr.fileno(), se_fileno)
  471. - else:
  472. - os.dup2(fout.fileno(), se_fileno)
  473. + # Inherit environment by default
  474. + env = env or None
  475. try:
  476. - # Use spawnv in favor of spawnve, unless necessary
  477. - if env:
  478. - status = spawn_command(os.P_WAIT, argv0, argv, encoded_environ)
  479. - else:
  480. - status = spawn_command(os.P_WAIT, argv0, argv)
  481. - except Exception:
  482. - errmess = str(get_exception())
  483. - status = 999
  484. - sys.stderr.write('%s: %s'%(errmess, argv[0]))
  485. -
  486. - so_flush()
  487. - se_flush()
  488. - if _so_has_fileno:
  489. - os.dup2(so_dup, so_fileno)
  490. - os.close(so_dup)
  491. - if _se_has_fileno:
  492. - os.dup2(se_dup, se_fileno)
  493. - os.close(se_dup)
  494. -
  495. - fout.close()
  496. - fout = open_latin1(outfile, 'r')
  497. - text = fout.read()
  498. - fout.close()
  499. - os.remove(outfile)
  500. -
  501. - if using_command:
  502. - ferr.close()
  503. - ferr = open_latin1(errfile, 'r')
  504. - errmess = ferr.read()
  505. - ferr.close()
  506. - os.remove(errfile)
  507. - if errmess and not status:
  508. - # Not sure how to handle the case where errmess
  509. - # contains only warning messages and that should
  510. - # not be treated as errors.
  511. - #status = 998
  512. - if text:
  513. - text = text + '\n'
  514. - #text = '%sCOMMAND %r FAILED: %s' %(text,command,errmess)
  515. - text = text + errmess
  516. - print (errmess)
  517. - if text[-1:]=='\n':
  518. + proc = subprocess.Popen(command, shell=use_shell, env=env,
  519. + stdout=subprocess.PIPE,
  520. + stderr=subprocess.STDOUT,
  521. + universal_newlines=True)
  522. + except EnvironmentError:
  523. + # Return 127, as os.spawn*() and /bin/sh do
  524. + return 127, ''
  525. + text, err = proc.communicate()
  526. + # Another historical oddity
  527. + if text[-1:] == '\n':
  528. text = text[:-1]
  529. - if status is None:
  530. - status = 0
  531. -
  532. - if use_tee:
  533. - print (text)
  534. -
  535. - return status, text
  536. -
  537. -
  538. -def test_nt(**kws):
  539. - pythonexe = get_pythonexe()
  540. - echo = find_executable('echo')
  541. - using_cygwin_echo = echo != 'echo'
  542. - if using_cygwin_echo:
  543. - log.warn('Using cygwin echo in win32 environment is not supported')
  544. -
  545. - s, o=exec_command(pythonexe\
  546. - +' -c "import os;print os.environ.get(\'AAA\',\'\')"')
  547. - assert s==0 and o=='', (s, o)
  548. -
  549. - s, o=exec_command(pythonexe\
  550. - +' -c "import os;print os.environ.get(\'AAA\')"',
  551. - AAA='Tere')
  552. - assert s==0 and o=='Tere', (s, o)
  553. -
  554. - os.environ['BBB'] = 'Hi'
  555. - s, o=exec_command(pythonexe\
  556. - +' -c "import os;print os.environ.get(\'BBB\',\'\')"')
  557. - assert s==0 and o=='Hi', (s, o)
  558. -
  559. - s, o=exec_command(pythonexe\
  560. - +' -c "import os;print os.environ.get(\'BBB\',\'\')"',
  561. - BBB='Hey')
  562. - assert s==0 and o=='Hey', (s, o)
  563. -
  564. - s, o=exec_command(pythonexe\
  565. - +' -c "import os;print os.environ.get(\'BBB\',\'\')"')
  566. - assert s==0 and o=='Hi', (s, o)
  567. - elif 0:
  568. - s, o=exec_command('echo Hello')
  569. - assert s==0 and o=='Hello', (s, o)
  570. -
  571. - s, o=exec_command('echo a%AAA%')
  572. - assert s==0 and o=='a', (s, o)
  573. -
  574. - s, o=exec_command('echo a%AAA%', AAA='Tere')
  575. - assert s==0 and o=='aTere', (s, o)
  576. + if use_tee and text:
  577. + print(text)
  578. + return proc.returncode, text
  579.  
  580. - os.environ['BBB'] = 'Hi'
  581. - s, o=exec_command('echo a%BBB%')
  582. - assert s==0 and o=='aHi', (s, o)
  583.  
  584. - s, o=exec_command('echo a%BBB%', BBB='Hey')
  585. - assert s==0 and o=='aHey', (s, o)
  586. - s, o=exec_command('echo a%BBB%')
  587. - assert s==0 and o=='aHi', (s, o)
  588. -
  589. - s, o=exec_command('this_is_not_a_command')
  590. - assert s and o!='', (s, o)
  591. -
  592. - s, o=exec_command('type not_existing_file')
  593. - assert s and o!='', (s, o)
  594. -
  595. - s, o=exec_command('echo path=%path%')
  596. - assert s==0 and o!='', (s, o)
  597. -
  598. - s, o=exec_command('%s -c "import sys;sys.stderr.write(sys.platform)"' \
  599. - % pythonexe)
  600. - assert s==0 and o=='win32', (s, o)
  601. -
  602. - s, o=exec_command('%s -c "raise \'Ignore me.\'"' % pythonexe)
  603. - assert s==1 and o, (s, o)
  604. -
  605. - s, o=exec_command('%s -c "import sys;sys.stderr.write(\'0\');sys.stderr.write(\'1\');sys.stderr.write(\'2\')"'\
  606. - % pythonexe)
  607. - assert s==0 and o=='012', (s, o)
  608. -
  609. - s, o=exec_command('%s -c "import sys;sys.exit(15)"' % pythonexe)
  610. - assert s==15 and o=='', (s, o)
  611. -
  612. - s, o=exec_command('%s -c "print \'Heipa\'"' % pythonexe)
  613. - assert s==0 and o=='Heipa', (s, o)
  614. -
  615. - print ('ok')
  616. -
  617. -def test_posix(**kws):
  618. - s, o=exec_command("echo Hello",**kws)
  619. - assert s==0 and o=='Hello', (s, o)
  620. -
  621. - s, o=exec_command('echo $AAA',**kws)
  622. - assert s==0 and o=='', (s, o)
  623. -
  624. - s, o=exec_command('echo "$AAA"',AAA='Tere',**kws)
  625. - assert s==0 and o=='Tere', (s, o)
  626. -
  627. -
  628. - s, o=exec_command('echo "$AAA"',**kws)
  629. - assert s==0 and o=='', (s, o)
  630. -
  631. - os.environ['BBB'] = 'Hi'
  632. - s, o=exec_command('echo "$BBB"',**kws)
  633. - assert s==0 and o=='Hi', (s, o)
  634. -
  635. - s, o=exec_command('echo "$BBB"',BBB='Hey',**kws)
  636. - assert s==0 and o=='Hey', (s, o)
  637. -
  638. - s, o=exec_command('echo "$BBB"',**kws)
  639. - assert s==0 and o=='Hi', (s, o)
  640. -
  641. -
  642. - s, o=exec_command('this_is_not_a_command',**kws)
  643. - assert s!=0 and o!='', (s, o)
  644. -
  645. - s, o=exec_command('echo path=$PATH',**kws)
  646. - assert s==0 and o!='', (s, o)
  647. -
  648. - s, o=exec_command('python -c "import sys,os;sys.stderr.write(os.name)"',**kws)
  649. - assert s==0 and o=='posix', (s, o)
  650. -
  651. - s, o=exec_command('python -c "raise \'Ignore me.\'"',**kws)
  652. - assert s==1 and o, (s, o)
  653. -
  654. - s, o=exec_command('python -c "import sys;sys.stderr.write(\'0\');sys.stderr.write(\'1\');sys.stderr.write(\'2\')"',**kws)
  655. - assert s==0 and o=='012', (s, o)
  656. -
  657. - s, o=exec_command('python -c "import sys;sys.exit(15)"',**kws)
  658. - assert s==15 and o=='', (s, o)
  659. -
  660. - s, o=exec_command('python -c "print \'Heipa\'"',**kws)
  661. - assert s==0 and o=='Heipa', (s, o)
  662. -
  663. - print ('ok')
  664. -
  665. -def test_execute_in(**kws):
  666. - pythonexe = get_pythonexe()
  667. - tmpfile = temp_file_name()
  668. - fn = os.path.basename(tmpfile)
  669. - tmpdir = os.path.dirname(tmpfile)
  670. - f = open(tmpfile, 'w')
  671. - f.write('Hello')
  672. - f.close()
  673. -
  674. - s, o = exec_command('%s -c "print \'Ignore the following IOError:\','\
  675. - 'open(%r,\'r\')"' % (pythonexe, fn),**kws)
  676. - assert s and o!='', (s, o)
  677. - s, o = exec_command('%s -c "print open(%r,\'r\').read()"' % (pythonexe, fn),
  678. - execute_in = tmpdir,**kws)
  679. - assert s==0 and o=='Hello', (s, o)
  680. - os.remove(tmpfile)
  681. - print ('ok')
  682. -
  683. -def test_svn(**kws):
  684. - s, o = exec_command(['svn', 'status'],**kws)
  685. - assert s, (s, o)
  686. - print ('svn ok')
  687. -
  688. -def test_cl(**kws):
  689. - if os.name=='nt':
  690. - s, o = exec_command(['cl', '/V'],**kws)
  691. - assert s, (s, o)
  692. - print ('cl ok')
  693. -
  694. -if os.name=='posix':
  695. - test = test_posix
  696. -elif os.name in ['nt', 'dos']:
  697. - test = test_nt
  698. -else:
  699. - raise NotImplementedError('exec_command tests for ', os.name)
  700. +def _quote_arg(arg):
  701. + """
  702. + Quote the argument for safe use in a shell command line.
  703. + """
  704. + # If there is a quote in the string, assume relevants parts of the
  705. + # string are already quoted (e.g. '-I"C:\\Program Files\\..."')
  706. + if '"' not in arg and ' ' in arg:
  707. + return '"%s"' % arg
  708. + return arg
  709.  
  710. ############################################################
  711. -
  712. -if __name__ == "__main__":
  713. -
  714. - test(use_tee=0)
  715. - test(use_tee=1)
  716. - test_execute_in(use_tee=0)
  717. - test_execute_in(use_tee=1)
  718. - test_svn(use_tee=1)
  719. - test_cl(use_tee=1)
  720. Common subdirectories: numpy-1.12.1/numpy/distutils/fcompiler and numpy-1.13.0.orig/numpy/distutils/fcompiler
  721. diff -u numpy-1.12.1/numpy/distutils/from_template.py numpy-1.13.0.orig/numpy/distutils/from_template.py
  722. --- numpy-1.12.1/numpy/distutils/from_template.py 2017-03-18 09:23:22.000000000 -0400
  723. +++ numpy-1.13.0.orig/numpy/distutils/from_template.py 2017-06-02 20:20:06.000000000 -0400
  724. @@ -1,4 +1,4 @@
  725. -#!/usr/bin/python
  726. +#!/usr/bin/env python
  727. """
  728.  
  729. process_file(filename)
  730. diff -u numpy-1.12.1/numpy/distutils/intelccompiler.py numpy-1.13.0.orig/numpy/distutils/intelccompiler.py
  731. --- numpy-1.12.1/numpy/distutils/intelccompiler.py 2017-03-12 15:36:42.000000000 -0400
  732. +++ numpy-1.13.0.orig/numpy/distutils/intelccompiler.py 2017-06-02 20:20:06.000000000 -0400
  733. @@ -17,9 +17,13 @@
  734.  
  735. def __init__(self, verbose=0, dry_run=0, force=0):
  736. UnixCCompiler.__init__(self, verbose, dry_run, force)
  737. +
  738. + v = self.get_version()
  739. + mpopt = 'openmp' if v and int(v.split('.')[0]) < 15 else 'qopenmp'
  740. self.cc_exe = ('icc -fPIC -fp-model strict -O3 '
  741. - '-fomit-frame-pointer -openmp')
  742. + '-fomit-frame-pointer -{}').format(mpopt)
  743. compiler = self.cc_exe
  744. +
  745. if platform.system() == 'Darwin':
  746. shared_flag = '-Wl,-undefined,dynamic_lookup'
  747. else:
  748. @@ -53,9 +57,13 @@
  749.  
  750. def __init__(self, verbose=0, dry_run=0, force=0):
  751. UnixCCompiler.__init__(self, verbose, dry_run, force)
  752. +
  753. + v = self.get_version()
  754. + mpopt = 'openmp' if v and int(v.split('.')[0]) < 15 else 'qopenmp'
  755. self.cc_exe = ('icc -m64 -fPIC -fp-model strict -O3 '
  756. - '-fomit-frame-pointer -openmp')
  757. + '-fomit-frame-pointer -{}').format(mpopt)
  758. compiler = self.cc_exe
  759. +
  760. if platform.system() == 'Darwin':
  761. shared_flag = '-Wl,-undefined,dynamic_lookup'
  762. else:
  763. Common subdirectories: numpy-1.12.1/numpy/distutils/mingw and numpy-1.13.0.orig/numpy/distutils/mingw
  764. diff -u numpy-1.12.1/numpy/distutils/mingw32ccompiler.py numpy-1.13.0.orig/numpy/distutils/mingw32ccompiler.py
  765. --- numpy-1.12.1/numpy/distutils/mingw32ccompiler.py 2017-03-18 09:23:22.000000000 -0400
  766. +++ numpy-1.13.0.orig/numpy/distutils/mingw32ccompiler.py 2017-06-02 20:20:06.000000000 -0400
  767. @@ -35,8 +35,19 @@
  768. from distutils.errors import (DistutilsExecError, CompileError,
  769. UnknownFileError)
  770. from numpy.distutils.misc_util import (msvc_runtime_library,
  771. + msvc_runtime_version,
  772. + msvc_runtime_major,
  773. get_build_architecture)
  774.  
  775. +def get_msvcr_replacement():
  776. + """Replacement for outdated version of get_msvcr from cygwinccompiler"""
  777. + msvcr = msvc_runtime_library()
  778. + return [] if msvcr is None else [msvcr]
  779. +
  780. +# monkey-patch cygwinccompiler with our updated version from misc_util
  781. +# to avoid getting an exception raised on Python 3.5
  782. +distutils.cygwinccompiler.get_msvcr = get_msvcr_replacement
  783. +
  784. # Useful to generate table of symbols from a dll
  785. _START = re.compile(r'\[Ordinal/Name Pointer\] Table')
  786. _TABLE = re.compile(r'^\s+\[([\s*[0-9]*)\] ([a-zA-Z0-9_]*)')
  787. @@ -100,8 +111,9 @@
  788. self.define_macro('NPY_MINGW_USE_CUSTOM_MSVCR')
  789.  
  790. # Define the MSVC version as hint for MinGW
  791. - msvcr_version = '0x%03i0' % int(msvc_runtime_library().lstrip('msvcr'))
  792. - self.define_macro('__MSVCRT_VERSION__', msvcr_version)
  793. + msvcr_version = msvc_runtime_version()
  794. + if msvcr_version:
  795. + self.define_macro('__MSVCRT_VERSION__', '0x%04i' % msvcr_version)
  796.  
  797. # MS_WIN64 should be defined when building for amd64 on windows,
  798. # but python headers define it only for MS compilers, which has all
  799. @@ -236,24 +248,37 @@
  800.  
  801.  
  802. def find_python_dll():
  803. - maj, min, micro = [int(i) for i in sys.version_info[:3]]
  804. - dllname = 'python%d%d.dll' % (maj, min)
  805. - print("Looking for %s" % dllname)
  806. -
  807. # We can't do much here:
  808. - # - find it in python main dir
  809. + # - find it in the virtualenv (sys.prefix)
  810. + # - find it in python main dir (sys.base_prefix, if in a virtualenv)
  811. # - in system32,
  812. # - ortherwise (Sxs), I don't know how to get it.
  813. - lib_dirs = [sys.prefix, os.path.join(sys.prefix, 'lib')]
  814. - try:
  815. - lib_dirs.append(os.path.join(os.environ['SYSTEMROOT'], 'system32'))
  816. - except KeyError:
  817. - pass
  818. -
  819. - for d in lib_dirs:
  820. - dll = os.path.join(d, dllname)
  821. - if os.path.exists(dll):
  822. - return dll
  823. + stems = [sys.prefix]
  824. + if sys.base_prefix != sys.prefix:
  825. + stems.append(sys.base_prefix)
  826. +
  827. + sub_dirs = ['', 'lib', 'bin']
  828. + # generate possible combinations of directory trees and sub-directories
  829. + lib_dirs = []
  830. + for stem in stems:
  831. + for folder in sub_dirs:
  832. + lib_dirs = os.path.join(stem, folder)
  833. +
  834. + # add system directory as well
  835. + if 'SYSTEMROOT' in os.environ:
  836. + lib_dirs.append(os.path.join(os.environ['SYSTEMROOT'], 'System32'))
  837. +
  838. + # search in the file system for possible candidates
  839. + major_version, minor_version = tuple(sys.version_info[:2])
  840. + patterns = ['python%d%d.dll']
  841. +
  842. + for pat in patterns:
  843. + dllname = pat % (major_version, minor_version)
  844. + print("Looking for %s" % dllname)
  845. + for folder in lib_dirs:
  846. + dll = os.path.join(folder, dllname)
  847. + if os.path.exists(dll):
  848. + return dll
  849.  
  850. raise ValueError("%s not found in %s" % (dllname, lib_dirs))
  851.  
  852. @@ -323,14 +348,24 @@
  853. if os.name != 'nt':
  854. return False
  855.  
  856. - msvcr_name = msvc_runtime_library()
  857. + # If the version number is None, then we couldn't find the MSVC runtime at
  858. + # all, because we are running on a Python distribution which is customed
  859. + # compiled; trust that the compiler is the same as the one available to us
  860. + # now, and that it is capable of linking with the correct runtime without
  861. + # any extra options.
  862. + msvcr_ver = msvc_runtime_major()
  863. + if msvcr_ver is None:
  864. + log.debug('Skip building import library: '
  865. + 'Runtime is not compiled with MSVC')
  866. + return False
  867.  
  868. # Skip using a custom library for versions < MSVC 8.0
  869. - if int(msvcr_name.lstrip('msvcr')) < 80:
  870. + if msvcr_ver < 80:
  871. log.debug('Skip building msvcr library:'
  872. ' custom functionality not present')
  873. return False
  874.  
  875. + msvcr_name = msvc_runtime_library()
  876. if debug:
  877. msvcr_name += 'd'
  878.  
  879. @@ -380,41 +415,80 @@
  880. else:
  881. raise ValueError("Unhandled arch %s" % arch)
  882.  
  883. -def _build_import_library_amd64():
  884. - dll_file = find_python_dll()
  885. +def _check_for_import_lib():
  886. + """Check if an import library for the Python runtime already exists."""
  887. + major_version, minor_version = tuple(sys.version_info[:2])
  888. +
  889. + # patterns for the file name of the library itself
  890. + patterns = ['libpython%d%d.a',
  891. + 'libpython%d%d.dll.a',
  892. + 'libpython%d.%d.dll.a']
  893. +
  894. + # directory trees that may contain the library
  895. + stems = [sys.prefix]
  896. + if sys.base_prefix != sys.prefix:
  897. + stems.append(sys.base_prefix)
  898. +
  899. + # possible subdirectories within those trees where it is placed
  900. + sub_dirs = ['libs', 'lib']
  901. +
  902. + # generate a list of candidate locations
  903. + candidates = []
  904. + for pat in patterns:
  905. + filename = pat % (major_version, minor_version)
  906. + for stem_dir in stems:
  907. + for folder in sub_dirs:
  908. + candidates.append(os.path.join(stem_dir, folder, filename))
  909. +
  910. + # test the filesystem to see if we can find any of these
  911. + for fullname in candidates:
  912. + if os.path.isfile(fullname):
  913. + # already exists, in location given
  914. + return (True, fullname)
  915.  
  916. - out_name = "libpython%d%d.a" % tuple(sys.version_info[:2])
  917. - out_file = os.path.join(sys.prefix, 'libs', out_name)
  918. - if os.path.isfile(out_file):
  919. - log.debug('Skip building import library: "%s" exists' %
  920. - (out_file))
  921. - return
  922. + # needs to be built, preferred location given first
  923. + return (False, candidates[0])
  924.  
  925. - def_name = "python%d%d.def" % tuple(sys.version_info[:2])
  926. - def_file = os.path.join(sys.prefix, 'libs', def_name)
  927. +def _build_import_library_amd64():
  928. + out_exists, out_file = _check_for_import_lib()
  929. + if out_exists:
  930. + log.debug('Skip building import library: "%s" exists', out_file)
  931. + return
  932.  
  933. + # get the runtime dll for which we are building import library
  934. + dll_file = find_python_dll()
  935. log.info('Building import library (arch=AMD64): "%s" (from %s)' %
  936. (out_file, dll_file))
  937.  
  938. + # generate symbol list from this library
  939. + def_name = "python%d%d.def" % tuple(sys.version_info[:2])
  940. + def_file = os.path.join(sys.prefix, 'libs', def_name)
  941. generate_def(dll_file, def_file)
  942.  
  943. + # generate import library from this symbol list
  944. cmd = ['dlltool', '-d', def_file, '-l', out_file]
  945. subprocess.Popen(cmd)
  946.  
  947. def _build_import_library_x86():
  948. """ Build the import libraries for Mingw32-gcc on Windows
  949. """
  950. + out_exists, out_file = _check_for_import_lib()
  951. + if out_exists:
  952. + log.debug('Skip building import library: "%s" exists', out_file)
  953. + return
  954. +
  955. lib_name = "python%d%d.lib" % tuple(sys.version_info[:2])
  956. lib_file = os.path.join(sys.prefix, 'libs', lib_name)
  957. - out_name = "libpython%d%d.a" % tuple(sys.version_info[:2])
  958. - out_file = os.path.join(sys.prefix, 'libs', out_name)
  959. if not os.path.isfile(lib_file):
  960. - log.warn('Cannot build import library: "%s" not found' % (lib_file))
  961. - return
  962. - if os.path.isfile(out_file):
  963. - log.debug('Skip building import library: "%s" exists' % (out_file))
  964. - return
  965. - log.info('Building import library (ARCH=x86): "%s"' % (out_file))
  966. + # didn't find library file in virtualenv, try base distribution, too,
  967. + # and use that instead if found there
  968. + base_lib = os.path.join(sys.base_prefix, 'libs', lib_name)
  969. + if os.path.isfile(base_lib):
  970. + lib_file = base_lib
  971. + else:
  972. + log.warn('Cannot build import library: "%s" not found', lib_file)
  973. + return
  974. + log.info('Building import library (ARCH=x86): "%s"', out_file)
  975.  
  976. from numpy.distutils import lib2def
  977.  
  978. @@ -425,9 +499,9 @@
  979. dlist, flist = lib2def.parse_nm(nm_output)
  980. lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))
  981.  
  982. - dll_name = "python%d%d.dll" % tuple(sys.version_info[:2])
  983. + dll_name = find_python_dll ()
  984. args = (dll_name, def_file, out_file)
  985. - cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args
  986. + cmd = 'dlltool --dllname "%s" --def "%s" --output-lib "%s"' % args
  987. status = os.system(cmd)
  988. # for now, fail silently
  989. if status:
  990. @@ -532,12 +606,8 @@
  991. """msver is the ms runtime version used for the MANIFEST."""
  992. # check msvcr major version are the same for linking and
  993. # embedding
  994. - msvcv = msvc_runtime_library()
  995. - if msvcv:
  996. - assert msvcv.startswith("msvcr"), msvcv
  997. - # Dealing with something like "mscvr90" or "mscvr100", the last
  998. - # last digit is the minor release, want int("9") or int("10"):
  999. - maj = int(msvcv[5:-1])
  1000. + maj = msvc_runtime_major()
  1001. + if maj:
  1002. if not maj == int(msver):
  1003. raise ValueError(
  1004. "Discrepancy between linked msvcr " \
  1005. diff -u numpy-1.12.1/numpy/distutils/misc_util.py numpy-1.13.0.orig/numpy/distutils/misc_util.py
  1006. --- numpy-1.12.1/numpy/distutils/misc_util.py 2017-03-18 09:23:22.000000000 -0400
  1007. +++ numpy-1.13.0.orig/numpy/distutils/misc_util.py 2017-06-07 09:21:24.000000000 -0400
  1008. @@ -12,6 +12,7 @@
  1009.  
  1010. import distutils
  1011. from distutils.errors import DistutilsError
  1012. +from distutils.msvccompiler import get_build_architecture
  1013. try:
  1014. from threading import local as tlocal
  1015. except ImportError:
  1016. @@ -390,21 +391,36 @@
  1017. return True
  1018. return False
  1019.  
  1020. -def msvc_runtime_library():
  1021. - "Return name of MSVC runtime library if Python was built with MSVC >= 7"
  1022. +def msvc_runtime_version():
  1023. + "Return version of MSVC runtime library, as defined by __MSC_VER__ macro"
  1024. msc_pos = sys.version.find('MSC v.')
  1025. if msc_pos != -1:
  1026. - msc_ver = sys.version[msc_pos+6:msc_pos+10]
  1027. - lib = {'1300': 'msvcr70', # MSVC 7.0
  1028. - '1310': 'msvcr71', # MSVC 7.1
  1029. - '1400': 'msvcr80', # MSVC 8
  1030. - '1500': 'msvcr90', # MSVC 9 (VS 2008)
  1031. - '1600': 'msvcr100', # MSVC 10 (aka 2010)
  1032. - }.get(msc_ver, None)
  1033. + msc_ver = int(sys.version[msc_pos+6:msc_pos+10])
  1034. + else:
  1035. + msc_ver = None
  1036. + return msc_ver
  1037. +
  1038. +def msvc_runtime_library():
  1039. + "Return name of MSVC runtime library if Python was built with MSVC >= 7"
  1040. + ver = msvc_runtime_major ()
  1041. + if ver:
  1042. + if ver < 140:
  1043. + return "msvcr%i" % ver
  1044. + else:
  1045. + return "vcruntime%i" % ver
  1046. else:
  1047. - lib = None
  1048. - return lib
  1049. + return None
  1050.  
  1051. +def msvc_runtime_major():
  1052. + "Return major version of MSVC runtime coded like get_build_msvc_version"
  1053. + major = {1300: 70, # MSVC 7.0
  1054. + 1310: 71, # MSVC 7.1
  1055. + 1400: 80, # MSVC 8
  1056. + 1500: 90, # MSVC 9 (aka 2008)
  1057. + 1600: 100, # MSVC 10 (aka 2010)
  1058. + 1900: 140, # MSVC 14 (aka 2015)
  1059. + }.get(msvc_runtime_version(), None)
  1060. + return major
  1061.  
  1062. #########################
  1063.  
  1064. @@ -525,6 +541,18 @@
  1065. direcs.append(d[0])
  1066. return direcs
  1067.  
  1068. +def _commandline_dep_string(cc_args, extra_postargs, pp_opts):
  1069. + """
  1070. + Return commandline representation used to determine if a file needs
  1071. + to be recompiled
  1072. + """
  1073. + cmdline = 'commandline: '
  1074. + cmdline += ' '.join(cc_args)
  1075. + cmdline += ' '.join(extra_postargs)
  1076. + cmdline += ' '.join(pp_opts) + '\n'
  1077. + return cmdline
  1078. +
  1079. +
  1080. def get_dependencies(sources):
  1081. #XXX scan sources for include statements
  1082. return _get_headers(_get_directories(sources))
  1083. @@ -2287,21 +2315,3 @@
  1084. raise ValueError("Compiler instance is not msvc (%s)"\
  1085. % compiler.compiler_type)
  1086. return compiler._MSVCCompiler__version
  1087. -
  1088. -if sys.version[:3] >= '2.5':
  1089. - def get_build_architecture():
  1090. - from distutils.msvccompiler import get_build_architecture
  1091. - return get_build_architecture()
  1092. -else:
  1093. - #copied from python 2.5.1 distutils/msvccompiler.py
  1094. - def get_build_architecture():
  1095. - """Return the processor architecture.
  1096. -
  1097. - Possible results are "Intel", "Itanium", or "AMD64".
  1098. - """
  1099. - prefix = " bit ("
  1100. - i = sys.version.find(prefix)
  1101. - if i == -1:
  1102. - return "Intel"
  1103. - j = sys.version.find(")", i)
  1104. - return sys.version[i+len(prefix):j]
  1105. diff -u numpy-1.12.1/numpy/distutils/msvc9compiler.py numpy-1.13.0.orig/numpy/distutils/msvc9compiler.py
  1106. --- numpy-1.12.1/numpy/distutils/msvc9compiler.py 2017-03-05 13:13:50.000000000 -0500
  1107. +++ numpy-1.13.0.orig/numpy/distutils/msvc9compiler.py 2017-06-07 09:45:06.000000000 -0400
  1108. @@ -11,15 +11,15 @@
  1109.  
  1110. Here `old` is the environment string before the base class initialize
  1111. function is called and `new` is the string after the call. The new string
  1112. - will be a fixed string if it is not obtained from the current enviroment,
  1113. - or the same as the old string if obtained from the same enviroment. The aim
  1114. + will be a fixed string if it is not obtained from the current environment,
  1115. + or the same as the old string if obtained from the same environment. The aim
  1116. here is not to append the new string if it is already contained in the old
  1117. string so as to limit the growth of the environment string.
  1118.  
  1119. Parameters
  1120. ----------
  1121. old : string
  1122. - Previous enviroment string.
  1123. + Previous environment string.
  1124. new : string
  1125. New environment string.
  1126.  
  1127. @@ -29,10 +29,10 @@
  1128. Updated environment string.
  1129.  
  1130. """
  1131. - if new in old:
  1132. - return old
  1133. if not old:
  1134. return new
  1135. + if new in old:
  1136. + return old
  1137.  
  1138. # Neither new nor old is empty. Give old priority.
  1139. return ';'.join([old, new])
  1140. diff -u numpy-1.12.1/numpy/distutils/msvccompiler.py numpy-1.13.0.orig/numpy/distutils/msvccompiler.py
  1141. --- numpy-1.12.1/numpy/distutils/msvccompiler.py 2017-03-18 09:23:22.000000000 -0400
  1142. +++ numpy-1.13.0.orig/numpy/distutils/msvccompiler.py 2017-06-02 20:20:06.000000000 -0400
  1143. @@ -42,12 +42,12 @@
  1144. def __init__(self, verbose=0, dry_run=0, force=0):
  1145. _MSVCCompiler.__init__(self, verbose, dry_run, force)
  1146.  
  1147. - def initialize(self, plat_name=None):
  1148. + def initialize(self):
  1149. # The 'lib' and 'include' variables may be overwritten
  1150. # by MSVCCompiler.initialize, so save them for later merge.
  1151. environ_lib = os.getenv('lib', '')
  1152. environ_include = os.getenv('include', '')
  1153. - _MSVCCompiler.initialize(self, plat_name)
  1154. + _MSVCCompiler.initialize(self)
  1155.  
  1156. # Merge current and previous values of 'lib' and 'include'
  1157. os.environ['lib'] = _merge(environ_lib, os.environ['lib'])
  1158. diff -u numpy-1.12.1/numpy/distutils/system_info.py numpy-1.13.0.orig/numpy/distutils/system_info.py
  1159. --- numpy-1.12.1/numpy/distutils/system_info.py 2017-03-18 09:23:22.000000000 -0400
  1160. +++ numpy-1.13.0.orig/numpy/distutils/system_info.py 2017-06-07 09:21:24.000000000 -0400
  1161. @@ -1667,6 +1667,8 @@
  1162. info = self.check_libs(lib_dirs, blas_libs, [])
  1163. if info is None:
  1164. return
  1165. + else:
  1166. + info['include_dirs'] = self.get_include_dirs()
  1167. if platform.system() == 'Windows':
  1168. # The check for windows is needed because has_cblas uses the
  1169. # same compiler that was used to compile Python and msvc is
  1170. Common subdirectories: numpy-1.12.1/numpy/distutils/tests and numpy-1.13.0.orig/numpy/distutils/tests
  1171. diff -u numpy-1.12.1/numpy/distutils/unixccompiler.py numpy-1.13.0.orig/numpy/distutils/unixccompiler.py
  1172. --- numpy-1.12.1/numpy/distutils/unixccompiler.py 2016-12-21 16:46:24.000000000 -0500
  1173. +++ numpy-1.13.0.orig/numpy/distutils/unixccompiler.py 2017-06-02 20:20:06.000000000 -0400
  1174. @@ -10,6 +10,7 @@
  1175. from distutils.unixccompiler import *
  1176. from numpy.distutils.ccompiler import replace_method
  1177. from numpy.distutils.compat import get_exception
  1178. +from numpy.distutils.misc_util import _commandline_dep_string
  1179.  
  1180. if sys.version_info[0] < 3:
  1181. from . import log
  1182. @@ -44,13 +45,25 @@
  1183. self.linker_so = llink_s.split() + opt.split()
  1184.  
  1185. display = '%s: %s' % (os.path.basename(self.compiler_so[0]), src)
  1186. +
  1187. + # gcc style automatic dependencies, outputs a makefile (-MF) that lists
  1188. + # all headers needed by a c file as a side effect of compilation (-MMD)
  1189. + if getattr(self, '_auto_depends', False):
  1190. + deps = ['-MMD', '-MF', obj + '.d']
  1191. + else:
  1192. + deps = []
  1193. +
  1194. try:
  1195. - self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
  1196. + self.spawn(self.compiler_so + cc_args + [src, '-o', obj] + deps +
  1197. extra_postargs, display = display)
  1198. except DistutilsExecError:
  1199. msg = str(get_exception())
  1200. raise CompileError(msg)
  1201.  
  1202. + # add commandline flags to dependency file
  1203. + with open(obj + '.d', 'a') as f:
  1204. + f.write(_commandline_dep_string(cc_args, extra_postargs, pp_opts))
  1205. +
  1206. replace_method(UnixCCompiler, '_compile', UnixCCompiler__compile)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement