Skip to content

Commit

Permalink
Fix python documentation warnings and format (#121)
Browse files Browse the repository at this point in the history
* Fix python documentation warnings and format

* Fix build when not using GStreamer

* Pin Sphinx theme dependencies versions to remove pip install warnings on Ubuntu 20.04

* Bump version

* Increase the abs error for the audio stream tests.

* Added visibility flag for OSX -fvisibility=hidden

---------

Co-authored-by: Marc-Antoine Maheux <Marc-Antoine.Maheux@USherbrooke.ca>
Co-authored-by: Dominic Létourneau <doumdi@gmail.com>
  • Loading branch information
3 people authored May 30, 2023
1 parent eae1743 commit f1d60ac
Show file tree
Hide file tree
Showing 23 changed files with 127 additions and 84 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ set(
"3"
CACHE STRING
"Specific Python version to use"
FORCE
)

find_package(Python ${OPENTERA_WEBRTC_NATIVE_CLIENT_PYTHON_VERSION} EXACT COMPONENTS Interpreter Development REQUIRED)
Expand Down Expand Up @@ -114,6 +113,7 @@ elseif (UNIX)
set(CMAKE_CXX_FLAGS "-fPIC")
add_compile_definitions(WEBRTC_POSIX)
if (APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
add_compile_definitions(WEBRTC_MAC)
endif(APPLE)
else()
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.6.0
0.6.1
20 changes: 17 additions & 3 deletions cmake/pip_utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ function(pip_configure_subpackage_file in_file out_file)
set(PIP_CONFIGURE_OUTPUT_FILES ${PIP_CONFIGURE_OUTPUT_FILES} PARENT_SCOPE)
endfunction()

function(add_dummy_target)
set(options)
set(oneValueArgs NAME)
set(multiValueArgs)
cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

add_custom_target(
${ARGS_NAME}-target
ALL
VERBATIM
)
set(${ARGS_NAME} ${ARGS_NAME}-target PARENT_SCOPE)
endfunction()

function(pip_add_requirements_target)
set(options)
set(oneValueArgs NAME REQUIREMENTS_FILE)
Expand All @@ -75,14 +89,14 @@ endfunction()

function(pip_add_so_target)
set(options)
set(oneValueArgs NAME SO_NAME)
set(oneValueArgs NAME SO_TARGET_NAME)
set(multiValueArgs DEPENDS)
cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

add_custom_command(
OUTPUT ${WORKING_DIR}/${ARGS_NAME}.stamp
DEPENDS ${ARGS_SO_NAME} ${ARGS_DEPENDS}
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${ARGS_SO_NAME}> ${PYTHON_PACKAGE_CONTENT_DIR}/$<TARGET_FILE_NAME:${ARGS_SO_NAME}>
DEPENDS ${ARGS_SO_TARGET_NAME} ${ARGS_DEPENDS}
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${ARGS_SO_TARGET_NAME}> ${PYTHON_PACKAGE_CONTENT_DIR}/$<TARGET_FILE_NAME:${ARGS_SO_TARGET_NAME}>
COMMAND ${CMAKE_COMMAND} -E touch ${WORKING_DIR}/${ARGS_NAME}.stamp
WORKING_DIRECTORY ${PYTHON_PACKAGE_DIR}
VERBATIM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ set(USE_EXACT_LIB_SUBPATH ${OPENTERA_WEBRTC_NATIVE_CLIENT_PYTHON_PIP_PREFIX_USE_
set(USE_EXACT_LIB_SUBPATH_SOURCE ${OPENTERA_WEBRTC_NATIVE_CLIENT_PYTHON_PIP_PREFIX_USE_EXACT_LIB_SUBPATH_SOURCE})
set(ENABLE_HTML_DOC ${OPENTERA_WEBRTC_ENABLE_PYTHON_HTML_DOC})
set(ENABLE_SO_STUB ${OPENTERA_WEBRTC_ENABLE_PYTHON_SO_STUB})
set(ENABLE_GSTREAMER ${OPENTERA_WEBRTC_ENABLE_GSTREAMER})
set(PYTHON_HTML_IGNORE_PREFIXES ${PIP_DEVEL_PREFIX} ${PIP_INSTALL_PREFIX})
set(PIP_PYTHON_EXECUTABLE ${PYTHON3_EXECUTABLE})

Expand All @@ -30,13 +31,14 @@ include(../../../../cmake/pip_utils.cmake)
set(LICENSE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../../../../LICENSE)
set(REQUIREMENTS_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../../../../requirements.txt)

# Set the variable for the target file name of OpenteraWebrtcNativeGStreamer
if (OPENTERA_WEBRTC_ENABLE_GSTREAMER)
pip_configure_setup(setup_gstreamer.py.in)
if (ENABLE_GSTREAMER)
set(GSTREAMER_TARGET_FILE_NAME "$<TARGET_FILE_NAME:OpenteraWebrtcNativeGStreamer>")
else()
pip_configure_setup(setup.py.in)
set(GSTREAMER_TARGET_FILE_NAME "")
endif()

pip_configure_setup(setup.py.in)

pip_configure_package_file(${LICENSE_FILE} LICENSE)
pip_configure_package_file(${CMAKE_CURRENT_SOURCE_DIR}/README.md.in README.md)
pip_configure_package_file(${CMAKE_CURRENT_SOURCE_DIR}/MANIFEST.in.in MANIFEST.in)
Expand All @@ -49,9 +51,11 @@ pip_configure_doc_file(${CMAKE_CURRENT_SOURCE_DIR}/_source/index.rst index.rst)
pip_configure_doc_file(${CMAKE_CURRENT_SOURCE_DIR}/_source/theme/requirements.txt theme/requirements.txt)
pip_configure_doc_file(${CMAKE_CURRENT_SOURCE_DIR}/post-process-doc.sh ../post-process-doc.sh)

pip_add_so_target(NAME ${PYTHON_LIB_NAME}-so SO_NAME ${PYTHON_LIB_NAME})
if (OPENTERA_WEBRTC_ENABLE_GSTREAMER)
pip_add_so_target(NAME OpenteraWebrtcNativeGStreamer-so SO_NAME OpenteraWebrtcNativeGStreamer)
pip_add_so_target(NAME ${PYTHON_LIB_NAME}-so SO_TARGET_NAME ${PYTHON_LIB_NAME})
if (ENABLE_GSTREAMER)
pip_add_so_target(NAME OpenteraWebrtcNativeGStreamer-so SO_TARGET_NAME OpenteraWebrtcNativeGStreamer)
else()
add_dummy_target(NAME OpenteraWebrtcNativeGStreamer-so)
endif()

pip_add_requirements_target(NAME ${PYTHON_SUBPACKAGE_NAME}-requirements REQUIREMENTS_FILE ${REQUIREMENTS_FILE})
Expand All @@ -78,6 +82,7 @@ pip_add_dist_target(
DEPENDS
${${PYTHON_SUBPACKAGE_NAME}-html}
${${PYTHON_SUBPACKAGE_NAME}-requirements}
${OpenteraWebrtcNativeGStreamer-so}
)
pip_add_install_target(
NAME ${PYTHON_SUBPACKAGE_NAME}-install
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ templates_path = ['_templates']
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'setup.py', 'theme']

autosummary_mock_imports = [
'opentera_webrtc.native_client.libOpenteraWebrtcNativeGStreamer',
]

# -- Options for HTML output -------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
sphinx-rtd-theme==1.1.1
charset-normalizer<3.0,>=2.0
sphinx==5.3.0
urllib3<2.0
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ find . -type f -name '*.html' | xargs sed -i.bak 's/opentera_webrtc\.native_clie

# Remove _opentera_webrtc_native_client
find . -type f -name '*.html' | xargs sed -i.bak 's/opentera_webrtc\.native_client\._opentera_webrtc_native_client/opentera_webrtc.native_client/g' && find . -type f -name '*.html.bak' | xargs rm

# Fix opentera:: prefix
find . -type f -name '*.html' | xargs sed -i.bak 's/opentera:://g' && find . -type f -name '*.html.bak' | xargs rm
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env sh
sed -i.bak 's/_opentera_webrtc_native_client\.//g' $1 && rm $1.bak
sed -i.bak 's/opentera::IceServer/IceServer/g' $1 && rm $1.bak
sed -i.bak 's/opentera:://g' $1 && rm $1.bak
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def get_doc_files():
files = {}
for root, _, filenames in os.walk('_doc'):
for filename in filenames:
rootless = root.replace('_doc', os.path.join('doc', 'opentera', 'webrtc', 'native_client'))
rootless = root.replace('_doc', os.path.join('doc', 'opentera_webrtc', 'native_client'))
if not rootless in files.keys():
files[rootless] = []
files[rootless].append(os.path.join(root, filename))
Expand Down Expand Up @@ -50,6 +50,7 @@ setup(
package_data={
'opentera_webrtc.native_client': [
"$<TARGET_FILE_NAME:${PYTHON_LIB_NAME}>",
$<IF:$<BOOL:${ENABLE_GSTREAMER}>,"${GSTREAMER_TARGET_FILE_NAME}"$<COMMA>,>
$<IF:$<BOOL:${ENABLE_SO_STUB}>,"opentera_webrtc/native_client/py.typed"$<COMMA>,>
$<IF:$<BOOL:${ENABLE_SO_STUB}>,"opentera_webrtc/native_client/__init__.pyi"$<COMMA>,>
],
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ void opentera::initAudioSourceConfigurationPython(py::module& m)
"create",
py::overload_cast<uint32_t>(&AudioSourceConfiguration::create),
"Creates an audio source configuration with default values.\n"
"\n"
":param sound_card_total_delay_ms: The sum of the playback and "
"recording delays\n"
"\n"
":return: An audio source configuration with default values",
py::arg("sound_card_total_delay_ms"))
.def_static(
Expand All @@ -43,6 +45,7 @@ void opentera::initAudioSourceConfigurationPython(py::module& m)
":param stereo_swapping: Enable or disable the stereo swapping\n"
":param transient_suppression: Enable or disable the transient "
"suppression\n"
"\n"
":return: An audio source configuration with the specified values",
py::arg("sound_card_total_delay_ms"),
py::arg("echo_cancellation"),
Expand All @@ -56,35 +59,42 @@ void opentera::initAudioSourceConfigurationPython(py::module& m)
"sound_card_total_delay_ms",
&AudioSourceConfiguration::soundCardTotalDelayMs,
"Returns the sum of the playback and recording delays.\n"
"\n"
":return: The sum of the playback and recording delays")
.def_property_readonly(
"echo_cancellation",
&AudioSourceConfiguration::echoCancellation,
"Indicates if the echo cancellation is enabled.\n"
"\n"
":return: True if the echo cancellation is enabled")
.def_property_readonly(
"auto_gain_control",
&AudioSourceConfiguration::autoGainControl,
"Indicates if the auto gain control is enabled.\n"
"\n"
":return: True if the auto gain control is enabled")
.def_property_readonly(
"noise_suppression",
&AudioSourceConfiguration::noiseSuppression,
"Indicates if the noise suppression is enabled.\n"
"\n"
":return: True if the noise suppression is enabled")
.def_property_readonly(
"highpass_filter",
&AudioSourceConfiguration::highpassFilter,
"Indicates if the highpass filter is enabled.\n"
"\n"
":return: True if the highpass filter is enabled")
.def_property_readonly(
"stereo_swapping",
&AudioSourceConfiguration::stereoSwapping,
"Indicates if the stereo swapping is enabled.\n"
"\n"
":return: true if the stereo swapping is enabled")
.def_property_readonly(
"transient_suppression",
&AudioSourceConfiguration::transientSuppression,
"Indicates if the transient suppression is enabled.\n"
"\n"
":return: True if the transient suppression is enabled");
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ void opentera::initDataChannelConfigurationPython(py::module& m)
"create",
py::overload_cast<>(&DataChannelConfiguration::create),
"Creates a data channel configuration with default values.\n"
"\n"
":return: A data channel configuration with default values")
.def_static(
"create",
Expand All @@ -22,6 +23,7 @@ void opentera::initDataChannelConfigurationPython(py::module& m)
"Creates a data channel configuration with the specified value.\n"
"\n"
":param ordered: Indicates if the message order must be preserved\n"
"\n"
":return: A data channel configuration with the specified value")
.def_static(
"create_protocol",
Expand All @@ -30,6 +32,7 @@ void opentera::initDataChannelConfigurationPython(py::module& m)
"Creates a data channel configuration with the specified value.\n"
"\n"
":param protocol: The data channel protocol\n"
"\n"
":return: A data channel configuration with the specified value")
.def_static(
"create",
Expand All @@ -38,6 +41,7 @@ void opentera::initDataChannelConfigurationPython(py::module& m)
"\n"
":param ordered: Indicates if the message order must be preserved\n"
":param protocol: The data channel protocol\n"
"\n"
":return: A data channel configuration with the specified values",
py::arg("ordered"),
py::arg("protocol"))
Expand All @@ -49,6 +53,7 @@ void opentera::initDataChannelConfigurationPython(py::module& m)
"\n"
":param max_packet_life_time: Indicates the amount of time a message "
"can be retransmitted (ms)\n"
"\n"
":return: A data channel configuration with the specified value",
py::arg("max_packet_life_time"))
.def_static(
Expand All @@ -59,6 +64,7 @@ void opentera::initDataChannelConfigurationPython(py::module& m)
":param ordered: Indicates if the message order must be preserved\n"
":param max_packet_life_time: Indicates the amount of time a message "
"can be retransmitted (ms)\n"
"\n"
":return: A data channel configuration with the specified values",
py::arg("ordered"),
py::arg("max_packet_life_time"))
Expand All @@ -70,6 +76,7 @@ void opentera::initDataChannelConfigurationPython(py::module& m)
":param max_packet_life_time: Indicates the amount of time a message "
"can be retransmitted (ms)\n"
":param protocol: The data channel protocol\n"
"\n"
":return: A data channel configuration with the specified values",
py::arg("max_packet_life_time"),
py::arg("protocol"))
Expand All @@ -82,6 +89,7 @@ void opentera::initDataChannelConfigurationPython(py::module& m)
":param max_packet_life_time: Indicates the amount of time a message "
"can be retransmitted (ms)\n"
":param protocol: The data channel protocol\n"
"\n"
":return: A data channel configuration with the specified values",
py::arg("ordered"),
py::arg("max_packet_life_time"),
Expand All @@ -94,6 +102,7 @@ void opentera::initDataChannelConfigurationPython(py::module& m)
"\n"
":param max_retransmits: Indicates the maximum number of time a "
"message can be retransmitted\n"
"\n"
":return: A data channel configuration with the specified value",
py::arg("max_retransmits"))
.def_static(
Expand All @@ -104,6 +113,7 @@ void opentera::initDataChannelConfigurationPython(py::module& m)
":param ordered: Indicates if the message order must be preserved\n"
":param max_retransmits: Indicates the maximum number of time a "
"message can be retransmitted\n"
"\n"
":return: A data channel configuration with the specified values",
py::arg("ordered"),
py::arg("max_retransmits"))
Expand All @@ -115,6 +125,7 @@ void opentera::initDataChannelConfigurationPython(py::module& m)
":param max_retransmits: Indicates the maximum number of time a "
"message can be retransmitted\n"
":param protocol: The data channel protocol\n"
"\n"
":return: A data channel configuration with the specified values",
py::arg("max_retransmits"),
py::arg("protocol"))
Expand All @@ -127,6 +138,7 @@ void opentera::initDataChannelConfigurationPython(py::module& m)
":param max_retransmits: Indicates the maximum number of time a "
"message can be retransmitted\n"
":param protocol: The data channel protocol\n"
"\n"
":return: A data channel configuration with the specified values",
py::arg("ordered"),
py::arg("max_retransmits"),
Expand All @@ -136,20 +148,24 @@ void opentera::initDataChannelConfigurationPython(py::module& m)
"ordered",
&DataChannelConfiguration::ordered,
"Indicates if the message order must be preserved.\n"
"\n"
":return: True if the message order must be preserved")
.def_property_readonly(
"max_packet_life_time",
&DataChannelConfiguration::maxPacketLifeTime,
"Returns the maximum number of time a message can be retransmitted.\n"
"\n"
":return: The maximum number of time a message can be retransmitted")
.def_property_readonly(
"max_retransmits",
&DataChannelConfiguration::maxRetransmits,
"Returns the maximum number of time a message can be retransmitted.\n"
"\n"
":return: The maximum number of time a message can be retransmitted")
.def_property_readonly(
"protocol",
&DataChannelConfiguration::protocol,
"Returns the data channel protocol.\n"
"\n"
":return: The data channel protocol");
}
Loading

0 comments on commit f1d60ac

Please sign in to comment.