
    .Ph]                     l   d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZm	Z	m
Z
mZmZmZmZ d dlmZmZmZ d dlmZmZmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlm Z  d dl!m"Z" d dl#m$Z$ d dl%m&Z& d dl'm(Z( d dl)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z: d dl;m<Z< d dl=m>Z>m?Z?m@Z@ d dlAmBZB d dlCmDZD d dlEmFZF erd dlmGZG g dZHdZI G d de:          ZJde	eKe(f         dee         fdZLdeKdefdZMdee	eKe(f                  de
eK         fd ZN e jO        d!e jP                  ZQd"eKdee	eKeKf                  fd#ZRd$eDjS        de0fd%ZTd&e@de3fd'ZU	 	 	 dCd)e
e/         d*eKd+e8d,e,d-ee
eF                  d.eVd/ee	eKeKf                  de
e@         fd0ZWd1e.deKfd2ZXd1e.d3eeK         de?fd4ZYddd5d(d(d6d7e	eKeDjS        f         d8e
eK         d9e	eKe@f         d:e	eKe@f         d;eKd*eKdee	eKe(f                  d-ee
eF                  d<eVd=eVd.eVd>eKde	eKe@f         fd?ZZ	 dDd<eVd-ee
eF                  de8fd@Z[dAeKdeKfdBZ\dS )E    N)Path)
expandvars)TYPE_CHECKINGDictListLiteralOptionalTuplecast)	urldefragurlsplit
urlunsplit)compatible_tagscpython_tagsmac_platforms)canonicalize_name)Version)	ArgvInput)IO)NullIO)	Verbosity)StreamOutput)HTTPRepository)HashableVirtualPackage)ChooserConfigEnvFactoryLink	OperationPoetryDependencyPoetryDirectoryDependencyPoetryFileDependencyPoetryPackagePoetryProjectPackagePoetrySolverPoetryURLDependencyPoetryVCSDependencyPoolPyPiRepository
VirtualEnv)apply_categories)DependencySource	HashModelLockedDependency)conda_name_to_pypi_name)	lock_spec)PipRepository)Tag)120102014_2_17_2_24_2_28)      c                       e Zd ZU dZed         ed<   ed         ed<   ed         ed<   ee         ed<   ee	e
d	f                  ed
<   ddddedeeeef                  dee         f fdZded         fdZdeeef         fdZ xZS )PlatformEnvzU
    Fake poetry Env to match PyPI distributions to the target conda environment
    )darwinlinuxwin32_sys_platform)DarwinLinuxWindows_platform_system)posixnt_os_name
_platforms._python_versionN)platform_virtual_packagespython_versionplatformrK   rL   c                   t                                          t          t          j                             |                    d          \  }dk    rd|dk    r+t          |          }fd|D             d gz   | _        nP|d	k    r(t          t          t                              | _        n"|d
k    r	dg| _        nt          d| d          |d | _        n:t          t          t          |                    d                              | _        |d	k    rd| _        d| _        d| _        d S |dk    rd| _        d| _        d| _        d S |dk    rd| _        d| _        d| _        d S t          d| d          )N)path-64x86_64r?   )rK   c                      g | ]
}d | d S )	manylinux_ ).0tagarchs     V/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/conda_lock/pypi_solver.py
<listcomp>z(PlatformEnv.__init__.<locals>.<listcomp>f   s7       -0(C(($((      linux_osxzwin-64	win_amd64zUnsupported platform ''.r>   rB   rF   rC   winr@   rD   rG   )super__init__r   sysprefixsplit"_compute_compatible_manylinux_tagsrI   listr   MACOS_VERSION
ValueErrorrJ   tuplemapintrA   rE   rH   )selfrM   rK   rL   systemcompatible_manylinux_tagsrY   	__class__s         @rZ   rd   zPlatformEnv.__init__T   s    	d3:..///~~c**4<<DW )K*C) ) )%   4M   $!"DOO u__"=#E#EFFDOO!!*mDOOAhAAABBB!#'D  #(S.2F2Fs2K2K)L)L#M#MD U??!)D$,D!#DMMMw!(D$+D!#DMMMu__!(D$-D! DMMMAhAAABBBr\   returnr3   c                     t          t          | j        | j                            t          t	          | j        | j                            z   S )zU
        Mimic the output of packaging.tags.sys_tags() on the given platform
        )rL   	platforms)ri   r   rJ   rI   r   )ro   s    rZ   get_supported_tagszPlatformEnv.get_supported_tags   sY     (<XXX
 
#3t  
 

 	
r\   c                     | j         | j        | j        d}| j        Vd                    d | j        D                       |d<   d                    d | j        dd         D                       |d<   |S )	z8Return the subset of info needed to match common markers)sys_platformplatform_systemos_nameNra   c                 ,    g | ]}t          |          S rV   strrW   cs     rZ   r[   z.PlatformEnv.get_marker_env.<locals>.<listcomp>   s    666AQ666r\   python_full_versionc                 ,    g | ]}t          |          S rV   r|   r~   s     rZ   r[   z.PlatformEnv.get_marker_env.<locals>.<listcomp>   s    :::AQ:::r\      rL   )rA   rE   rH   rJ   join)ro   results     rZ   get_marker_envzPlatformEnv.get_marker_env   s     !.#4}"
 "

 +,/HH66!5666- -F() (+xx::!5bqb!9:::( (F#$ r\   )__name__
__module____qualname____doc__r   __annotations__r   r}   r	   r
   rn   r   r   rd   rv   r   __classcell__)rr   s   @rZ   r=   r=   I   s=          56666:;;;;m$$$$S	eCHo.... RV(,-C -C -C -C $,D6L1L,M#N	-C
 !-C -C -C -C -C -C^

DK 

 

 

 

S#X        r\   r=   rK   rs   c                 T   g }|                                  D ]6}|d         dk    r(|                    t          |d                              7t          |          dk    rdS t          |          dk    r|d         S t	          |          }t          j        d|d| d	           |S )
a  Get the glibc version from the "package" repodata of a chosen platform.

    Note that the glibc version coming from a virtual package is never a legacy
    manylinux tag (i.e. 1, 2010, or 2014). Those tags predate PEP 600 which
    introduced manylinux tags containing the glibc version. Currently, all
    relevant glibc versions look like 2.XX.

    >>> platform_virtual_packages = {
    ...     "__glibc-2.17-0.tar.bz2": {
    ...         "name": "__glibc",
    ...         "version": "2.17",
    ...     },
    ... }
    >>> _extract_glibc_version_from_virtual_packages(platform_virtual_packages)
    <Version('2.17')>
    >>> _extract_glibc_version_from_virtual_packages({}) is None
    True
    name__glibcversionr   N   z8Multiple __glibc virtual package entries found! matches=z Using the lowest version ra   )valuesappendr   lenminwarningswarn)rK   matchesplowests       rZ   ,_extract_glibc_version_from_virtual_packagesr      s    *  G&--// 2 2V9	!!NN71Y<00111
7||qt	W		qzW== =39= = =	
 	
 	
 r\   rX   c                    t          d          t          d          t          d          d}| |v r||          S |                     d          r+t          | dd                             dd                    S t          d	|            )
z
    Return the glibc version for the given manylinux tag

    >>> _glibc_version_from_manylinux_tag("2010")
    <Version('2.12')>
    >>> _glibc_version_from_manylinux_tag("_2_28")
    <Version('2.28')>
    z2.5z2.12z2.17)r4   r5   r6   rU   r   Nra   zUnknown manylinux tag )r   
startswithreplacerk   )rX   SPECIAL_CASESs     rZ   !_glibc_version_from_manylinux_tagr      s     U^^ M
 mS!!			 9s122wsC001117#77888r\   c                     d| rt          |           t          t          d                   fdt          t                    D             }|S )aw  Determine the manylinux tags that are compatible with the given platform.

    If there is no glibc virtual package, then assume that all manylinux tags are
    compatible.

    The result is sorted in descending order in order to favor the latest.

    >>> platform_virtual_packages = {
    ...     "__glibc-2.24-0.tar.bz2": {
    ...         "name": "__glibc",
    ...         "version": "2.24",
    ...     },
    ... }
    >>> _compute_compatible_manylinux_tags({}) == list(reversed(MANYLINUX_TAGS))
    True
    >>> _compute_compatible_manylinux_tags(platform_virtual_packages)
    ['_2_24', '_2_17', '2014', '2010', '1']
    Nc                 :    g | ]}t          |          k    |S rV   )r   )rW   rX   latest_supported_glibc_versions     rZ   r[   z6_compute_compatible_manylinux_tags.<locals>.<listcomp>  s7     ! ! !,S115SSS 	SSSr\   )r   r   MANYLINUX_TAGSreversed)rK   rq   r   s     @rZ   rh   rh      s    0 9="  
)U%*
 *
& &-)J2*
 *
&! ! ! !N++! ! !
 %$r\   a  
    ^
    (?P<name>[a-zA-Z0-9_-]+) # package name
    (?:\[(?P<extras>(?:\s?[a-zA-Z0-9_-]+(?:\s?\,\s?)?)+)\])? # extras
    (?:
        (?: # a direct reference
            \s?@\s?(?P<url>.*)
        )
        |
        (?: # one or more PEP440 version specifiers
            \s?(?P<constraint>
                (?:\s?
                    (?:
                        (?:=|[><~=!])?=
                        |
                        [<>]
                    )?
                    \s?
                    (?:
                        [A-Za-z0-9\.-_\*]+ # a version tuple, e.g. x.y.z
                        (?:-[A-Za-z]+(?:\.[0-9]+)?)? # a post-release tag, e.g. -alpha.2
                        (?:\s?\,\s?)?
                    )
                )+
            )
        )
    )?
    $
    requirementc                 f    t                               |           }|sd S |                                S N)REQUIREMENT_PATTERNmatch	groupdict)r   r   s     rZ   parse_pip_requirementr   /  s2    %%k22E t??r\   depc           	         g }t          | t          j                  r#t          | j        | j        pd| j                  S t          | t          j                  r@t          | j        | j	         d| j
        d                             dd           |          S t          | t          j                  r't          | j        | j        | j        | j                  S t          | t          j                  rc| j        r.t'          | j        t)          | j                  | j        	          S t-          | j        t)          | j                  | j        	          S t/          d
|            )N*)r   
constraintextras#r   :=)r   urlr   )r   vcssourcerev)r   rO   r   zUnknown requirement )
isinstancer1   VersionedDependencyr!   r   r   r   URLDependencyr'   r   hashesr   VCSDependencyr(   r   r   r   PathDependencyis_directoryr"   r   rO   r#   rk   )r   r   s     rZ   get_dependencyr   6  sw   F#y455 7ck&8S
 
 
 	
 
C0	1	1 7"7>>SZ]223<<>>
 
 
 	

 
C0	1	1 7":	
 
 
 	
 
C1	2	2 
7 	,XDNN3:    (XDNN3:    555666r\   lockedc                     | j         "t          | j        d| j         j        d          S t          | j        | j                  S )Nr   0.0.0)source_type
source_urlr   )r   )r   r$   r   r   r   )r   s    rZ   get_packager   W  sM    } K}(	
 
 
 	
 V[&.AAAAr\   Fr   rM   poolenvpip_repositories
strip_authlock_spec_hashesc                 t   t          ||          }g }|i }d |pg D             }	| D ]}
|
j        sd}d}|
j        j        r|	                    |
j        j                  }|
j        j        dk    rt          t          t          |
j        j	                            \  }}|
                    d          }|dk    rt                      }n@t          |          dk    rt          di |d         |d	         i}nt          d
|           t          dt          t          |
j        j	                            }n|
j        j        dk    rR|
j        j         d|
j        j	         d|
j        j         }t          di d|
j        j        i}t          d|          }n|
j        j        dv r/d|
j        j	         }t                      }t          d|          }nV|                    |
j                  }t#          |          }t%          ||                    |
j        j                            }|r|                    |          }|                    t-          |
j        j        t          |
j        j                  d||d |
j        j        D             |s|nt3          |          |                     |S )zExtract distributions from Poetry package plan, ignoring uninstalls
    (usually: conda package with no pypi equivalent) and skipped ops
    (already installed)
    )r   Nc                     i | ]
}|j         |S rV   r   )rW   
repositorys     rZ   
<dictcomp>z$get_requirements.<locals>.<dictcomp>u  s)       (2
  r\   r   r    r   r   r   zDon't know what to do with )typer   git+@sha256)	directoryfilezfile://pipc                 B    i | ]}|j         t          |j                  S rV   )r   r}   r   rW   r   s     rZ   r   z$get_requirements.<locals>.<dictcomp>  s3     " " ":=#cn"5"5" " "r\   )r   r   managerr   rM   dependenciesr   hashrV   )r   skippedpackagesource_referencegetr   r   r   r}   r   rg   r.   r   rk   r-   source_resolved_reference
choose_for_get_stripped_url_compute_hashr   normalize_solver_urlr   r/   r   requires_strip_auth)r   rM   r   r   r   r   r   chooserrequirementsrepositories_by_nameopr   source_repositoryr   fragmenthash_splitsr   links                     rZ   get_requirementsr   c  s    d$$$G+-L 6F6L"    6 6z 5	15F $z* $8$<$<J/% %! z%.. )$sBJ4I*J*J K KX&nnS11r>>$;;DD%%**$HHAA'GHHDD$%M8%M%MNNN)Dbj.C$D$D   '500/pp"*2Gpp"*Jnpp TTHbj.R#STT)u#>>>'+@@@7
 577 {{)u#>>>
 ))"*55'--$T+;+?+?
+P+PQQ  B'<<SAA 
 233!!%" "ACAT" " " $.C;s3C3C     r\   r   c                     t          | j                  }|j         }|j        | d|j         }t	          |j        ||j        |j        df          S )a9  Get the URL for a package link, stripping credentials.

    Basic case, do nothing:
    >>> _get_stripped_url(Link(url="http://example.com/path/to/file"))
    'http://example.com/path/to/file'

    Strip credentials:
    >>> _get_stripped_url(Link(url="http://user:pass@example.com/path/to/file"))
    'http://example.com/path/to/file'

    Handle a port:
    >>> _get_stripped_url(Link(url="http://example.com:8080/path/to/file"))
    'http://example.com:8080/path/to/file'

    Strip credentials while handling a port:
    >>> _get_stripped_url(Link(url="http://user:pass@example.com:8080/path/to/file"))
    'http://example.com:8080/path/to/file'

    General case:
    >>> _get_stripped_url(Link(url="https://user:pass@example.com:8080/path/to/file?query#fragment"))
    'https://example.com:8080/path/to/file?query'
    Nr   r   )r   r   hostnameportr   schemerO   query)r   
parsed_urlclean_netlocs      rZ   r   r     si    . $(##J )+L"&::::O	
  r\   lock_spec_hashc                     |(t          | j                  }t          j        |          S |                    d          \  }}t          di ||iS )Nr   rV   )dictr   r.   model_validaterg   )r   r   r   algovalues        rZ   r   r     sY    !%dk!2!2'/// %**3//e))D%=)))r\   T)rK   r   allow_pypi_requestsverboser   	pip_specs
use_latest
pip_lockedconda_lockedrL   r   r  mapping_urlc           	         t          dd          }d |                                 D             }|D ]}|                    |           d |                                 D             }t          ||          }g }g }t	                      }|                                D ]}|j                            d          r|j        dk    r
d|j        vr2	 t          |j        |	          
                                }n# t          $ r Y hw xY w||vs||j        k    r
|j        ||<   |                                D ]0\  }}||fD ]&}|                    t          ||
                     '1|                                D ]$}|                    t!          |                     %|	rt#                      }|                    t&          j                   t+          |t-          t&          j                  t-          t&          j                            }|                    t4          j                   nt9                      }t;          |||||          }t=          d |                                D                                 |                    }tA          |||          }|!                    |          5  |"                    |          }ddd           n# 1 swxY w Y   tG          |$                    d          |||||
|          } i d | D             }!|                                D ]<\  }"}t          |"|	          }||!v r|!|                             |           6|g|!|<   =tK          | |!d|           d | D             S )ab  
    Solve pip dependencies for the given platform

    Parameters
    ----------
    conda :
        Path to conda, mamba, or micromamba
    use_latest :
        Names of packages to update to the latest version compatible with pip_specs
    pip_specs :
        PEP440 package specifications
    pip_locked :
        Previous solution for the given platform (pip packages only)
    conda_locked :
        Current solution of conda-only specs for the given platform
    python_version :
        Version of Python in conda_locked
    platform :
        Target platform
    platform_virtual_packages :
        Virtual packages for the target platform
    allow_pypi_requests :
        Add pypi.org to the list of repositories (pip packages only)
    verbose :
        Print chatter from solver
    strip_auth :
        Whether to strip HTTP Basic auth from URLs.

    _dummy_package_r   c                 ,    g | ]}t          |          S rV   )r   rW   specs     rZ   r[   zsolve_pypi.<locals>.<listcomp>  s-     , , ,!%t, , ,r\   c                 j    i | ]0}t          |t          j                  |j        #|j        |j        1S rV   )r   r1   r   r   r   r
  s     rZ   r   zsolve_pypi.<locals>.<dictcomp>  sQ        dI9::	 @Dy		49  r\   )r   __r   python)r  )r   r   )r   	installedr   ioc                 6    h | ]}t          |j                  S rV   )r   r   r
  s     rZ   	<setcomp>zsolve_pypi.<locals>.<setcomp>O  s#    FFF$	49	%	%FFFr\   )rL   rM   rK   )r  NF)with_uninstalls)r   r   r   c                      i | ]}|j         |gS rV   r   r   s     rZ   r   zsolve_pypi.<locals>.<dictcomp>i  s    
3
3
3s38cU
3
3
3r\   T)	requestedplannedconvert_to_pip_namesr  c                     i | ]
}|j         |S rV   r   r   s     rZ   r   zsolve_pypi.<locals>.<dictcomp>  s    222cCHc222r\   )&r%   r   add_dependency_prepare_repositories_poolr   r   r   r   r   r0   lowerKeyErrorr   itemsr   r$   r   r   
set_streamre   stdinr   r   stdoutstderrset_verbosityr   VERY_VERBOSEr   r&   ri   intersectionr=   use_environmentsolver   calculate_operationsr,   )#r  r  r  r  rL   rM   rK   r   r   r  r   r  dummy_packager   r   r   r   r  r   python_packages
locked_dep	pypi_namer   r   repor  inputr  s	to_updater   r   r   r  
conda_names#                                      rZ   
solve_pypir1    s   X )):GDDM, ,)2)9)9););, , ,L  * *$$S))))  $$&&   &.>  D IFffO"))++ < <
?%%d++ 	&&8:;R+R+R	/[  egg I  	 	 	H	
 O++yJO/K/K)3);OI&(..00 C CgY' 	C 	CDKK4AAABBBB	C !!## ) )k$''(((( ###|CJ//cj1I1IJJ
/0000XX	 	 	A FF*2C2C2E2EFFFSS	
 	
 I
 %";  C 
		3		 / /I../ / / / / / / / / / / / / / / $##E#::))  L
3
3l
3
3
3G #/"4"4"6"6 . .
J+JKPPP	I%%j1111",GI!	    32\2222s$   (C::
DD7KK!Kc                 `   t                      }t          j                    }g }|pg }|D ]n}|j        }||                    d|j        |ii           |                    |j        t          |j                  d|          }|	                    |           o|
                    di                                           D ]9\  }}	|                    ||	d         d|          }|	                    |           :| r!|	                    t                                 t          g |          S )z
    Prepare the pool of repositories to solve pip dependencies

    Parameters
    ----------
    allow_pypi_requests :
            Add pypi.org to the list of repositories
    Nz
http-basic)r   r   repositoriesr   )r3  )r   r   createexpanded_basic_authmerger   create_package_sourcer   stripped_urlr   r   r  r*   r)   )
r   r   factoryconfigrepospip_repositorycredsr   r   repo_configs
             rZ   r  r    sT    iiG]__F"$E'-2*  2LL,)<e(DEFFF..&+!."=>>  
 
 	V#ZZ;;AACC  k..+e"455v
 
 	V '^%%&&&XuX&&&&r\   r   c                     t          | d          }|j                            d          d         }t          |j        ||j        |j        |j        f          S )z+Strip HTTP Basic authentication from a URL.T)allow_fragmentsr   r   )r   netlocrg   r   r   rO   r   r   )r   partsrA  s      rZ   r   r     sQ    S$///E \$$R(Fu|VUZenUVVVr\   )NFNr   )]rere   r   pathlibr   	posixpathr   typingr   r   r   r   r	   r
   r   urllib.parser   r   r   packaging.tagsr   r   r   packaging.utilsr   packaging.versionr   ,conda_lock._vendor.cleo.io.inputs.argv_inputr   conda_lock._vendor.cleo.io.ior   "conda_lock._vendor.cleo.io.null_ior   )conda_lock._vendor.cleo.io.outputs.outputr   0conda_lock._vendor.cleo.io.outputs.stream_outputr   6conda_lock._vendor.poetry.repositories.http_repositoryr   conda_lock.content_hash_typesr   %conda_lock.interfaces.vendored_poetryr   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   conda_lock.lockfiler,   #conda_lock.lockfile.v2prelim.modelsr-   r.   r/   conda_lock.lookupr0   conda_lock.modelsr1    conda_lock.models.pip_repositoryr2   r3   r   rj   r=   r}   r   r   rh   compileVERBOSEr   r   
Dependencyr   r   boolr   r   r   r1  r  r   rV   r\   rZ   <module>r\     s   				 



                                     9 8 8 8 8 8 8 8 8 8 G G G G G G G G G G - - - - - - % % % % % % B B B B B B , , , , , , 5 5 5 5 5 5 ? ? ? ? ? ? I I I I I I Q Q Q Q Q Q @ @ @ @ @ @                                     & 1 0 0 0 0 0         
 6 5 5 5 5 5 ' ' ' ' ' ' : : : : : :  #"""""" BAA T T T T T* T T Tn##C)?$?@#g# # # #L93 97 9 9 9 9,.%'S2H-H(IJ.%	#Y.% .% .% .%b !bj: J=  Ds xS#X/G    7	, 71A 7 7 7 7B	B( 	B] 	B 	B 	B 	B" 7;15M MOMM M 
	M
 tM23M M tCH~.M 

M M M M`$D $S $ $ $ $N* *hsm *	 * * * *$ NR6: $]3 ]3 ]3C--.]3 S	]3 S**+	]3
 s,,-]3 ]3 ]3  (S2H-H(IJ]3 tM23]3 ]3 ]3 ]3 ]3 
#
 ]3 ]3 ]3 ]3B RV"' "'"'19$}:M1N"'	"' "' "' "'JWS WS W W W W W Wr\   