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

WIP Install locked versions of dependencies #28

Draft
wants to merge 1 commit into
base: develop-0.0.x
Choose a base branch
from
Draft
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
20 changes: 20 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,12 @@ 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",
default=False,
)


@tox.hookimpl # type: ignore[misc]
Expand All @@ -58,6 +65,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 +140,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