summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorRalf Gommers <ralf.gommers@googlemail.com>2011-08-02 17:34:38 +0200
committerRalf Gommers <ralf.gommers@googlemail.com>2012-04-22 12:26:49 +0200
commit6fbddd9c8400744baf110e96c7e2ece854d40644 (patch)
tree9cdaa2a2d102e4b404bbdf915ca79a6852612254 /setup.py
parentef3f401fed1564145e370a90c0b512ff55aa3757 (diff)
downloadnumpy-6fbddd9c8400744baf110e96c7e2ece854d40644.tar.gz
BLD: fix build for py3k + pip. Closes #1857. Thanks to Erik Bray.
Also works inside a virtualenv.
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/setup.py b/setup.py
index 902a43685..140146be8 100755
--- a/setup.py
+++ b/setup.py
@@ -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)