Skip to content

Commit

Permalink
Ensure develop flag is respected for git packages (#1321)
Browse files Browse the repository at this point in the history
Resolves: #1080
  • Loading branch information
abn authored and kasteph committed Sep 24, 2019
1 parent 0a5b448 commit f0855d9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
9 changes: 7 additions & 2 deletions poetry/installation/pip_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
34 changes: 32 additions & 2 deletions tests/installation/test_pip_installer.py
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]: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",
Expand All @@ -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 = "[email protected]: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", "[email protected]:demo/demo.git@master#egg=demo"]

assert expected == result

0 comments on commit f0855d9

Please sign in to comment.