8000 Revert "Merge pull request #4421 from meltingwax/meltingwax/4382" · ddasilva/numpy@4b2b77e · GitHub
[go: up one dir, main page]

Skip to content

Commit 4b2b77e

Browse files
author
Daniel da Silva
committed
Revert "Merge pull request numpy#4421 from meltingwax/meltingwax/4382"
Caused SciPy tests to fail when built with this NumPy.
1 parent 683bc33 commit 4b2b77e

File tree

5 files changed

+23
-89
lines changed

5 files changed

+23
-89
lines changed

numpy/distutils/fcompiler/__init__.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from numpy.distutils.ccompiler import CCompiler, gen_lib_options
3939
from numpy.distutils import log
4040
from numpy.distutils.misc_util import is_string, all_strings, is_sequence, \
41-
make_temp_file, get_shared_lib_extension, quote
41+
make_temp_file, get_shared_lib_extension
4242
from numpy.distutils.environment import EnvironmentConfig
4343
from numpy.distutils.exec_command import find_executable
4444
from numpy.distutils.compat import get_exception
@@ -582,12 +582,12 @@ def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
582582
% (self.__class__.__name__, src))
583583
extra_compile_args = self.extra_f90_compile_args or []
584584
if self.object_switch[-1]==' ':
585-
o_args = [self.object_switch.strip(), quote(obj)]
585+
o_args = [self.object_switch.strip(), obj]
586586
else:
587-
o_args = [self.object_switch.strip() + quote(obj)]
587+
o_args = [self.object_switch.strip()+obj]
588588

589589
assert self.compile_switch.strip()
590-
s_args = [self.compile_switch, quote(src)]
590+
s_args = [self.compile_switch, src]
591591

592592
if extra_compile_args:
593593
log.info('extra %s options: %r' \
@@ -659,7 +659,6 @@ def link(self, target_desc, objects,
659659
else:
660660
ld_args = objects + self.objects
661661
ld_args = ld_args + lib_opts + o_args
662-
ld_args = [quote(ld_arg) for ld_arg in ld_args]
663662
if debug:
664663
ld_args[:0] = ['-g']
665664
if extra_preargs:
@@ -988,4 +987,3 @@ def get_f77flags(src):
988987

989988
if __name__ == '__main__':
990989
show_fcompilers()
991-

numpy/distutils/misc_util.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414
import distutils
1515
from distutils.errors import DistutilsError
1616

17-
try:
18-
from pipes import quote
19-
except ImportError:
20-
from shlex import quote
21-
2217
try:
2318
set
2419
except NameError:
@@ -36,8 +31,7 @@
3631
'get_script_files', 'get_lib_source_files', 'get_data_files',
3732
'dot_join', 'get_frame', 'minrelpath', 'njoin',
3833
'is_sequence', 'is_string', 'as_list', 'gpaths', 'get_language',
39-
'quote_args', 'quote', 'get_build_architecture', 'get_info',
40-
'get_pkg_info']
34+
'quote_args', 'get_build_architecture', 'get_info', 'get_pkg_info']
4135

4236
class InstallableLib(object):
4337
"""

numpy/distutils/npy_pkg_config.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
else:
1111
from configparser import ConfigParser, SafeConfigParser, NoOptionError
1212

13-
from numpy.distutils.misc_util import quote
14-
1513
__all__ = ['FormatError', 'PkgNotFound', 'LibraryInfo', 'VariableSet',
1614
'read_config', 'parse_flags']
1715

@@ -58,7 +56,7 @@ def parse_flags(line):
5856
* 'ignored'
5957
6058
"""
61-
lexer = shlex.shlex(line, posix=True)
59+
lexer = shlex.shlex(line)
6260
lexer.whitespace_split = True
6361

6462
d = {'include_dirs': [], 'library_dirs': [], 'libraries': [],
@@ -90,6 +88,8 @@ def next_token(t):
9088

9189
return d
9290

91+
def _escape_backslash(val):
92+
return val.replace('\\', '\\\\')
9393

9494
class LibraryInfo(object):
9595
"""
@@ -147,11 +147,11 @@ def sections(self):
147147

148148
def cflags(self, section="default"):
149149
val = self.vars.interpolate(self._sections[section]['cflags'])
150-
return quote(val)
150+
return _escape_backslash(val)
151151

152152
def libs(self, section="default"):
153153
val = self.vars.interpolate(self._sections[section]['libs'])
154-
return quote(val)
154+
return _escape_backslash(val)
155155

156156
def __str__(self):
157157
m = ['Name: %s' % self.name]
@@ -289,7 +289,7 @@ def parse_config(filename, dirs=None):
289289
vars = {}
290290
if config.has_section('variables'):
291291
for name, value in config.items("variables"):
292-
vars[name] = quote(value)
292+
vars[name] = _escape_backslash(value)
293293

294294
# Parse "normal" sections
295295
secs = [s for s in config.sections() if not s in ['meta', 'variables']]
@@ -338,7 +338,7 @@ def _read_config(f):
338338
(pkgname, meta["name"]))
339339

340340
mod = sys.modules[pkgname]
341-
vars["pkgdir"] = quote(os.path.dirname(mod.__file__))
341+
vars["pkgdir"] = _escape_backslash(os.path.dirname(mod.__file__))
342342

343343
return LibraryInfo(name=meta["name"], description=meta["description"],
344344
version=meta["version"], sections=sections, vars=VariableSet(vars))
Lines changed: 9 additions & 66 deletions
< F438 /tr>
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import division, absolute_import, print_function
22

33
import os
4-
import shlex
54
from tempfile import mkstemp
65

76
from numpy.testing import *
@@ -39,12 +38,6 @@
3938
'version': '0.1', 'name': 'foo'}
4039

4140
class TestLibraryInfo(TestCase):
42-
43-
def assertLexEqual(self, str1, str2):
44-
# Use shlex.split for comparison because it is above quotes
45-
# eg: shlex.split("'abc'") == shlex.split("abc")
46-
return shlex.split(str1) == shlex.split(str2)
47-
4841
def test_simple(self):
4942
fd, filename = mkstemp('foo.ini')
5043
try:
@@ -55,10 +48,10 @@ def test_simple(self):
5548
os.close(fd)
5649

5750
out = read_config(pkg)
58-
self.assertLexEqual(out.cflags(), simple_d['cflags'])
59-
self.assertLexEqual(out.libs(), simple_d['libflags'])
60-
self.assertEqual(out.name, simple_d['name'])
61-
self.assertEqual(out.version, simple_d['version'])
51+
self.assertTrue(out.cflags() == simple_d['cflags'])
52+
self.assertTrue(out.libs() == simple_d['libflags'])
53+
self.assertTrue(out.name == simple_d['name'])
54+
self.assertTrue(out.version == simple_d['version'])
6255
finally:
6356
os.remove(filename)
6457

@@ -72,13 +65,13 @@ def test_simple_variable(self):
7265
os.close(fd)
7366

7467
out = read_config(pkg)
75-
self.assertLexEqual(out.cflags(), simple_variable_d['cflags'])
76-
self.assertLexEqual(out.libs(), simple_variable_d['libflags'])
77-
self.assertEqual(out.name, simple_variable_d['name'])
78-
self.assertEqual(out.version, simple_variable_d['version'])
68+
self.assertTrue(out.cflags() == simple_variable_d['cflags'])
69+
self.assertTrue(out.libs() == simple_variable_d['libflags'])
70+
self.assertTrue(out.name == simple_variable_d['name'])
71+
self.assertTrue(out.version == simple_variable_d['version'])
7972

8073
out.vars['prefix'] = '/Users/david'
81-
self.assertLexEqual(out.cflags(), '-I/Users/david/include')
74+
self.assertTrue(out.cflags() == '-I/Users/david/include')
8275
finally:
8376
os.remove(filename)
8477

@@ -95,28 +88,6 @@ def test_simple_cflags(self):
9588
self.assertTrue(d['include_dirs'] == ['/usr/include'])
9689
self.assertTrue(d['macros'] == ['FOO'])
9790

98-
def test_quotes_cflags(self):
99-
d = parse_flags("-I'/usr/foo bar/include' -DFOO")
100-
self.assertTrue(d['include_dirs'] == ['/usr/foo bar/include'])
101-
self.assertTrue(d['macros'] == ['FOO'])
102-
103-
d = parse_flags("-I/usr/'foo bar'/include -DFOO")
104-
self.assertTrue(d['include_dirs'] == ['/usr/foo bar/include'])
105-
self.assertTrue(d['macros'] == ['FOO'])
106-
107-
d = parse_flags("'-I/usr/foo bar'/include -DFOO")
108-
self.assertTrue(d['include_dirs'] == ['/usr/foo bar/include'])
109-
self.assertTrue(d['macros'] == ['FOO'])
110-
111-
def test_escaping_cflags(self):
112-
d = parse_flags("-I/usr/foo\\ bar/include -DFOO")
113-
self.assertTrue(d['include_dirs'] == ['/usr/foo bar/include'])
114-
self.assertTrue(d['macros'] == ['FOO'])
115-
116-
d = parse_flags(r"-I/usr/foo\ bar/include -DFOO")
117-
self.assertTrue(d['include_dirs'] == ['/usr/foo bar/include'])
118-
self.assertTrue(d['macros'] == ['FOO'])
119-
12091
def test_simple_lflags(self):
12192
d = parse_flags("-L/usr/lib -lfoo -L/usr/lib -lbar")
12293
self.assertTrue(d['library_dirs'] == ['/usr/lib', '/usr/lib'])
@@ -125,31 +96,3 @@ def test_simple_lflags(self):
12596
d = parse_flags("-L /usr/lib -lfoo -L/usr/lib -lbar")
12697
self.assertTrue(d['library_dirs'] == ['/usr/lib', '/usr/lib'])
12798
self.assertTrue(d['libraries'] == ['foo', 'bar'])
128-
129-
def test_quotes_lflags(self):
130-
d = parse_flags("-L'/usr/foo bar' -lfoo -L/usr/lib -lbar")
131-
self.assertTrue(d['library_dirs'] == ['/usr/foo bar', '/usr/lib'])
132-
133-
d = parse_flags("-L/usr/'foo bar' -lfoo -L/usr/lib -lbar")
134-
self.assertTrue(d['library_dirs'] == ['/usr/foo bar', '/usr/lib'])
135-
136-
d = parse_flags("\"-L/usr/foo bar\" -lfoo -L/usr/lib -lbar")
137-
self.assertTrue(d['library_dirs'] == ['/usr/foo bar', '/usr/lib'])
138-
139-
d = parse_flags("\"-L/usr/foo bar/baz buz\" -lfoo -L/usr/lib -lbar")
140-
self.assertTrue(d['library_dirs'] == ['/usr/foo bar/baz buz', '/usr/lib'])
141-
142-
def test_escaping_lflags(self):
143-
d = parse_flags("-L/usr/foo\\ bar -lfoo -L/usr/lib -lbar")
144-
self.assertTrue(d['library_dirs'] == ['/usr/foo bar', '/usr/lib'])
145-
146-
d = parse_flags(r"-L/usr/foo\ bar -lfoo -L/usr/lib -lbar")
147-
self.assertTrue(d['library_dirs'] == ['/usr/foo bar', '/usr/lib'])
148-
149-
def test_odd_characters_lflags(self):
150-
# tab in directory name
151-
d = parse_flags('-L/usr/"foo\tbar" -lfoo -L/usr/lib -lbar')
152-
self.assertTrue(d['library_dirs'] == ['/usr/foo\tbar', '/usr/lib'])
153-
154-
d = parse_flags("-L/usr/foo\\\tbar -lfoo -L/usr/lib -lbar")
155-
self.assertTrue(d['library_dirs'] == ['/usr/foo\tbar', '/usr/lib'])

numpy/distutils/unixccompiler.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from distutils.unixccompiler import *
1111
from numpy.distutils.ccompiler import replace_method
1212
from numpy.distutils.compat import get_exception
13-
from numpy.distutils.misc_util import quote_args, quote
1413

1514
if sys.version_info[0] < 3:
1615
from . import log
@@ -89,8 +88,8 @@ def UnixCCompiler_create_static_lib(self, objects, output_libname,
8988
display = '%s: adding %d object files to %s' % (
9089
os.path.basename(self.archiver[0]),
9190
len(objects), output_filename)
92-
command = self.archiver + [quote(output_filename)] + quote_args(objects)
93-
self.spawn(command, display = display)
91+
self.spawn(self.archiver + [output_filename] + objects,
92+
display = display)
9493

9594
# Not many Unices required ranlib anymore -- SunOS 4.x is, I
9695
# think the only major Unix that does. Maybe we need some

0 commit comments

Comments
 (0)
0