8000 P3K: Fix build for py3k + pip. · ludgate/scikit-learn@0f24720 · GitHub 8000
[go: up one dir, main page]

Skip to content

Commit 0f24720

Browse files
astaricGaelVaroquaux
authored andcommitted
P3K: Fix build for py3k + pip.
Same fix as used in numpy. For more info see http://projects.scipy.org/numpy/ticket/1857.
1 parent c89d208 commit 0f24720

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

setup.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,20 @@ def configuration(parent_package='', top_path=None):
106106
if res != 0:
107107
raise Exception('2to3 failed, exiting ...')
108108

109+
# Ugly hack to make pip work with Python 3, see
110+
# http://projects.scipy.org/numpy/ticket/1857.
111+
# Explanation: pip messes with __file__ which interacts badly with the
112+
# change in directory due to the 2to3 conversion. Therefore we restore
113+
# __file__ to what it would have been otherwise.
114+
global __file__
115+
__file__ = os.path.join(os.curdir, os.path.basename(__file__))
116+
if '--egg-base' in sys.argv:
117+
# Change pip-egg-info entry to absolute path, so pip can find it
118+
# after changing directory.
119+
idx = sys.argv.index('--egg-base')
120+
if sys.argv[idx + 1] == 'pip-egg-info':
121+
sys.argv[idx + 1] = os.path.join(old_path, 'pip-egg-info')
122+
109123
os.chdir(local_path)
110124
sys.path.insert(0, local_path)
111125

0 commit comments

Comments
 (0)
0