Skip to content
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

write pip delete marker into global build dir upon creation #948

Merged
merged 1 commit into from
May 19, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions pip/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@

default_cert_path = os.path.join(os.path.dirname(__file__), 'cacert.pem')

DELETE_MARKER_MESSAGE = '''\
This file is placed here by pip to indicate the source was put
here by pip.

Once this package is successfully installed this source code will be
deleted (unless you remove this file).
'''
PIP_DELETE_MARKER_FILENAME = 'pip-delete-this-directory.txt'

def write_delete_marker_file(directory):
"""
Write the pip delete marker file into this directory.
"""
filepath = os.path.join(directory, PIP_DELETE_MARKER_FILENAME)
marker_fp = open(filepath, 'w')
marker_fp.write(DELETE_MARKER_MESSAGE)
marker_fp.close()


def running_under_virtualenv():
"""
Return True if we're running inside a virtualenv, False otherwise.
Expand Down Expand Up @@ -38,6 +57,7 @@ def _get_build_prefix():
return path
try:
os.mkdir(path)
write_delete_marker_file(path)
except OSError:
file_uid = None
try:
Expand Down
26 changes: 4 additions & 22 deletions pip/req.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import zipfile

from distutils.util import change_root
from pip.locations import bin_py, running_under_virtualenv
from pip.locations import (bin_py, running_under_virtualenv,PIP_DELETE_MARKER_FILENAME,
write_delete_marker_file)
from pip.exceptions import (InstallationError, UninstallationError,
BestVersionAlreadyInstalled,
DistributionNotFound, PreviousBuildDirError)
Expand All @@ -33,10 +34,6 @@
import pip.wheel
from pip.wheel import move_wheel_files


PIP_DELETE_MARKER_FILENAME = 'pip-delete-this-directory.txt'


class InstallRequirement(object):

def __init__(self, req, comes_from, source_dir=None, editable=False,
Expand Down Expand Up @@ -801,15 +798,6 @@ def delete_marker_filename(self):
return os.path.join(self.source_dir, PIP_DELETE_MARKER_FILENAME)


DELETE_MARKER_MESSAGE = '''\
This file is placed here by pip to indicate the source was put
here by pip.

Once this package is successfully installed this source code will be
deleted (unless you remove this file).
'''


class Requirements(object):

def __init__(self):
Expand Down Expand Up @@ -1220,7 +1208,7 @@ def unpack_url(self, link, location, only_download=False):
self.download_cache = os.path.expanduser(self.download_cache)
retval = unpack_http_url(link, location, self.download_cache, self.download_dir)
if only_download:
_write_delete_marker_message(os.path.join(location, PIP_DELETE_MARKER_FILENAME))
write_delete_marker_file(location)
return retval

def install(self, install_options, global_options=(), *args, **kwargs):
Expand Down Expand Up @@ -1335,13 +1323,7 @@ def _clean_zip_name(self, name, prefix):

def _make_build_dir(build_dir):
os.makedirs(build_dir)
_write_delete_marker_message(os.path.join(build_dir, PIP_DELETE_MARKER_FILENAME))


def _write_delete_marker_message(filepath):
marker_fp = open(filepath, 'w')
marker_fp.write(DELETE_MARKER_MESSAGE)
marker_fp.close()
write_delete_marker_file(build_dir)


_scheme_re = re.compile(r'^(http|https|file):', re.I)
Expand Down