Skip to content

Commit

Permalink
fix(get deps): avoid failure if the dependency version is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
mostaphaRoudsari committed Sep 12, 2023
1 parent efd81f3 commit 64623da
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
18 changes: 13 additions & 5 deletions pollination_dsl/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,19 @@ def get_requirement_version(package_name, dependency_name):
package_data = importlib_metadata.metadata(package_name)
req_dists = package_data.get_all('Requires-Dist') or []
for package in req_dists:
name, version = package.split(' (')
version = \
version.replace('=', '').replace('>', '').replace('<', '') \
.replace(')', '').strip()
requirements[name] = version
try:
name, version = package.split(' (')
except ValueError as e:
print(
f'Failed to parse the dependency version for {name} from {package}. '
f'The version will not be set:\n{str(e)}'
)
requirements[name] = ''
else:
version = \
version.replace('=', '').replace('>', '').replace('<', '') \
.replace(')', '').strip()
requirements[name] = version
else:
for package in pkg_resources.parse_requirements(req):
version = \
Expand Down
3 changes: 2 additions & 1 deletion pollination_dsl/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ def load(package_name: str, baked: bool = False) -> Union[Plugin, BakedRecipe, R
f'of the currently installed version: {name}:{dep.tag}'
)
else:
dep.tag = tag
if tag:
dep.tag = tag

# tag might return additional information for extra dependencies
# here is an example: "0.1.11 ; extra 'viz'"
Expand Down

0 comments on commit 64623da

Please sign in to comment.