o
    tBhx                     @   s\   d Z ddlZddlZddlZddlZddlZddlmZmZ ddl	m
Z
 dd Zdd	 ZdS )
z,Helpers for OpenMP support during the build.    N)CompileError	LinkError   )compile_test_programc                 C   s   t | dr| jd } n| jj} tjdkrd| v sd| v rdgS tjdkr'dgS tjdv r3d| v r3d	gS tjd
krBdtddv rBg S dgS )Ncompilerr   win32icciclz/Qopenmpz/openmp)darwinlinuxz-qopenmpr
   openmpCPPFLAGS z-fopenmp)hasattrr   	__class____name__sysplatformosgetenv)r    r   z/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/sklearn/_build_utils/openmp_helpers.pyget_openmp_flag   s   

r   c               
   C   s   dt jv rdS td} t dd}|dur$| d}dd |D }t}z/t| ||d	}|rJd
|d v rJt	|d  dd }t
||k}n
dt jv rRd}nd}W n tttjfyd   d}Y nw |szt drptdtd}t| |S )z6Check whether OpenMP test code can be compiled and runPYODIDE_PACKAGE_ABIFz        #include <omp.h>
        #include <stdio.h>
        int main(void) {
        #pragma omp parallel
        printf("nthreads=%d\n", omp_get_num_threads());
        return 0;
        }
        LDFLAGSN c                 S   s   g | ]	}| d r|qS ))z-Lz
-Wl,-rpathz-lz-Wl,--sysroot=/)
startswith).0flagr   r   r   
<listcomp>F   s    z(check_openmp_support.<locals>.<listcomp>)extra_preargsextra_postargsz	nthreads=r   =r   PYTHON_CROSSENVTSKLEARN_FAIL_NO_OPENMPzFailed to build with OpenMPas  

                                ***********
                                * WARNING *
                                ***********

                It seems that scikit-learn cannot be built with OpenMP.

                - Make sure you have followed the installation instructions:

                    https://scikit-learn.org/dev/developers/advanced_installation.html

                - If your compiler supports OpenMP but you still see this
                  message, please submit a bug report at:

                    https://github.com/scikit-learn/scikit-learn/issues

                - The build will continue with OpenMP-based parallelism
                  disabled. Note however that some estimators will run in
                  sequential mode instead of leveraging thread-based
                  parallelism.

                                    ***
                )r   environtextwrapdedentr   stripsplitr   r   intlenr   r   
subprocessCalledProcessErrorwarningswarn)coder    r!   outputnthreadsopenmp_supportedmessager   r   r   check_openmp_support/   sD   



r5   )__doc__r   r   r&   r.   r,   distutils.errorsr   r   pre_build_helpersr   r   r5   r   r   r   r   <module>   s    