Skip to content

Commit

Permalink
Merge pull request #583 from costypetrisor/editable-no-archive
Browse files Browse the repository at this point in the history
pip-compile must not archive the entire directory of a locally available editable requirement
  • Loading branch information
vphilippon authored Nov 23, 2017
2 parents de486b8 + 3b9b5d8 commit bef5d3b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
7 changes: 6 additions & 1 deletion piptools/repositories/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,12 @@ def get_dependencies(self, ireq):
raise TypeError('Expected pinned or editable InstallRequirement, got {}'.format(ireq))

if ireq not in self._dependencies_cache:
if ireq.link and not ireq.link.is_artifact:
if ireq.editable and (ireq.source_dir and os.path.exists(ireq.source_dir)):
# No download_dir for locally available editable requirements.
# If a download_dir is passed, pip will unnecessarely
# archive the entire source directory
download_dir = None
elif ireq.link and not ireq.link.is_artifact:
# No download_dir for VCS sources. This also works around pip
# using git-checkout-index, which gets rid of the .git dir.
download_dir = None
Expand Down
23 changes: 23 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,29 @@ def test_editable_package_vcs(tmpdir):
assert 'pytest' in out.output # dependency of pytest-django


def test_locally_available_editable_package_is_not_archived_in_cache_dir(tmpdir):
""" piptools will not create an archive for a locally available editable requirement """
cache_dir = tmpdir.mkdir('cache_dir')

fake_package_dir = os.path.join(os.path.split(__file__)[0], 'fixtures', 'small_fake_package')
fake_package_dir = 'file:' + pathname2url(fake_package_dir)

with mock.patch('piptools.repositories.pypi.CACHE_DIR', new=str(cache_dir)):
runner = CliRunner()
with runner.isolated_filesystem():
with open('requirements.in', 'w') as req_in:
req_in.write('-e ' + fake_package_dir) # require editable fake package

out = runner.invoke(cli, ['-n'])

assert out.exit_code == 0
assert fake_package_dir in out.output
assert 'six==1.10.0' in out.output

# we should not find any archived file in {cache_dir}/pkgs
assert not os.listdir(os.path.join(str(cache_dir), 'pkgs'))


def test_input_file_without_extension(tmpdir):
"""
piptools can compile a file without an extension,
Expand Down

0 comments on commit bef5d3b

Please sign in to comment.