mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Merge pull request #6770 from omry/master
exclude '.tox', '.nox' from being copied during 'pip install .'
This commit is contained in:
commit
e4c32b9917
4 changed files with 61 additions and 3 deletions
|
@ -694,10 +694,21 @@ does not satisfy the ``--require-hashes`` demand that every package have a
|
|||
local hash.
|
||||
|
||||
|
||||
Local project installs
|
||||
++++++++++++++++++++++
|
||||
pip supports installing local project in both regular mode and editable mode.
|
||||
You can install local projects by specifying the project path to pip::
|
||||
|
||||
$ pip install path/to/SomeProject
|
||||
|
||||
During regular installation, pip will copy the entire project directory to a temporary location and install from there.
|
||||
The exception is that pip will exclude .tox and .nox directories present in the top level of the project from being copied.
|
||||
|
||||
|
||||
.. _`editable-installs`:
|
||||
|
||||
"Editable" Installs
|
||||
+++++++++++++++++++
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
"Editable" installs are fundamentally `"setuptools develop mode"
|
||||
<https://setuptools.readthedocs.io/en/latest/setuptools.html#development-mode>`_
|
||||
|
|
1
news/6770.bugfix
Normal file
1
news/6770.bugfix
Normal file
|
@ -0,0 +1 @@
|
|||
Skip copying .tox and .nox directories to temporary build directories
|
|
@ -967,12 +967,23 @@ def unpack_file_url(
|
|||
of the link file inside download_dir.
|
||||
"""
|
||||
link_path = url_to_path(link.url_without_fragment)
|
||||
|
||||
# If it's a url to a local directory
|
||||
if is_dir_url(link):
|
||||
|
||||
def ignore(d, names):
|
||||
# Pulling in those directories can potentially be very slow,
|
||||
# exclude the following directories if they appear in the top
|
||||
# level dir (and only it).
|
||||
# See discussion at https://github.com/pypa/pip/pull/6770
|
||||
return ['.tox', '.nox'] if d == link_path else []
|
||||
|
||||
if os.path.isdir(location):
|
||||
rmtree(location)
|
||||
shutil.copytree(link_path, location, symlinks=True)
|
||||
shutil.copytree(link_path,
|
||||
location,
|
||||
symlinks=True,
|
||||
ignore=ignore)
|
||||
|
||||
if download_dir:
|
||||
logger.info('Link is a directory, ignoring download_dir')
|
||||
return
|
||||
|
|
|
@ -431,6 +431,41 @@ class Test_unpack_file_url(object):
|
|||
assert os.path.isdir(os.path.join(self.build_dir, 'fspkg'))
|
||||
|
||||
|
||||
@pytest.mark.parametrize('exclude_dir', [
|
||||
'.nox',
|
||||
'.tox'
|
||||
])
|
||||
def test_unpack_file_url_excludes_expected_dirs(tmpdir, exclude_dir):
|
||||
src_dir = tmpdir / 'src'
|
||||
dst_dir = tmpdir / 'dst'
|
||||
src_included_file = src_dir.joinpath('file.txt')
|
||||
src_excluded_dir = src_dir.joinpath(exclude_dir)
|
||||
src_excluded_file = src_dir.joinpath(exclude_dir, 'file.txt')
|
||||
src_included_dir = src_dir.joinpath('subdir', exclude_dir)
|
||||
|
||||
# set up source directory
|
||||
src_excluded_dir.mkdir(parents=True)
|
||||
src_included_dir.mkdir(parents=True)
|
||||
src_included_file.touch()
|
||||
src_excluded_file.touch()
|
||||
|
||||
dst_included_file = dst_dir.joinpath('file.txt')
|
||||
dst_excluded_dir = dst_dir.joinpath(exclude_dir)
|
||||
dst_excluded_file = dst_dir.joinpath(exclude_dir, 'file.txt')
|
||||
dst_included_dir = dst_dir.joinpath('subdir', exclude_dir)
|
||||
|
||||
src_link = Link(path_to_url(src_dir))
|
||||
unpack_file_url(
|
||||
src_link,
|
||||
dst_dir,
|
||||
download_dir=None
|
||||
)
|
||||
assert not os.path.isdir(dst_excluded_dir)
|
||||
assert not os.path.isfile(dst_excluded_file)
|
||||
assert os.path.isfile(dst_included_file)
|
||||
assert os.path.isdir(dst_included_dir)
|
||||
|
||||
|
||||
class TestSafeFileCache:
|
||||
"""
|
||||
The no_perms test are useless on Windows since SafeFileCache uses
|
||||
|
|
Loading…
Reference in a new issue