Skip to content

Commit

Permalink
Merge pull request #1098 from techalchemy/bugfix/1079-shallow-editabl…
Browse files Browse the repository at this point in the history
…e-installs

Stop excluding files from package list...
  • Loading branch information
nateprewitt authored Dec 4, 2017
2 parents 3c80c3c + 9b4f1c8 commit d122401
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 7 deletions.
23 changes: 17 additions & 6 deletions pipenv/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,34 @@ def path_to(self, p):
def _build_package_list(self, package_section):
"""Returns a list of packages for pip-tools to consume."""
ps = {}
# TODO: Separate the logic for showing packages from the filters for supplying pip-tools
for k, v in self.parsed_pipfile.get(package_section, {}).items():
# Skip editable VCS deps.
if hasattr(v, 'keys'):
# When a vcs url is given without editable it only appears as a key
if is_vcs(v) or is_vcs(k):
# Non-editable VCS entries can't be resolved by piptools
# When a vcs url is gven without editable it only appears as a key
# Eliminate any vcs, path, or url entries which are not editable
# Since pip-tools can't do deep resolution on them, even setuptools-installable ones
if (is_vcs(v) or is_vcs(k) or (is_installable_file(k) or is_installable_file(v)) or
any((prefix in v and
(os.path.isfile(v[prefix]) or is_valid_url(v[prefix])))
for prefix in ['path', 'file'])):
# If they are editable, do resolve them
if 'editable' not in v:
continue
else:
ps.update({k: v})
else:
if not (is_installable_file(k) or is_installable_file(v) or
any(file_prefix in v for file_prefix in ['path', 'file'])):
ps.update({k: v})
ps.update({k: v})
else:
# Since these entries have no attributes we know they are not editable
# So we can safely exclude things that need to be editable in order to be resolved
# First exclude anything that is a vcs entry either in the key or value
if not (any(is_vcs(i) for i in [k, v]) or
# Then exclude any installable files that are not directories
# Because pip-tools can resolve setup.py for example
any(is_installable_file(i) for i in [k, v]) or
# Then exclude any URLs because they need to be editable also
# Things that are excluded can only be 'shallow resolved'
any(is_valid_url(i) for i in [k, v])):
ps.update({k: v})
return ps
Expand Down
2 changes: 1 addition & 1 deletion pipenv/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def get_requirement(dep):
# Only parse if it is a file or an installable dir
if dep_path.is_file() or (dep_path.is_dir() and pip.utils.is_installable_dir(dep)):
if dep_path.is_absolute() or dep_path.as_posix() == '.':
path = dep
path = dep_path.as_posix()
else:
path = get_converted_relative_path(dep)
dep = dep_path.resolve().as_uri()
Expand Down
23 changes: 23 additions & 0 deletions tests/test_pipenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,29 @@ def test_urls_work(self):

assert 'file' in dep

@pytest.mark.install
@pytest.mark.files
@pytest.mark.resolver
def test_local_package(self):
"""This test ensures that local packages (directories with a setup.py)
installed in editable mode have their dependencies resolved as well"""
file_name = 'tablib-0.12.1.tar.gz'
package = 'tablib-0.12.1'
# Not sure where travis/appveyor run tests from
test_dir = os.path.dirname(os.path.abspath(__file__))
source_path = os.path.abspath(os.path.join(test_dir, 'test_artifacts', file_name))
with PipenvInstance() as p:
# This tests for a bug when installing a zipfile in the current dir
copy_to = os.path.join(p.path, file_name)
shutil.copy(source_path, copy_to)
import tarfile
with tarfile.open(copy_to, 'r:gz') as tgz:
tgz.extractall(path=p.path)
c = p.pipenv('install -e {0}'.format(package))
assert c.return_code == 0
assert all(pkg in p.lockfile['default'] for pkg in ['xlrd', 'xlwt', 'pyyaml', 'odfpy'])


@pytest.mark.install
@pytest.mark.files
def test_local_zipfiles(self):
Expand Down

0 comments on commit d122401

Please sign in to comment.