Skip to content
This repository has been archived by the owner on Jan 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #294 from dephell/fix-convert-envs
Browse files Browse the repository at this point in the history
Apply envs in `deps convert`
  • Loading branch information
orsinium committed Nov 19, 2019
2 parents 5ffab4f + 5e4f48e commit 08c85d3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
12 changes: 12 additions & 0 deletions dephell/commands/deps_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@ def __call__(self) -> bool:
return False
self.logger.debug('resolved')

# filter out deps by `--envs`
if self.config.get('envs'):
if len(resolver.graph._layers) == 1:
for root in resolver.graph._roots:
for dep in root.dependencies:
dep.applied = True
resolver.graph.add(dep)
for root in resolver.graph._roots:
root.applied = True
resolver.apply_envs(set(self.config['envs']))
resolver.graph._layers = resolver.graph._layers[:1]

# dump
self.logger.debug('dump dependencies...', extra=dict(
format=self.config['to']['format'],
Expand Down
3 changes: 2 additions & 1 deletion dephell/controllers/_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def from_params(cls, *, raw_name: str, constraint,
link = url
if link and not isinstance(link, UnknownLink):
if link.name and rex_hash.fullmatch(raw_name):
raw_name = link.name
if not link.name.startswith(raw_name):
raw_name = link.name

# make constraint
if isinstance(constraint, str):
Expand Down
2 changes: 1 addition & 1 deletion dephell/controllers/_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def apply_envs(self, envs: set) -> None:

# Some child deps can be unapplied from other child deps, but we need them.
# For example, if we need A, but don't need B, and A and B depends on C,
# then C will be unapplied from B. Let's retun B in the graph by apllying A.
# then C will be unapplied from B. Let's return B in the graph by re-applying A.
for dep in self.graph:
if not dep.applied:
continue
Expand Down

0 comments on commit 08c85d3

Please sign in to comment.