recognize editable packages as in project

Signed-off-by: Frost Ming <mianghong@gmail.com>
This commit is contained in:
Frost Ming
2018-11-17 00:10:46 +08:00
parent 33e07181d3
commit 483621f478
2 changed files with 21 additions and 3 deletions
+2 -3
View File
@@ -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."""
+19
View File
@@ -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()
]