diff options
author | Ralf Gommers <ralf.gommers@googlemail.com> | 2011-08-02 17:34:38 +0200 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2011-08-13 08:36:44 -0600 |
commit | dba98cc143687bcb9ab25403b5d51fdefd582370 (patch) | |
tree | 89e6d1d6dbd153bd9f4e60d228accaf47e31c236 | |
parent | 57b56bc6409f30039e59d5476feb675d2c279564 (diff) | |
download | python-numpy-dba98cc143687bcb9ab25403b5d51fdefd582370.tar.gz python-numpy-dba98cc143687bcb9ab25403b5d51fdefd582370.tar.bz2 python-numpy-dba98cc143687bcb9ab25403b5d51fdefd582370.zip |
BLD: fix build for py3k + pip. Closes #1857. Thanks to Erik Bray.
Also works inside a virtualenv.
-rw-r--r-- | numpy/distutils/ccompiler.py | 6 | ||||
-rwxr-xr-x | setup.py | 13 |
2 files changed, 18 insertions, 1 deletions
diff --git a/numpy/distutils/ccompiler.py b/numpy/distutils/ccompiler.py index 14213dc4b..e3b88af08 100644 --- a/numpy/distutils/ccompiler.py +++ b/numpy/distutils/ccompiler.py @@ -58,7 +58,11 @@ def CCompiler_spawn(self, cmd, display=None): if s: if is_sequence(cmd): cmd = ' '.join(list(cmd)) - print(o) + try: + print(o) + except UnicodeError: + # When installing through pip, `o` can contain non-ascii chars + pass if re.search('Too many open files', o): msg = '\nTry rerunning setup command until build succeeds.' else: @@ -167,6 +167,19 @@ def setup_package(): if os.path.isfile(site_cfg): shutil.copy(site_cfg, src_path) + # Ugly hack to make pip work with Python 3, see #1857. + # Explanation: pip messes with __file__ which interacts badly with the + # change in directory due to the 2to3 conversion. Therefore we restore + # __file__ to what it would have been otherwise. + global __file__ + __file__ = os.path.join(os.curdir, os.path.basename(__file__)) + if '--egg-base' in sys.argv: + # Change pip-egg-info entry to absolute path, so pip can find it + # after changing directory. + idx = sys.argv.index('--egg-base') + if sys.argv[idx + 1] == 'pip-egg-info': + sys.argv[idx + 1] = os.path.join(local_path, 'pip-egg-info') + old_path = os.getcwd() os.chdir(src_path) sys.path.insert(0, src_path) |