From 483621f4789699a4a431a1cf2bdaa6c8cb256157 Mon Sep 17 00:00:00 2001 From: Frost Ming Date: Sat, 17 Nov 2018 00:10:46 +0800 Subject: [PATCH] recognize editable packages as in project Signed-off-by: Frost Ming --- pipenv/environment.py | 5 ++--- tests/integration/test_project.py | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/pipenv/environment.py b/pipenv/environment.py index 7a7fd2ea..8ac78dd8 100644 --- a/pipenv/environment.py +++ b/pipenv/environment.py @@ -246,7 +246,7 @@ class Environment(object): def find_egg(self, egg_dist): """Find an egg by name in the given environment""" - site_packages = get_python_lib() + site_packages = self.libdir[1] search_filename = "{0}.egg-link".format(egg_dist.project_name) try: user_site = site.getusersitepackages() @@ -264,8 +264,7 @@ class Environment(object): If the egg - link doesn 't exist, return the supplied distribution.""" location = self.find_egg(dist) - if not location: - return dist.location + return location or dist.location def dist_is_in_project(self, dist): """Determine whether the supplied distribution is in the environment.""" diff --git a/tests/integration/test_project.py b/tests/integration/test_project.py index 5e1bafb9..aa72673d 100644 --- a/tests/integration/test_project.py +++ b/tests/integration/test_project.py @@ -2,6 +2,7 @@ import io import pytest import os +import tarfile from pipenv.project import Project from pipenv.utils import temp_environ from pipenv.patched import pipfile @@ -161,3 +162,21 @@ version = "*" contents = f.read() assert "[packages.requests]" not in contents assert 'requests = {version = "*"}' in contents + + +@pytest.mark.install +@pytest.mark.project +def test_include_editable_packages(PipenvInstance, pypi, testsroot, tmpdir): + file_name = "requests-2.19.1.tar.gz" + package = os.path.join(tmpdir, "requests-2.19.1") + source_path = os.path.abspath(os.path.join(testsroot, "test_artifacts", file_name)) + with PipenvInstance(chdir=True, pypi=pypi) as p: + with tarfile.open(source_path, "r:gz") as tarinfo: + tarinfo.extractall(path=tmpdir) + c = p.pipenv('install -e {}'.format(package)) + assert c.return_code == 0 + project = Project() + assert "requests" in [ + package.project_name + for package in project.environment.get_installed_packages() + ]