[DOCS] OpenVINO Python API docs build fix (#24952)
### Details: - *item1* - *...* ### Tickets: - *ticket-id*
This commit is contained in:
parent
4e6ee7f15e
commit
0908908227
|
|
@ -33,6 +33,7 @@ function(build_docs)
|
||||||
set(DOXYGEN_MAPPING_SCRIPT "${SCRIPTS_DIR}/create_mapping.py")
|
set(DOXYGEN_MAPPING_SCRIPT "${SCRIPTS_DIR}/create_mapping.py")
|
||||||
set(DOCS_MAPPING_SCRIPT "${SCRIPTS_DIR}/create_doc_mapping.py")
|
set(DOCS_MAPPING_SCRIPT "${SCRIPTS_DIR}/create_doc_mapping.py")
|
||||||
set(BREATHE_APIDOC_SCRIPT "${SCRIPTS_DIR}/apidoc.py")
|
set(BREATHE_APIDOC_SCRIPT "${SCRIPTS_DIR}/apidoc.py")
|
||||||
|
set(OV_INSTALLATION_SCRIPT "${SCRIPTS_DIR}/install_appropriate_openvino_version.py")
|
||||||
|
|
||||||
# Doxygen/Sphinx setup
|
# Doxygen/Sphinx setup
|
||||||
set(DOXYGEN_XML_OUTPUT "${DOCS_BUILD_DIR}/xml")
|
set(DOXYGEN_XML_OUTPUT "${DOCS_BUILD_DIR}/xml")
|
||||||
|
|
@ -62,7 +63,9 @@ function(build_docs)
|
||||||
|
|
||||||
if(${ENABLE_PYTHON_API})
|
if(${ENABLE_PYTHON_API})
|
||||||
list(APPEND commands COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --green "STARTED preprocessing OpenVINO Python API")
|
list(APPEND commands COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --green "STARTED preprocessing OpenVINO Python API")
|
||||||
list(APPEND commands COMMAND ${Python3_EXECUTABLE} -m pip install openvino)
|
list(APPEND commands COMMAND ${Python3_EXECUTABLE} ${OV_INSTALLATION_SCRIPT}
|
||||||
|
--ov_dir=${SPHINX_SETUP_DIR}
|
||||||
|
--python=${Python3_EXECUTABLE})
|
||||||
list(APPEND commands COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --green "FINISHED preprocessing OpenVINO Python API")
|
list(APPEND commands COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --green "FINISHED preprocessing OpenVINO Python API")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
{{ fullname | escape | underline}}
|
||||||
|
|
||||||
|
.. currentmodule:: {{ module }}
|
||||||
|
|
||||||
|
.. autoclass:: {{ objname }}
|
||||||
|
:members:
|
||||||
|
:show-inheritance:
|
||||||
|
:inherited-members:
|
||||||
|
|
||||||
|
{% block methods %}
|
||||||
|
.. automethod:: __init__
|
||||||
|
|
||||||
|
{% if methods %}
|
||||||
|
.. rubric:: Methods
|
||||||
|
|
||||||
|
.. autosummary::
|
||||||
|
{% for met in methods %}
|
||||||
|
~{{ name }}.{{ met }}
|
||||||
|
{%- endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block attributes %}
|
||||||
|
{% if attributes %}
|
||||||
|
.. rubric:: Attributes
|
||||||
|
|
||||||
|
.. autosummary::
|
||||||
|
{% for att in attributes %}
|
||||||
|
~{{ name }}.{{ att }}
|
||||||
|
{%- endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
{{ fullname | escape | underline}}
|
||||||
|
|
||||||
|
.. automodule:: {{ fullname }}
|
||||||
|
|
||||||
|
{% block attributes %}
|
||||||
|
{% if attributes %}
|
||||||
|
.. rubric:: Module Attributes
|
||||||
|
|
||||||
|
.. autosummary::
|
||||||
|
:toctree:
|
||||||
|
{% for attr in attributes %}
|
||||||
|
{{ attr }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block functions %}
|
||||||
|
{% if functions %}
|
||||||
|
.. rubric:: Functions
|
||||||
|
|
||||||
|
.. autosummary::
|
||||||
|
:toctree:
|
||||||
|
{% for func in functions %}
|
||||||
|
{% if not func.startswith('_') %}
|
||||||
|
{{ func }}
|
||||||
|
{% endif %}
|
||||||
|
{%- endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block classes %}
|
||||||
|
{% if classes %}
|
||||||
|
.. rubric:: Classes
|
||||||
|
|
||||||
|
.. autosummary::
|
||||||
|
:toctree:
|
||||||
|
:template: custom-class-template.rst
|
||||||
|
{% for cl in classes %}
|
||||||
|
{{ cl }}
|
||||||
|
{%- endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block exceptions %}
|
||||||
|
{% if exceptions %}
|
||||||
|
.. rubric:: Exceptions
|
||||||
|
|
||||||
|
.. autosummary::
|
||||||
|
:toctree:
|
||||||
|
{% for item in exceptions %}
|
||||||
|
{{ item }}
|
||||||
|
{%- endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block modules %}
|
||||||
|
{% if modules %}
|
||||||
|
.. rubric:: Modules
|
||||||
|
|
||||||
|
.. autosummary::
|
||||||
|
:toctree:
|
||||||
|
:template: custom-module-template.rst
|
||||||
|
:recursive:
|
||||||
|
{% for mod in modules %}
|
||||||
|
{{ mod }}
|
||||||
|
{%- endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
import re
|
||||||
|
import argparse
|
||||||
|
import subprocess
|
||||||
|
import requests
|
||||||
|
import pkg_resources
|
||||||
|
from packaging import version
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
def determine_openvino_version(file_path):
|
||||||
|
pattern = r"version_name\s*=\s*['\"]([^'\"]+)['\"]"
|
||||||
|
|
||||||
|
with open(file_path, 'r') as file:
|
||||||
|
content = file.read()
|
||||||
|
|
||||||
|
match = re.search(pattern, content)
|
||||||
|
|
||||||
|
if match:
|
||||||
|
return match.group(1)
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def get_latest_version(major_version):
|
||||||
|
url = f"https://pypi.org/pypi/openvino/json"
|
||||||
|
response = requests.get(url)
|
||||||
|
|
||||||
|
if response.status_code == 200:
|
||||||
|
data = response.json()
|
||||||
|
versions = data['releases'].keys()
|
||||||
|
|
||||||
|
# Filter versions by the major version prefix
|
||||||
|
matching_versions = [v for v in versions if v.startswith(major_version)]
|
||||||
|
|
||||||
|
# Sort the matching versions and return the latest one
|
||||||
|
if matching_versions:
|
||||||
|
matching_versions.sort(key=version.parse)
|
||||||
|
return matching_versions[-1]
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('--ov_dir', type=Path, help='OpenVINO docs directory')
|
||||||
|
parser.add_argument('--python', type=Path, help='Python executable')
|
||||||
|
args = parser.parse_args()
|
||||||
|
ov_dir = args.ov_dir
|
||||||
|
python_executable = args.python
|
||||||
|
version_name = determine_openvino_version(ov_dir.joinpath("conf.py"))
|
||||||
|
|
||||||
|
if version_name is None:
|
||||||
|
ov_version = "openvino"
|
||||||
|
elif version_name == "nightly":
|
||||||
|
ov_version = "openvino-nightly"
|
||||||
|
else:
|
||||||
|
latest_version = get_latest_version(version_name)
|
||||||
|
if latest_version:
|
||||||
|
ov_version = f"openvino=={latest_version}"
|
||||||
|
else:
|
||||||
|
ov_version = f"openvino=={version_name}"
|
||||||
|
subprocess.check_call([f'{python_executable}', '-m', 'pip', 'install', '-U', ov_version, '--no-cache-dir'])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Loading…
Reference in New Issue