Skip to content

Commit

Permalink
Add tests and comments to prevent regression
Browse files Browse the repository at this point in the history
- Ensure we resolve install_requires from local setup.py files
  • Loading branch information
techalchemy committed Nov 19, 2017
1 parent dbbdb4a commit 9ffe911
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pipenv/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def _build_package_list(self, package_section):
# Exempt setuptools-installable directories
if (is_vcs(v) or is_vcs(k) or (is_installable_file(k) and os.path.isfile(k)) or
any((prefix in v and
(os.path.isfile(v[prefix]) or is_valid_url(v[prefix])))
for prefix in ['path', 'file'])):
(os.path.isfile(v[prefix]) or is_valid_url(v[prefix])))
for prefix in ['path', 'file'])):
# Non-editable VCS entries can't be resolved by piptools
if 'editable' not in v:
continue
Expand All @@ -76,8 +76,15 @@ def _build_package_list(self, package_section):
else:
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) and os.path.isfile(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
23 changes: 23 additions & 0 deletions tests/test_pipenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,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 9ffe911

Please sign in to comment.