[PyOV] Simplify requirement files (#15343)
* Partial progress * Finish v1 * Cleanup * Remove useless files * Fix path to pdpd * Fix onnx path * Minor change * Rework MO * Minor change * Remove some costraints * Add MO constraints * Update gitignore for MO * Minor change * Apply tech sync discussion * Cleanup * CR comment * Debug ONNX FE * simplify ONNX FE * Update cmake * Hardcode ONNX requirement * Add dependency resolver to cmake * Add constraints for openvino/tests * Add missing pytest-html * Fix -c path * Revert debug changes to path * Add cmake to copy constraints.txt * Update dependabot * Remove slash * Remove cmake * Debug prints * Minor changes * Move reqs check to separate file * Add requirements parser to benchmark_tool * Fix smoke tests constraints * Minor fixes * Minor change * My fixes were apparently wrong * Debug - self.executable_path * Debug - add singledispatch to tests and tools * Debug - print IE_APP_PATHs * Revert "Debug - print IE_APP_PATHs" This reverts commit67ccb6d3f5. * Revert "Debug - add singledispatch to tests and tools" This reverts commit3b945931e2. * Revert "Debug - self.executable_path" This reverts commit3aa724eff6. * update dependabot * update dependabot * Skip benchmark_app tests * Use CMAKE_CURRENT_BINARY_DIR in cmake * Remove debug prints * minor change --------- Signed-off-by: p-wysocki <przemyslaw.wysocki@intel.com>
This commit is contained in:
committed by
GitHub
parent
988a8dd6a9
commit
591c3e61c5
52
cmake/developer_package/check_python_requirements.py
Normal file
52
cmake/developer_package/check_python_requirements.py
Normal file
@@ -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)
|
||||
@@ -97,7 +97,11 @@ function(ov_check_pip_packages)
|
||||
|
||||
if(PYTHONINTERP_FOUND)
|
||||
execute_process(
|
||||
COMMAND ${PYTHON_EXECUTABLE} -c "import pkg_resources ; pkg_resources.require(open('${ARG_REQUIREMENTS_FILE}', mode='r'))"
|
||||
COMMAND ${PYTHON_EXECUTABLE} -c "
|
||||
from check_python_requirements import check_python_requirements ;
|
||||
check_python_requirements('${ARG_REQUIREMENTS_FILE}') ;
|
||||
"
|
||||
WORKING_DIRECTORY "${IEDevScripts_DIR}"
|
||||
RESULT_VARIABLE EXIT_CODE
|
||||
OUTPUT_VARIABLE OUTPUT_TEXT
|
||||
ERROR_VARIABLE ERROR_TEXT)
|
||||
|
||||
Reference in New Issue
Block a user