From 4a4d012eedc72a6839c3e72b140c317e25bdc0e9 Mon Sep 17 00:00:00 2001 From: Arun Babu Neelicattu Date: Sun, 18 Aug 2019 05:17:15 +0200 Subject: [PATCH] Fix support for url sourced packages in pip installer This change fixes the installation of packages using a url source. Previously, the installer attempted to install the package using the name ignoring the source url. --- poetry/installation/pip_installer.py | 3 +++ tests/installation/test_pip_installer.py | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/poetry/installation/pip_installer.py b/poetry/installation/pip_installer.py index 1afd23f3443..c46ad1ce0e7 100644 --- a/poetry/installation/pip_installer.py +++ b/poetry/installation/pip_installer.py @@ -138,6 +138,9 @@ def requirement(self, package, formatted=False): package.source_url, package.source_reference, package.name ) + if package.source_type == "url": + return "{}#egg={}".format(package.source_url, package.name) + return "{}=={}".format(package.name, package.version) def create_temporary_requirement(self, package): diff --git a/tests/installation/test_pip_installer.py b/tests/installation/test_pip_installer.py index b901bf7f560..0f77b65ed4e 100644 --- a/tests/installation/test_pip_installer.py +++ b/tests/installation/test_pip_installer.py @@ -26,6 +26,19 @@ def test_requirement(): assert expected == result +def test_requirement_source_type_url(): + installer = PipInstaller(NullEnv(), NullIO(), Pool()) + + foo = Package("foo", "0.0.0") + foo.source_type = "url" + foo.source_url = "https://somehwere.com/releases/foo-1.0.0.tar.gz" + + result = installer.requirement(foo, formatted=True) + expected = "{}#egg={}".format(foo.source_url, foo.name) + + assert expected == result + + def test_install_with_non_pypi_default_repository(): pool = Pool()