diff --git a/.github/workflows/dev-ci.yml b/.github/workflows/dev-ci.yml index 93f8171afa..7e93c761a6 100644 --- a/.github/workflows/dev-ci.yml +++ b/.github/workflows/dev-ci.yml @@ -12,6 +12,8 @@ jobs: name: Build linux ${{ matrix.python.name }} wheel runs-on: ubuntu-latest container: quay.io/pypa/manylinux2014_x86_64:2024-07-01-8dac23b + env: + ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true strategy: matrix: python: diff --git a/.github/workflows/full-ci.yml b/.github/workflows/full-ci.yml index 9ec3102b48..ad2f634013 100644 --- a/.github/workflows/full-ci.yml +++ b/.github/workflows/full-ci.yml @@ -12,6 +12,8 @@ jobs: name: Build linux ${{ matrix.python.name }} wheel runs-on: ubuntu-latest container: quay.io/pypa/manylinux2014_x86_64:2024-07-01-8dac23b + env: + ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true strategy: matrix: python: diff --git a/cpp/powsybl-cpp/CMakeLists.txt b/cpp/powsybl-cpp/CMakeLists.txt index 112c678400..e55aaf7f71 100644 --- a/cpp/powsybl-cpp/CMakeLists.txt +++ b/cpp/powsybl-cpp/CMakeLists.txt @@ -7,6 +7,12 @@ cmake_minimum_required(VERSION 3.14) project(powsybl-cpp) +# Enable static linkage to prevent any future runtime binary compatibility issue +if(MSVC) + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") +endif() + include(ExternalProject) set(POWSYBL_CPP_LIB ${CMAKE_SHARED_LIBRARY_PREFIX}powsybl-cpp${CMAKE_SHARED_LIBRARY_SUFFIX}) @@ -95,4 +101,11 @@ if(DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY) add_custom_command(TARGET powsybl-cpp POST_BUILD ${POWSYBL_CPP_INSTALL_EXTRA_COMMAND} COMMAND ${CMAKE_COMMAND} -E copy $ ${PYPOWSYBL_JAVA_BIN_DIR}/${PYPOWSYBL_JAVA_LIB} ${CMAKE_CURRENT_BINARY_DIR}/${POWSYBL_MATH_NATIVE_JAR_ENTRY_DIR}/${POWSYBL_MATH_NATIVE_LIB} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) endif(DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY) +# Fix related to issue describred here https://github.com/actions/runner-images/issues/10004#issuecomment-2156109231 +# Should fix incompatibility between MSVC runtime 14.40.XXX and previous version +if(MSVC) + target_compile_definitions(powsybl-cpp + PRIVATE _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR) +endif() + target_link_libraries(powsybl-cpp PUBLIC ${PYPOWSYBL_JAVA_LIB}) diff --git a/cpp/pypowsybl-cpp/CMakeLists.txt b/cpp/pypowsybl-cpp/CMakeLists.txt index 3d2980d683..57081648a7 100644 --- a/cpp/pypowsybl-cpp/CMakeLists.txt +++ b/cpp/pypowsybl-cpp/CMakeLists.txt @@ -7,6 +7,12 @@ cmake_minimum_required(VERSION 3.14) project(pypowsybl-cpp) +# Enable static linkage to prevent any future runtime binary compatibility issue +if(MSVC) + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") +endif() + set(POWSYBL_CPP_SOURCE_DIR "../powsybl-cpp") set(PYPOWSYBL_JAVA_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}/../java) include_directories(${POWSYBL_CPP_SOURCE_DIR} ${PYPOWSYBL_JAVA_BIN_DIR}) @@ -16,4 +22,12 @@ pybind11_add_module(_pypowsybl pylogging.cpp bindings.cpp) add_dependencies(_pypowsybl native-image math-native) add_dependencies(math-native native-image) # because mvn command also copy math native jar + +# Fix related to issue describred here https://github.com/actions/runner-images/issues/10004#issuecomment-2156109231 +# Should fix incompatibility between MSVC runtime 14.40.XXX and previous version +if(MSVC) + target_compile_definitions(_pypowsybl + PRIVATE _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR) +endif() + target_link_libraries(_pypowsybl PRIVATE powsybl-cpp) diff --git a/java/src/main/java/com/powsybl/python/commons/CTypeUtil.java b/java/src/main/java/com/powsybl/python/commons/CTypeUtil.java index b415cfc3ff..d55fb3707a 100644 --- a/java/src/main/java/com/powsybl/python/commons/CTypeUtil.java +++ b/java/src/main/java/com/powsybl/python/commons/CTypeUtil.java @@ -75,7 +75,7 @@ public static String toStringOrNull(CCharPointer charPtr) { public static String[][] toString2DArray(CCharPointerPointer charPtrPtr, int length, int rows) { int cols = length / rows; - String[][] string2DArray = new String[rows][length / cols]; + String[][] string2DArray = new String[rows][cols]; int index = 0; for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { diff --git a/pypowsybl/network/impl/network.py b/pypowsybl/network/impl/network.py index 5ea817bbc5..f8a20914b9 100644 --- a/pypowsybl/network/impl/network.py +++ b/pypowsybl/network/impl/network.py @@ -1776,8 +1776,8 @@ def get_hvdc_lines(self, all_attributes: bool = False, attributes: List[str] = N Notes: The resulting dataframe, depending on the parameters, will include the following columns: - - **converters_mode**: - - **target_p**: (in MW) + - **converters_mode**: the mode of the converter stations. It can be either SIDE_1_RECTIFIER_SIDE_2_INVERTER or SIDE_1_INVERTER_SIDE_2_RECTIFIER + - **target_p**: active power target (in MW) - **max_p**: the maximum of active power that can pass through the hvdc line (in MW) - **nominal_v**: nominal voltage (in kV) - **r**: the resistance of the hvdc line (in Ohm) diff --git a/pypowsybl/voltage_initializer/impl/voltage_initializer.py b/pypowsybl/voltage_initializer/impl/voltage_initializer.py index 54fd4ecaef..9f72126ca7 100644 --- a/pypowsybl/voltage_initializer/impl/voltage_initializer.py +++ b/pypowsybl/voltage_initializer/impl/voltage_initializer.py @@ -10,7 +10,7 @@ from .voltage_initializer_results import VoltageInitializerResults -def run(network: Network, params: VoltageInitializerParameters = VoltageInitializerParameters(), debug: bool = False) \ +def run(network: Network, params: VoltageInitializerParameters, debug: bool = False) \ -> VoltageInitializerResults: """ Run voltage initializer on the network with the given params. @@ -20,5 +20,7 @@ def run(network: Network, params: VoltageInitializerParameters = VoltageInitiali params: The parameters used to customize the run debug: if true, the tmp directory of the voltage initializer run will not be erased. """ + if params is None: + params = VoltageInitializerParameters() result_handle = run_voltage_initializer(debug, network._handle, params._handle) return VoltageInitializerResults(result_handle) diff --git a/requirements.txt b/requirements.txt index 03b77b341c..d4575435b8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,8 @@ pandas==2.2.2; python_version >= "3.9" pandas==2.0.3; python_version <= "3.8" prettytable==2.0.0 networkx -matplotlib +matplotlib==3.9.0; python_version >= "3.9" +matplotlib; python_version <= "3.8" # documentation dependencies sphinx==7.1.2 diff --git a/tests/test_network.py b/tests/test_network.py index 824e3859ff..1dba0a8919 100644 --- a/tests/test_network.py +++ b/tests/test_network.py @@ -848,6 +848,14 @@ def test_sld_svg(): assert re.search('.* 0 + sld_multi_substation3 = n.get_matrix_multi_substation_single_line_diagram([['S1'],['S2']]) + assert re.search('.* 0 + + sld_multi_substation4 = n.get_matrix_multi_substation_single_line_diagram([['S1', 'S2']]) + assert re.search('.* 0 + def test_sld_svg_backward_compatibility(): n = pp.network.create_four_substations_node_breaker_network() sld = n.get_single_line_diagram('S1VL1', LayoutParameters(use_name=True, center_name=True, diagonal_label=True,