Skip to content
Permalink
Browse files

Fix installation with non-PyPI default repository

Co-authored-by: rusty <rusty@spoqa.com>
  • Loading branch information
sdispater and pbzweihander committed Jul 5, 2019
1 parent d78b57f commit 6f4aa21ce65dd719cfc98951d207ff39cd1d94cf
Showing with 33 additions and 10 deletions.
  1. +8 −10 poetry/installation/pip_installer.py
  2. +25 −0 tests/installation/test_pip_installer.py
@@ -3,10 +3,9 @@

from subprocess import CalledProcessError

from clikit.api.io import IO
from clikit.io import NullIO

from poetry.config import Config
from poetry.utils.helpers import get_http_basic_auth
from poetry.utils.helpers import safe_rmtree


@@ -15,19 +14,15 @@
except ImportError:
import urlparse

from poetry.repositories.pool import Pool
from poetry.utils._compat import encode
from poetry.utils.env import Env

from .base_installer import BaseInstaller


class PipInstaller(BaseInstaller):
def __init__(
self,
env, # type: Env
io,
pool,
): # type: (...) -> None
def __init__(self, env, io, pool): # type: (Env, IO, Pool) -> None
self._env = env
self._io = io
self._pool = pool
@@ -60,8 +55,11 @@ def install(self, package, update=False):

args += ["--index-url", index_url]
if self._pool.has_default():
if repository.name != self._pool.default.name:
args += ["--extra-index-url", self._pool.default.authenticated_url]
if repository.name != self._pool.repositories[0].name:
args += [
"--extra-index-url",
self._pool.repositories[0].authenticated_url,
]

if update:
args.append("-U")
@@ -1,6 +1,7 @@
from poetry.installation.pip_installer import PipInstaller
from poetry.io.null_io import NullIO
from poetry.packages.package import Package
from poetry.repositories.legacy_repository import LegacyRepository
from poetry.repositories.pool import Pool
from poetry.utils.env import NullEnv

@@ -23,3 +24,27 @@ def test_requirement():
)

assert expected == result


def test_install_with_non_pypi_default_repository():

This comment has been minimized.

Copy link
@areeh

areeh Jul 10, 2019

Thanks for this

pool = Pool()

default = LegacyRepository("default", "https://default.com")
another = LegacyRepository("another", "https://another.com")

pool.add_repository(default, default=True)
pool.add_repository(another)

installer = PipInstaller(NullEnv(), NullIO(), pool)

foo = Package("foo", "0.0.0")
foo.source_type = "legacy"
foo.source_reference = default._name
foo.source_url = default._url
bar = Package("bar", "0.1.0")
bar.source_type = "legacy"
bar.source_reference = another._name
bar.source_url = another._url

installer.install(foo)
installer.install(bar)

0 comments on commit 6f4aa21

Please sign in to comment.
You can’t perform that action at this time.