[NumPy-Tickets] [NumPy] #1857: Pip install into virtualenv doesn't work
NumPy Trac
numpy-tickets@scipy....
Wed Aug 3 10:49:26 CDT 2011
#1857: Pip install into virtualenv doesn't work
-------------------------------+--------------------------------------------
Reporter: rgommers | Owner: rgommers
Type: defect | Status: new
Priority: normal | Milestone: Unscheduled
Component: numpy.distutils | Version: 1.6.0
Keywords: pip, easy_install |
-------------------------------+--------------------------------------------
Comment(by rgommers):
I meant after always changing {{{__file__}}} it works. Looks like this for
me:
{{{
#!diff
diff --git a/numpy/distutils/ccompiler.py b/numpy/distutils/ccompiler.py
index 14213dc..e3b88af 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:
diff --git a/setup.py b/setup.py
index 542ca7b..b0b7a97 100755
--- a/setup.py
+++ b/setup.py
@@ -167,6 +167,18 @@ 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')
+ 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)
}}}
Works for me with -e. Haven't tested without -e; is there a better way to
do that than pushing to my github account and letting pip install from
there with some magic incantation?
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1857#comment:18>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list