Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure develop flag is respected for git packages #1321

Merged
merged 1 commit into from
Sep 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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