Files
openvino/tools/benchmark_tool/setup.py
T
Przemyslaw Wysocki 591c3e61c5 [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 commit 67ccb6d3f5.

* Revert "Debug - add singledispatch to tests and tools"

This reverts commit 3b945931e2.

* Revert "Debug - self.executable_path"

This reverts commit 3aa724eff6.

* 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>
2023-03-29 14:27:27 +04:00

107 lines
3.4 KiB
Python

#!/usr/bin/env python3
# Copyright (C) 2018-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""
Use this script to create a wheel with OpenVINO™ Python* tools:
$ python setup.py sdist bdist_wheel
"""
import pkg_resources
import re
from setuptools import setup, find_packages
from pathlib import Path
from typing import List
with open('README.md', 'r', encoding='utf-8') as f:
long_description = f.read()
def read_constraints(path: str='../constraints.txt') -> Dict[str, List[str]]:
"""
Read a constraints.txt file and return a dict
of {package_name: [required_version_1, required_version_2]}.
The dict values are a list because a package can be mentioned
multiple times, for example:
mxnet~=1.2.0; sys_platform == 'win32'
mxnet>=1.7.0; sys_platform != 'win32'
"""
constraints = {}
with open(Path(__file__).resolve().parent / path) as f:
raw_constraints = f.readlines()
for line in raw_constraints:
# skip comments
if line.startswith('#'):
continue
line = line.replace('\n', '')
# read constraints for that package
package, delimiter, constraint = re.split('(~|=|<|>|;)', line, maxsplit=1)
# if there is no entry for that package, add it
if constraints.get(package) is None:
constraints[package] = [delimiter + constraint]
# else add another entry for that package
else:
constraints[package].extend([delimiter + constraint])
return constraints
def read_requirements(path: str) -> List[str]:
"""
Read a requirements.txt file and return a list
of requirements. Three cases are supported, the
list corresponds to priority:
1. version specified in requirements.txt
2. version specified in constraints.txt
3. version unbound
"""
requirements = []
constraints = read_constraints()
with open(Path(__file__).resolve().parent / path) as f:
raw_requirements = f.readlines()
for line in raw_requirements:
# skip comments and constraints link
if line.startswith(('#', '-c')):
continue
# get rid of newlines
line = line.replace('\n', '')
# if version is specified (non-word chars present)
if re.search('\W', line):
requirements.append(line)
# else get version from constraints
else:
constraint = constraints.get(line)
# if version found in constraints.txt
if constraint:
for marker in constraint:
requirements.append(line+marker)
# else version is unbound
else:
requirements.append(line)
return requirements
setup(
name='benchmark_tool',
version='0.0.0',
author='Intel® Corporation',
license='OSI Approved :: Apache Software License',
author_email='openvino_pushbot@intel.com',
url='https://github.com/openvinotoolkit/openvino',
description='OpenVINO™ Python* tools package',
long_description=long_description,
long_description_content_type='text/markdown',
entry_points={
'console_scripts': [
'benchmark_app = openvino.tools.benchmark.main:main'],
},
classifiers=[
'Programming Language :: Python :: 3',
'Operating System :: OS Independent',
],
packages=find_packages(),
install_requires=read_requirements('requirements.txt'),
python_requires='>=3.7',
)