mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Restore deleted _copy_dist_from_dir().
This reverts commit 62ac258e1e
.
https://github.com/pypa/pip/pull/3176 is about to add the missing piece that makes this code useful (and not dead), so let's not delete it.
This commit is contained in:
parent
9e5e34e9f7
commit
4c405a0ad3
|
@ -702,6 +702,45 @@ def unpack_file_url(link, location, download_dir=None, hashes=None):
|
|||
_copy_file(from_path, download_dir, content_type, link)
|
||||
|
||||
|
||||
def _copy_dist_from_dir(link_path, location):
|
||||
"""Copy distribution files in `link_path` to `location`.
|
||||
|
||||
Invoked when user requests to install a local directory. E.g.:
|
||||
|
||||
pip install .
|
||||
pip install ~/dev/git-repos/python-prompt-toolkit
|
||||
|
||||
"""
|
||||
|
||||
# Note: This is currently VERY SLOW if you have a lot of data in the
|
||||
# directory, because it copies everything with `shutil.copytree`.
|
||||
# What it should really do is build an sdist and install that.
|
||||
# See https://github.com/pypa/pip/issues/2195
|
||||
|
||||
if os.path.isdir(location):
|
||||
rmtree(location)
|
||||
|
||||
# build an sdist
|
||||
setup_py = 'setup.py'
|
||||
sdist_args = [sys.executable]
|
||||
sdist_args.append('-c')
|
||||
sdist_args.append(
|
||||
"import setuptools, tokenize;__file__=%r;"
|
||||
"exec(compile(getattr(tokenize, 'open', open)(__file__).read()"
|
||||
".replace('\\r\\n', '\\n'), __file__, 'exec'))" % setup_py)
|
||||
sdist_args.append('sdist')
|
||||
sdist_args += ['--dist-dir', location]
|
||||
logger.info('Running setup.py sdist for %s', link_path)
|
||||
|
||||
with indent_log():
|
||||
call_subprocess(sdist_args, cwd=link_path, show_stdout=False)
|
||||
|
||||
# unpack sdist into `location`
|
||||
sdist = os.path.join(location, os.listdir(location)[0])
|
||||
logger.info('Unpacking sdist %s into %s', sdist, location)
|
||||
unpack_file(sdist, location, content_type=None, link=None)
|
||||
|
||||
|
||||
class PipXmlrpcTransport(xmlrpc_client.Transport):
|
||||
"""Provide a `xmlrpclib.Transport` implementation via a `PipSession`
|
||||
object.
|
||||
|
|
Loading…
Reference in a new issue