From e5f805758eafbb1bc53c1c369419f84911cd2fb9 Mon Sep 17 00:00:00 2001 From: Arun Babu Neelicattu Date: Sat, 24 Aug 2019 01:47:30 +0200 Subject: [PATCH] Ensure develop flag is respected for git packages Resolves: #1080 --- poetry/installation/pip_installer.py | 9 +++++-- tests/installation/test_pip_installer.py | 34 ++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/poetry/installation/pip_installer.py b/poetry/installation/pip_installer.py index 68904c34bb0..cab9b3ac185 100644 --- a/poetry/installation/pip_installer.py +++ b/poetry/installation/pip_installer.py @@ -138,10 +138,15 @@ def requirement(self, package, formatted=False): return req if package.source_type == "git": - return "git+{}@{}#egg={}".format( + req = "git+{}@{}#egg={}".format( package.source_url, package.source_reference, package.name ) + if package.develop: + req = ["-e", req] + + return req + return "{}=={}".format(package.name, package.version) def create_temporary_requirement(self, package): @@ -226,6 +231,6 @@ def install_git(self, package): pkg = Package(package.name, package.version) pkg.source_type = "directory" pkg.source_url = str(src_dir) - pkg.develop = True + pkg.develop = package.develop self.install_directory(pkg) diff --git a/tests/installation/test_pip_installer.py b/tests/installation/test_pip_installer.py index 89b44cf9465..aab748928e7 100644 --- a/tests/installation/test_pip_installer.py +++ b/tests/installation/test_pip_installer.py @@ -1,12 +1,26 @@ +import pytest + from poetry.installation.pip_installer import PipInstaller from poetry.io import NullIO from poetry.packages.package import Package from poetry.utils.env import NullEnv -def test_requirement(): - installer = PipInstaller(NullEnv(), NullIO()) +@pytest.fixture +def package_git(): + package = Package("demo", "1.0.0") + package.source_type = "git" + package.source_url = "git@github.com:demo/demo.git" + package.source_reference = "master" + return package + + +@pytest.fixture +def installer(): + return PipInstaller(NullEnv(), NullIO()) + +def test_requirement(installer): package = Package("ipython", "7.5.0") package.hashes = [ "md5:dbdc53e3918f28fa335a173432402a00", @@ -22,3 +36,19 @@ def test_requirement(): ) assert expected == result + + +def test_requirement_git_develop_false(installer, package_git): + package_git.develop = False + result = installer.requirement(package_git) + expected = "git+git@github.com:demo/demo.git@master#egg=demo" + + assert expected == result + + +def test_requirement_git_develop_true(installer, package_git): + package_git.develop = True + result = installer.requirement(package_git) + expected = ["-e", "git+git@github.com:demo/demo.git@master#egg=demo"] + + assert expected == result