forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from ynimmaga/ynimmaga/master_changes
Merging changes from latest master
- Loading branch information
Showing
2,020 changed files
with
65,667 additions
and
29,089 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import pkg_resources | ||
import re | ||
import os | ||
|
||
|
||
def check_python_requirements(requirements_path: str) -> None: | ||
""" | ||
Checks if the requirements defined in `requirements_path` are installed | ||
in the active Python environment, while also taking constraints.txt files | ||
into account. | ||
""" | ||
|
||
constraints = {} | ||
constraints_path = None | ||
requirements = [] | ||
|
||
# read requirements and find constraints file | ||
with open(requirements_path) as f: | ||
raw_requirements = f.readlines() | ||
for line in raw_requirements: | ||
if line.startswith("-c"): | ||
constraints_path = os.path.join(os.path.dirname(requirements_path), line.split(' ')[1][:-1]) | ||
|
||
# read constraints if they exist | ||
if constraints_path: | ||
with open(constraints_path) as f: | ||
raw_constraints = f.readlines() | ||
for line in raw_constraints: | ||
if line.startswith("#") or line=="\n": | ||
continue | ||
line = line.replace("\n", "") | ||
package, delimiter, constraint = re.split("(~|=|<|>|;)", line, maxsplit=1) | ||
if constraints.get(package) is None: | ||
constraints[package] = [delimiter + constraint] | ||
else: | ||
constraints[package].extend([delimiter + constraint]) | ||
for line in raw_requirements: | ||
if line.startswith(("#", "-c")): | ||
continue | ||
line = line.replace("\n", "") | ||
if re.search("\W", line): | ||
requirements.append(line) | ||
else: | ||
constraint = constraints.get(line) | ||
if constraint: | ||
for marker in constraint: | ||
requirements.append(line+marker) | ||
else: | ||
requirements.append(line) | ||
else: | ||
requirements = raw_requirements | ||
pkg_resources.require(requirements) |
Oops, something went wrong.