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

Fixes custom repositories with wrong precedence #2678

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion poetry/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def create_poetry(
# Always put PyPI last to prefer private repositories
# but only if we have no other default source
if not poetry.pool.has_default():
poetry.pool.add_repository(PyPiRepository(), True)
poetry.pool.add_repository(PyPiRepository(), default=False)
else:
if io.is_debug():
io.write_line("Deactivating the PyPI repository")
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/with_custom_source/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
My Package
==========
60 changes: 60 additions & 0 deletions tests/fixtures/with_custom_source/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[tool.poetry]
name = "my-package"
version = "1.2.3"
description = "Some description."
authors = [
"Sébastien Eustace <[email protected]>"
]
license = "MIT"

readme = "README.rst"

homepage = "https://python-poetry.org"
repository = "https://github.com/python-poetry/poetry"
documentation = "https://python-poetry.org/docs"

keywords = ["packaging", "dependency", "poetry"]

classifiers = [
"Topic :: Software Development :: Build Tools",
"Topic :: Software Development :: Libraries :: Python Modules"
]

# Requirements
[tool.poetry.dependencies]
python = "~2.7 || ^3.6"
cleo = "^0.6"
pendulum = { git = "https://github.com/sdispater/pendulum.git", branch = "2.0" }
requests = { version = "^2.18", optional = true, extras=[ "security" ] }
pathlib2 = { version = "^2.2", python = "~2.7" }

orator = { version = "^0.9", optional = true }

# File dependency
demo = { path = "../distributions/demo-0.1.0-py2.py3-none-any.whl" }

# Dir dependency with setup.py
my-package = { path = "../project_with_setup/" }

# Dir dependency with pyproject.toml
simple-project = { path = "../simple_project/" }


[tool.poetry.extras]
db = [ "orator" ]

[tool.poetry.dev-dependencies]
pytest = "~3.4"


[tool.poetry.scripts]
my-script = "my_package:main"


[tool.poetry.plugins."blogtool.parsers"]
".rst" = "some_module::SomeClass"


[[tool.poetry.source]]
name = "foo"
url = "https://foo.bar/simple/"
8 changes: 8 additions & 0 deletions tests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ def test_poetry_with_two_default_sources():
assert "Only one repository can be the default" == str(e.value)


def test_poetry_with_custom_source():
poetry = Factory().create_poetry(fixtures_dir / "with_custom_source")

assert ["foo", "PyPI"] == [
repository.name for repository in poetry.pool.repositories
]


def test_validate():
complete = TomlFile(fixtures_dir / "complete.toml")
content = complete.read()["tool"]["poetry"]
Expand Down