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

pip-compile must not archive the entire directory of a locally available editable requirement #583

Merged
merged 2 commits into from
Nov 23, 2017
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
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