Skip to content

Commit

Permalink
Fix git dependencies prereleases resolution (#1458)
Browse files Browse the repository at this point in the history
  • Loading branch information
sdispater authored Oct 11, 2019
1 parent af71f6c commit 8a7764f
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 3 deletions.
8 changes: 7 additions & 1 deletion poetry/repositories/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ def find_packages(

for package in self.packages:
if name == package.name:
if package.is_prerelease() and not allow_prereleases:
if (
package.is_prerelease()
and not allow_prereleases
and not package.source_type
):
# If prereleases are not allowed and the package is a prerelease
# and is a standard package then we skip it
continue

if constraint.allows(package.version):
Expand Down
3 changes: 1 addition & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def mock_clone(_, source, dest):
parts = urlparse.urlparse(source)

folder = (
Path(__file__).parent.parent
Path(__file__).parent
/ "fixtures"
/ "git"
/ parts.netloc
Expand All @@ -91,7 +91,6 @@ def mock_clone(_, source, dest):
if dest.exists():
shutil.rmtree(str(dest))

shutil.rmtree(str(dest))
shutil.copytree(str(folder), str(dest))


Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[tool.poetry]
name = "prerelease"
version = "1.0.0.dev0"
description = "Some description."
authors = [
"Sébastien Eustace <[email protected]>"
]
license = "MIT"

# Requirements
[tool.poetry.dependencies]
python = "~2.7 || ^3.4"

[tool.poetry.dev-dependencies]
28 changes: 28 additions & 0 deletions tests/installation/test_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1529,3 +1529,31 @@ def test_run_installs_with_url_file(installer, locker, repo, package):
assert locker.written_data == expected

assert len(installer.installer.installs) == 2


def test_installer_uses_prereleases_if_they_are_compatible(
installer, locker, package, repo
):
package.python_versions = "~2.7 || ^3.4"
package.add_dependency(
"prerelease", {"git": "https://github.com/demo/prerelease.git"}
)

package_b = get_package("b", "2.0.0")
package_b.add_dependency("prerelease", ">=0.19")

repo.add_package(package_b)

installer.run()

del installer.installer.installs[:]
locker.locked(True)
locker.mock_lock_data(locker.written_data)

package.add_dependency("b", "^2.0.0")

installer.whitelist(["b"])
installer.update(True)
installer.run()

assert len(installer.installer.installs) == 2

0 comments on commit 8a7764f

Please sign in to comment.