Skip to content

Temporary build and src directories no longer created in cwd/pwd (bugs #339, #381) #516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 31, 2012
16 changes: 11 additions & 5 deletions pip/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import sys
import os
import tempfile
from pip.backwardcompat import get_python_lib


Expand All @@ -18,13 +19,18 @@ def running_under_virtualenv():
build_prefix = os.path.join(sys.prefix, 'build')
src_prefix = os.path.join(sys.prefix, 'src')
else:
#Use tempfile to create a temporary folder
build_prefix = tempfile.mkdtemp('-build', 'pip-')
src_prefix = tempfile.mkdtemp('-src', 'pip-')
## FIXME: this is a terrible hack; change req.py (or other locations?)
## to flag a directory for deletion based on whether or not it matches
## build_prefix and src_prefix, NOT if pip has had to create it
try:
## FIXME: this isn't a very good default
build_prefix = os.path.join(os.getcwd(), 'build')
src_prefix = os.path.join(os.getcwd(), 'src')
os.rmdir(build_prefix)
os.rmdir(src_prefix)
except OSError:
# In case the current working directory has been renamed or deleted
sys.exit("The folder you are executing pip from can no longer be found.")
# I'm not sure why this wouldn't work, but just in case!
sys.exit("An error has occurred in attempting to set up the temporary directories")

# under Mac OS X + virtualenv sys.prefix is not properly resolved
# it is something like /path/to/python/bin/..
Expand Down