Skip to content

Commit

Permalink
Add support for URL dependencies in lockfile
Browse files Browse the repository at this point in the history
GitHub: closes #45
  • Loading branch information
sinoroc committed Oct 19, 2020
1 parent 662f4f5 commit 3a720f0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
0.0.5.dev0
==========

* Add support for URL dependencies in lockfile


0.0.4
=====
Expand Down
20 changes: 18 additions & 2 deletions src/tox_poetry_dev_dependencies/_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class CanNotHaveMultipleDefaultSourceRepositories(_Exception):
"""Can not have multiple 'default' source repositories."""


class UnsupportedLockedDependency(_Exception):
"""Unsupported type of locked dependency."""


@tox.hookimpl # type: ignore[misc]
def tox_addoption(parser: tox.config.Parser) -> None:
"""Set hook."""
Expand Down Expand Up @@ -307,14 +311,26 @@ def _get_locked_deps(
lock_document = tomlkit.parse(lock_str)
#
for dependency in lock_document['package']:
#
dep_pep_508 = None
#
dep_name = dependency['name']
dep_version = dependency['version']
#
dep_pep_508 = f'{dep_name}=={dep_version}'
dep_source = dependency.get('source', None)
if dep_source:
if dep_source['type'] == 'url':
dep_url = dep_source['url']
dep_pep_508 = f'{dep_name} @ {dep_url}'
else:
dep_pep_508 = f'{dep_name}=={dep_version}'
#
if dep_pep_508:
dep_config = tox.config.DepConfig(dep_pep_508)
else:
raise UnsupportedLockedDependency(dependency)
#
dep_category = dependency['category']
dep_config = tox.config.DepConfig(dep_pep_508)
locked_deps.setdefault(dep_category, []).append(dep_config)
#
return locked_deps
Expand Down

0 comments on commit 3a720f0

Please sign in to comment.