Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
sdispater committed Sep 7, 2018
2 parents e6261dc + 9d87b56 commit 30a848f
Show file tree
Hide file tree
Showing 13 changed files with 109 additions and 20 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Change Log

## [Unreleased]
## [0.11.5] - 2018-09-04

### Fixed

- Fixed a recursion error with circular dependencies.
- Fixed the `config` command setting incorrect values for paths.
- Fixed an `OSError` on Python >= 3.5 for `git` dependencies with recursive symlinks.
- Fixed the possible deletion of system paths by `cache:clear`.
- Fixed a performance issue when parsing the lock file by upgrading `tomlkit`.


## [0.11.4] - 2018-07-30
Expand Down Expand Up @@ -463,7 +467,8 @@ Initial release



[Unreleased]: https://github.com/sdispater/poetry/compare/0.11.4...master
[Unreleased]: https://github.com/sdispater/poetry/compare/0.11.5...master
[0.11.5]: https://github.com/sdispater/poetry/releases/tag/0.11.5
[0.11.4]: https://github.com/sdispater/poetry/releases/tag/0.11.4
[0.11.3]: https://github.com/sdispater/poetry/releases/tag/0.11.3
[0.11.2]: https://github.com/sdispater/poetry/releases/tag/0.11.2
Expand Down
2 changes: 1 addition & 1 deletion docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ theme:
extra:
version: 2.0

pages:
nav:
- Introduction: index.md
- Basic Usage: basic-usage.md
- Libraries: libraries.md
Expand Down
2 changes: 1 addition & 1 deletion poetry/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.11.4"
__version__ = "0.11.5"
16 changes: 13 additions & 3 deletions poetry/console/commands/cache/clear.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,26 @@ class CacheClearCommand(Command):
def handle(self):
from cachy import CacheManager
from poetry.locations import CACHE_DIR
from poetry.utils._compat import Path

cache = self.argument("cache")

parts = cache.split(":")
cache_dir = os.path.join(CACHE_DIR, "cache", "repositories", parts[0])
root = parts[0]

base_cache = Path(CACHE_DIR) / "cache" / "repositories"
cache_dir = base_cache / root

try:
cache_dir.relative_to(base_cache)
except ValueError:
raise ValueError("{} is not a valid repository cache".format(root))

cache = CacheManager(
{
"default": parts[0],
"serializer": "json",
"stores": {parts[0]: {"driver": "file", "path": cache_dir}},
"stores": {parts[0]: {"driver": "file", "path": str(cache_dir)}},
}
)

Expand All @@ -41,7 +51,7 @@ def handle(self):

# Calculate number of entries
entries_count = 0
for path, dirs, files in os.walk(cache_dir):
for path, dirs, files in os.walk(str(cache_dir)):
entries_count += len(files)

delete = self.confirm(
Expand Down
2 changes: 1 addition & 1 deletion poetry/console/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def unique_config_values(self):
),
"settings.virtualenvs.path": (
str,
lambda val: str(Path(val).resolve()),
lambda val: str(Path(val)),
str(Path(CACHE_DIR) / "virtualenvs"),
),
}
Expand Down
2 changes: 1 addition & 1 deletion poetry/packages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def dependency_from_pep_508(name):

for or_ in markers["extra"]:
for _, extra in or_:
dep.extras.append(extra)
dep.in_extras.append(extra)

if "python_version" in markers:
ors = []
Expand Down
38 changes: 34 additions & 4 deletions poetry/puzzle/provider.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import glob
import logging
import os
import pkginfo
Expand Down Expand Up @@ -25,6 +26,7 @@

from poetry.repositories import Pool

from poetry.utils._compat import PY35
from poetry.utils._compat import Path
from poetry.utils.helpers import parse_requires
from poetry.utils.toml_file import TomlFile
Expand Down Expand Up @@ -193,7 +195,21 @@ def search_for_vcs(self, dependency): # type: (VCSDependency) -> List[Package]
try:
venv.run("python", "setup.py", "egg_info")

egg_info = next(tmp_dir.glob("**/*.egg-info"))
# Sometimes pathlib will fail on recursive
# symbolic links, so we need to workaround it
# and use the glob module instead.
# Note that this does not happen with pathlib2
# so it's safe to use it for Python < 3.4.
if PY35:
egg_info = next(
Path(p)
for p in glob.glob(
os.path.join(str(tmp_dir), "**", "*.egg-info"),
recursive=True,
)
)
else:
egg_info = next(tmp_dir.glob("**/*.egg-info"))

meta = pkginfo.UnpackedSDist(str(egg_info))

Expand All @@ -209,7 +225,15 @@ def search_for_vcs(self, dependency): # type: (VCSDependency) -> List[Package]
package = Package(meta.name, meta.version)

for req in reqs:
package.requires.append(dependency_from_pep_508(req))
dep = dependency_from_pep_508(req)
if dep.in_extras:
for extra in dep.in_extras:
if extra not in package.extras:
package.extras[extra] = []

package.extras[extra].append(dep)

package.requires.append(dep)
except Exception:
raise
finally:
Expand All @@ -231,6 +255,12 @@ def search_for_vcs(self, dependency): # type: (VCSDependency) -> List[Package]
)
)

if dependency.extras:
for extra in dependency.extras:
if extra in package.extras:
for dep in package.extras[extra]:
dep.activate()

return [package]

def search_for_file(self, dependency): # type: (FileDependency) -> List[Package]
Expand Down Expand Up @@ -314,10 +344,10 @@ def incompatibilities_for(
]

def complete_package(self, package): # type: (str, Version) -> Package
if package.is_root() or package.source_type in {"git", "file"}:
if package.is_root():
return package

if package.source_type != "directory":
if package.source_type not in {"directory", "file", "git"}:
package = self._pool.package(
package.name, package.version.text, extras=package.requires_extras
)
Expand Down
4 changes: 2 additions & 2 deletions poetry/repositories/pypi_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ def package(
)
continue

if dependency.extras:
for extra in dependency.extras:
if dependency.in_extras:
for extra in dependency.in_extras:
if extra not in package.extras:
package.extras[extra] = []

Expand Down
1 change: 1 addition & 0 deletions poetry/utils/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@


PY2 = sys.version_info[0] == 2
PY35 = sys.version_info >= (3, 5)
PY36 = sys.version_info >= (3, 6)


Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "poetry"
version = "0.11.4"
version = "0.11.5"
description = "Python dependency management and packaging made easy."
authors = [
"Sébastien Eustace <[email protected]>"
Expand Down Expand Up @@ -34,7 +34,7 @@ cachecontrol = { version = "^0.12.4", extras = ["filecache"] }
pkginfo = "^1.4"
html5lib = "^1.0"
shellingham = "^1.1"
tomlkit = "^0.4.0"
tomlkit = "^0.4.4"

# The typing module is not in the stdlib in Python 2.7 and 3.4
typing = { version = "^3.6", python = "~2.7 || ~3.4" }
Expand All @@ -47,7 +47,7 @@ virtualenv = { version = "^16.0", python = "~2.7" }
[tool.poetry.dev-dependencies]
pytest = "^3.4"
pytest-cov = "^2.5"
mkdocs = "^0.17.3"
mkdocs = "^1.0"
pymdown-extensions = "^4.9"
pygments = "^2.2"
pytest-mock = "^1.9"
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/git/github.com/demo/demo/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
url="https://github.com/demo/demo",
packages=["demo"],
install_requires=["pendulum>=1.4.4"],
extras_require={"foo": ["cleo"]},
)


Expand Down
4 changes: 2 additions & 2 deletions tests/packages/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_dependency_from_pep_508_with_extras():

assert dep.name == "requests"
assert str(dep.constraint) == "2.18.0"
assert dep.extras == ["foo", "bar"]
assert dep.in_extras == ["foo", "bar"]


def test_dependency_from_pep_508_with_python_version():
Expand Down Expand Up @@ -84,7 +84,7 @@ def test_dependency_from_pep_508_complex():

assert dep.name == "requests"
assert str(dep.constraint) == "2.18.0"
assert dep.extras == ["foo"]
assert dep.in_extras == ["foo"]
assert dep.python_versions == ">=2.7 !=3.2.*"
assert dep.platform == "win32 || darwin"

Expand Down
42 changes: 42 additions & 0 deletions tests/puzzle/test_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from tests.helpers import get_dependency
from tests.helpers import get_package
from tests.repositories.test_pypi_repository import MockRepository


@pytest.fixture()
Expand Down Expand Up @@ -921,3 +922,44 @@ def test_solver_does_not_get_stuck_in_recursion_on_circular_dependency(
{"job": "install", "package": package_a},
],
)


def test_solver_can_resolve_git_dependencies(solver, repo, package):
pendulum = get_package("pendulum", "2.0.3")
cleo = get_package("cleo", "1.0.0")
repo.add_package(pendulum)
repo.add_package(cleo)

package.add_dependency("demo", {"git": "https://github.com/demo/demo.git"})

ops = solver.solve()

check_solver_result(
ops,
[
{"job": "install", "package": pendulum},
{"job": "install", "package": get_package("demo", "0.1.2")},
],
)


def test_solver_can_resolve_git_dependencies_with_extras(solver, repo, package):
pendulum = get_package("pendulum", "2.0.3")
cleo = get_package("cleo", "1.0.0")
repo.add_package(pendulum)
repo.add_package(cleo)

package.add_dependency(
"demo", {"git": "https://github.com/demo/demo.git", "extras": ["foo"]}
)

ops = solver.solve()

check_solver_result(
ops,
[
{"job": "install", "package": cleo},
{"job": "install", "package": pendulum},
{"job": "install", "package": get_package("demo", "0.1.2")},
],
)

0 comments on commit 30a848f

Please sign in to comment.