Skip to content

Commit

Permalink
WIP Install locked versions of dependencies
Browse files Browse the repository at this point in the history
GitHub: #24
  • Loading branch information
sinoroc committed Oct 1, 2020
1 parent a73a33b commit 00cfd81
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/tox_poetry_dev_dependencies/_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import typing

import poetry.core.factory
import poetry.core.poetry
import tox

if typing.TYPE_CHECKING:
Expand Down Expand Up @@ -48,6 +49,11 @@ def tox_addoption(parser: tox.config.Parser) -> None:
"'PIP_EXTRA_INDEX_URL')."
),
)
parser.add_testenv_attribute(
'poetry_install_locked_dependencies',
'bool',
"Install locked versions of the dependencies according to lock file",
)


@tox.hookimpl # type: ignore[misc]
Expand All @@ -58,6 +64,8 @@ def tox_configure(config: tox.config.Config) -> None:
except NoPoetryFound:
pass
else:
pinned_deps = _get_pinned_deps(poetry_)
#
dev_deps = _get_dev_requirements(poetry_)
_add_dev_dependencies(config, dev_deps)
#
Expand Down Expand Up @@ -131,6 +139,17 @@ def _get_dev_requirements(
return requirements


def _get_pinned_deps(
poetry_: poetry.core.poetry.Poetry,
) -> typing.List[tox.config.DepConfig]:
#
pinned_deps = [
tox.config.DepConfig(dependency.to_dependency().to_pep_508())
for dependency in poetry_.locker.get_packages()
]
return pinned_deps


def _get_index_servers(
poetry_: poetry.core.poetry.Poetry,
) -> 'IndexServersT':
Expand Down

0 comments on commit 00cfd81

Please sign in to comment.