§
    ¬	Êj´.  ã                  ó>  — d Z ddlm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lmZmZmZmZ ddlmZ  e	d¬	¦  «         G d
„ d¦  «        ¦   «         Zd!d„Zd"d„Zd#d„Zd$d„Zd\  ZZZ e	d¬	¦  «         G d„ d¦  «        ¦   «         Zd%d„Zd&d„Zd'd „ZdS )(aV  Is this distribution an EDITABLE install, and how sure are we?

WHY IT IS ITS OWN MODULE. This answer existed twice, in two strengths, and the
strong one was in the place that never acts on it:

  * `__main__.py` had a three-valued detector over four independent signals,
    refusing on `unknown` - and `__main__` is the CLI, which is forbidden from
    running pip at all (`INSTALL_RUNNER = _refuse_to_install`).
  * `_pin.py` had `editable_core_path()`: one file, `direct_url.json`, two
    values, `None` on any gap - and `_pin` is the module that actually runs
    `pip install --force-reinstall`, from the first line of a consumer's
    `__init__`.

So the careful check guarded a command that never runs and the careless one
guarded the command that overwrites a developer's working tree. That is not
hypothetical: on 2026-07-27 it fired THREE times in one session, replacing an
editable checkout with the published wheel, and twice it corrupted a
measurement rather than just being annoying - three tests went red claiming
fixes that were present on disk were missing, and five mutation checks reported
SURVIVED against a gate that was sound. The third time it blocked a push in the
middle of a release.

THE RULE
--------
`safe_to_reinstall` is `state == NOT_EDITABLE`, never `state != EDITABLE`. The
three ways the old check was defeated all produced an ABSENCE of evidence, and
an absence of evidence must not read as a licence to overwrite somebody's work.

Stdlib only. `_pin` imports this and `_pin` runs at the first line of a
consumer's import, so anything heavy here is paid by every user on every start.
é    )ÚannotationsN)Ú	dataclassÚfield)ÚPath)ÚListÚOptionalÚSequenceÚTuple)ÚmetadataT)Úfrozenc                  ó¦   — e Zd ZU dZded<   ded<   dZded<   dZd	ed
<   dZded<   dZded<   dZ	ded<   dZ
ded<   dZd	ed<   dZd	ed<   dZded<   dS )Ú	DistFactsa  Everything the doctor reads about one distribution. One seam, so the
    tests never touch the real environment.

    direct_url_raw is the FILE, kept separately from the parsed object on
    purpose: "the file is not there" and "the file is there and is garbage" are
    different findings, and collapsing them into `direct_url is None` is how the
    editable check used to conclude "not editable" from a truncated file.

    requires is the raw Requires-Dist list. The doctor does NOT parse it here:
    the `invisible-core==` question is answered by invisible_core.pin, so the
    doctor and the consumers' import-time check cannot disagree about the same
    metadata. It is kept because it is what the environment declares, and the
    tests feed the shared parser from this same field.
    ÚstrÚnameÚboolÚpresentÚ Úversion© úTuple[str, ...]ÚrequiresNzOptional[dict]Ú
direct_urlzOptional[str]Údirect_url_rawÚmetadata_dirÚmodule_pathÚlegacy_editableÚeditable_finderÚgit_worktree)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r   r   r   r   r   r   r   r   r   r   ó    úCC:\Projects\Muse2API\.venv\Lib\site-packages\invisible_core/_env.pyr   r   .   sÉ   € € € € € € ðð ð €I€I�IØ€M€M�MØ€GÐÐÐÑØ "€HÐ"Ð"Ð"Ñ"Ø!%€JÐ%Ð%Ð%Ñ%Ø$(€NÐ(Ð(Ð(Ñ(Ø€LÐÐÐÑØ€KÐÐÐÑØ')€OÐ)Ð)Ð)Ñ)Ø')€OÐ)Ð)Ð)Ñ)Ø€LÐÐÐÑÐÐr$   r   Úpr   Úreturnr   c                ó>   — t          d„ | j        D ¦   «         ¦  «        S )Nc              3  ó   K  — | ]}|d v V — Œ	dS ))zsite-packageszdist-packagesNr   )Ú.0Úparts     r%   ú	<genexpr>z'_under_site_packages.<locals>.<genexpr>L   s(   è è € ÐNÐN¸dˆtÐ9Ð9ÐNÐNÐNÐNÐNÐNr$   )ÚanyÚparts)r&   s    r%   Ú_under_site_packagesr/   K   s!   € ÝÐNÐNÀaÄgÐNÑNÔNÑNÔNÐNr$   r   c                ó”   — 	 | g| j         ¢D ]*}|dz                       ¦   «         rt          |¦  «        c S Œ+n# t          $ r Y nw xY wdS )aÃ  The nearest ancestor holding a .git entry, or "".

    Only ever consulted for files that are NOT under site-packages. A virtualenv
    created inside the project (.venv/, the common layout) puts every ordinary
    index install inside a git working tree, so on its own this signal would
    call the whole environment editable. Paired with the site-packages test it
    is what distinguishes `pip install -e .` from `pip install invisible-core`.
    z.gitr   )ÚparentsÚexistsr   ÚOSError)r&   Úds     r%   Ú_git_worktree_abover5   O   sv   € ðØ��a”i�ð 	ð 	ˆAØ�F‘
×"Ò"Ñ$Ô$ð Ý˜1‘v”v���ðð	øõ ð ð ð Øˆðøøøàˆ2s   ‚38 ¶8 ¸
AÁAÚmodr   c                óú  — 	 t          |                      |¦  «        ¦  «        }|                     ¦   «         rt          |¦  «        S n# t          $ r Y nw xY w	 ddl}|j                             |¦  «        }t          t          |dd¦  «        pg ¦  «        }|r"t          t          |d         ¦  «        ¦  «        S |�-|j
        r&t          t          |j
        ¦  «        j        ¦  «        S n# t          $ r Y nw xY wdS )z8Where do the files that would actually be imported live?r   NÚsubmodule_search_locationsr   )r   Úlocate_filer2   r   Ú	ExceptionÚimportlib.utilÚutilÚ	find_specÚlistÚgetattrÚoriginÚparent)r4   r6   r   r&   Ú	importlibÚspecÚlocss          r%   Ú_locate_modulerE   a   s  € ðÝ�—’˜sÑ#Ô#Ñ$Ô$ˆØ�8Š8‰:Œ:ð 	Ý�q‘6”6ˆMð	øåð ð ð Øˆðøøøð	ØÐÐÐØŒ~×'Ò'¨Ñ,Ô,ˆÝ•G˜DÐ">ÀÑEÔEÐKÈÑLÔLˆØð 	&Ý•t˜D œG‘}”}Ñ%Ô%Ð%ØÐ ¤ÐÝ•t˜DœKÑ(Ô(Ô/Ñ0Ô0Ð0øøÝð ð ð Øˆðøøøàˆ2s+   ‚AA Á
AÁAÁA!C+ Â;.C+ Ã+
C8Ã7C8r   c                óR  — 	 t          j        | ¦  «        }n@# t           j        $ r t          | d¦  «        cY S t          $ r t          | d¦  «        cY S w xY wd }	 |                     d¦  «        }n# t          $ r d }Y nw xY wd }|�A	 t          j        |¦  «        }t          |t          ¦  «        r|nd }n# t          $ r d }Y nw xY wt          j        dd| ¦  «        }t          t          t          |dd¦  «        pd¦  «        ¦  «        }t          |¦  «        r|j        nd }t#          |||¦  «        }g }	g }
t          |¦  «        rN|j                             d¦  «        r4t)          |¦  «        s%|	                     d|j        › d	|j        › �¦  «         |�û	 |                     d
¦  «        D ]`}|                     ¦   «         |j                             ¦   «                              dd¦  «        v r|	                     |j        › d�¦  «         Œa|                     d¦  «        D ]]}|                     ¦   «         |j                             ¦   «                              dd¦  «        v r|
                     |j        ¦  «         Œ^n# t4          $ r Y nw xY wd}|r8t)          t          |¦  «        ¦  «        st7          t          |¦  «        ¦  «        }t          | d|j        pdt;          |j        pd¦  «        ||t          |¦  «        |t;          |	¦  «        t;          |
¦  «        |¬¦  «        S )NFzdirect_url.jsonz[-.]+Ú_Ú_pathr   )z	.egg-infoz.eggzlegacy z outside site-packages at z
*.egg-linkú-z (a develop-mode link)z__editable__*Tr   )r   r   r   r   r   r   )r   ÚdistributionÚPackageNotFoundErrorr   r:   Ú	read_textÚjsonÚloadsÚ
isinstanceÚdictÚ
ValueErrorÚreÚsubr   r   r?   rA   rE   r   Úendswithr/   ÚappendÚglobÚlowerÚstemÚreplacer3   r5   r   Útupler   )r   r4   ÚrawÚduÚparsedr6   Úmeta_dirÚsite_dirr   ÚlegacyÚfinderÚlinkÚshimÚworktrees                 r%   Ú_dist_factsre   x   ss  € ð&ÝÔ! $Ñ'Ô'ˆˆøÝÔ(ð &ð &ð &Ý˜˜uÑ%Ô%Ð%Ð%Ð%Ýð &ð &ð &Ý˜˜uÑ%Ô%Ð%Ð%Ð%ð&øøøð €CðØ�kŠkÐ+Ñ,Ô,ˆˆøÝð ð ð Øˆˆˆðøøøà	€BØ
€ð	Ý”Z ‘_”_ˆFÝ% f­dÑ3Ô3Ð=��¸ˆBˆBøÝð 	ð 	ð 	ØˆBˆBˆBð	øøøõ Œ&�˜3 Ñ
%Ô
%€CÝ•C�  7¨BÑ/Ô/Ð5°2Ñ6Ô6Ñ7Ô7€HÝ"% h¡-¤-Ð9ˆxŒˆ°T€HÝ   C¨Ñ2Ô2€Kà€FØ€FÝ
ˆ8�}„}ð \˜œ×/Ò/Ð0EÑFÔFð \Ý(¨Ñ2Ô2ð\ð
 	�ŠÐZ ¤ÐZÐZÈÌÐZÐZÑ[Ô[Ð[ØÐð	Ø Ÿš lÑ3Ô3ð Hð H�Ø—9’9‘;”; $¤)§/¢/Ñ"3Ô"3×";Ò";¸CÀÑ"EÔ"EÐEÐEØ—M’M T¤YÐ"FÐ"FÐ"FÑGÔGÐGøØ Ÿš oÑ6Ô6ð -ð -�Ø—9’9‘;”; $¤)§/¢/Ñ"3Ô"3×";Ò";¸CÀÑ"EÔ"EÐEÐEØ—M’M $¤)Ñ,Ô,Ð,øð-øõ ð 	ð 	ð 	ØˆDð	øøøð €HØð :Õ/µ°[Ñ0AÔ0AÑBÔBð :Ý&¥t¨KÑ'8Ô'8Ñ9Ô9ˆå�T˜4 ¤ ¨bµ%¸¼
Ð8HÀbÑ2IÔ2IÈ2Ø$'µc¸(±m´mØ!,½eÀF¹m¼mÝ%*¨6¡]¤]ÀðKñ Kô Kð KsK   ‚ —A¸AÁAÁA0 Á0A?Á>A?Â-B5 Â5CÃCÆC)J Ê
JÊJ)Úeditableznot-editableÚunknownc                  ót   — e Zd ZU dZded<   dZded<   dZded<    ee¬¦  «        Z	ded	<   e
dd„¦   «         ZdS )ÚEditabilityzEThree answers, not two. `unknown` is the one that used to be missing.r   Ústater   ÚpathÚwhy)Údefault_factoryr   Úevidencer'   r   c                ó"   — | j         t          k    S )a#  Only a POSITIVE not-editable finding unlocks an install command.

        Not `state != EDITABLE`. The three ways this check was defeated all
        produced an absence of evidence, and an absence of evidence must not
        read as a licence to overwrite somebody's working tree.
        )rj   ÚNOT_EDITABLE)Úselfs    r%   Úsafe_to_reinstallzEditability.safe_to_reinstallº   s   € ð Œz�\Ò)Ð)r$   N)r'   r   )r   r    r!   r"   r#   rk   rl   r   rZ   rn   Úpropertyrr   r   r$   r%   ri   ri   ²   s{   € € € € € € àOÐOØ€J€J�JØ€D€N€N€N�NØ€C€M€M€M�MØ % °eÐ <Ñ <Ô <€HÐ<Ð<Ð<Ñ<àð*ð *ð *ñ „Xð*ð *ð *r$   ri   ÚfactsúTuple[str, str, str]c                ó€  — | j         €
t          ddfS | j        €B| j                              ¦   «         dd…                              dd¦  «        }t          dd|›�fS | j        }|                     d¦  «        pd}t          |t          ¦  «        r|s
t          dd	fS |                     d
¦  «        }|€d|v sd|v r
t          |dfS t          |dfS t          |t          ¦  «        s t          |dt          |¦  «        j        › d�fS |                     d¦  «        }|du r
t          |dfS |dv r
t          |dfS t          |d|›�fS )z@(state, url, why) from PEP 610 alone. Every gap answers UNKNOWN.Nr   zYno direct_url.json (an index install has none, but so does a `setup.py develop` editable)é<   ú
ú z@direct_url.json is present but does not parse as a JSON object: Úurlz!direct_url.json declares no 'url'Údir_infoÚvcs_infoÚarchive_infoz:installed from a VCS or archive URL, not a local directoryzhdirect_url.json has no 'dir_info', and no 'vcs_info' or 'archive_info' either - the record is incompletez direct_url.json 'dir_info' is a z, not an objectrf   Tz&direct_url.json says dir_info.editable)FNz>installed from a local directory, dir_info.editable is not setz'direct_url.json 'dir_info.editable' is )r   ÚUNKNOWNr   ÚstriprY   ÚgetrO   r   rp   rP   Útyper   ÚEDITABLE)rt   Úheadr\   rz   r{   Úflags         r%   Ú_pep610_verdictr…   Å   s¼  € àÔÐ#Ý˜ð Cð Dð 	DàÔÐØÔ#×)Ò)Ñ+Ô+¨C¨R¨CÔ0×8Ò8¸¸sÑCÔCˆÝ˜ð 1Ø(,ð1ð 1ð 2ð 	2à	Ô	€BØ
�&Š&�‰-Œ-Ð
˜2€CÝ�c�3ÑÔð B sð BÝ˜Ð@ÐAÐAØ�vŠv�jÑ!Ô!€HØÐð ˜ÐÐ˜~°Ð3Ð3Ý  #ð (9ð :ð :å˜ð Qð Rð 	Rå�h¥Ñ%Ô%ð KÝ˜ð JÝ!% h¡¤Ô!8ðJð Jð Jð Kð 	Kà�<Š<˜
Ñ#Ô#€DØˆt€|€|Ý˜#ÐGÐHÐHØˆ}ÐÐÝ˜cð $0ð 1ð 	1å�SÐLÀDÐLÐLÐMÐMr$   c           	     óx  — | j         st          t          dd¦  «        S t          | j        ¦  «        d„ | j        D ¦   «         z   }| j        rTt          t          | j        ¦  «        ¦  «        s3d| j        › �}| j	        r|d| j	        › �z  }| 
                    |¦  «         t          | ¦  «        \  }}}t          |¦  «        p| j        }|t          k    r(t          t          ||t          |g|z   ¦  «        ¦  «        S |r>t          t          |p| j        d                     |¦  «        t          |¦  «        ¦  «        S |t           k    r`| j        €C| j        r<t          t          | j        ¦  «        ¦  «        rt          t          | j        d¦  «        S t          t           ||¦  «        S t          t          ||¦  «        S )	a1  editable / not-editable / unknown, from four independent signals.

    Ordering is deliberate: any positive signal wins over a negative PEP 610
    record, because the ways this goes wrong in practice are all "the record
    does not know about the editable install", never "the record invented one".
    r   z'no install record for this distributionc                ó   — g | ]}|› d �‘ŒS )z+ in site-packages (an editable finder shim)r   )r*   Úns     r%   ú
<listcomp>z _editable_of.<locals>.<listcomp>ñ   s4   € ð 9Zð 9Zð 9ZØ>?ˆ1Ð9Ð9Ð9ð9Zð 9Zð 9Zr$   z3the importable files are outside site-packages, at z, inside the git working tree z; Nz6no direct_url.json and the files live in site-packages)r   ri   rp   r>   r   r   r   r/   r   r   rU   r…   Ú_display_pathr‚   rZ   Újoinr~   r   )rt   ÚpositiveÚnoterj   rz   rl   rk   s          r%   Ú_editable_ofrŽ   ç   sÙ  € ð Œ=ð XÝ�<¨Ð-VÑWÔWÐWå˜uÔ4Ñ5Ô5ð 9Zð 9ZØCHÔCXð9Zñ 9Zô 9Zñ Z€HàÔð Õ!5µd¸5Ô;LÑ6MÔ6MÑ!NÔ!Nð ØXÀUÔEVÐXÐXˆØÔð 	JØÐI°UÔ5GÐIÐIÑIˆDØ�Š˜ÑÔÐå% eÑ,Ô,�O€Eˆ3�Ý˜ÑÔÐ2 Ô!2€Dà•ÒÐÝ�8 T¨3µ°s°e¸hÑ6FÑ0GÔ0GÑHÔHÐHØð AÝ�8 TÐ%>¨UÔ->ØŸ9š9 XÑ.Ô.µ°h±´ñAô Að 	Aà•ÒÐØÔÐ'¨EÔ,=Ð'Ý(­¨eÔ.?Ñ)@Ô)@ÑAÔAð (õ �|¨UÔ->ØWñYô Yð Yå�7 D¨#Ñ.Ô.Ð.Ý•| T¨3Ñ/Ô/Ð/r$   rz   c                ó¨   — | sdS |                       d¦  «        r8ddlm} ddlm} 	  | || ¦  «        j        ¦  «        S # t          $ r | cY S w xY w| S )Nr   zfile:r   )Úurlparse)Úurl2pathname)Ú
startswithÚurllib.parser�   Úurllib.requestr‘   rk   r:   )rz   r�   r‘   s      r%   rŠ   rŠ     s�   € Øð ØˆrØ
‡~‚~�gÑÔð Ø)Ð)Ð)Ð)Ð)Ð)Ø/Ð/Ð/Ð/Ð/Ð/ð	Ø�<  ¨¡¤Ô 2Ñ3Ô3Ð3øÝð 	ð 	ð 	ØˆJˆJˆJð	øøøà€Js   §A  Á AÁA)r&   r   r'   r   )r&   r   r'   r   )r6   r   r   r   r'   r   )r   r   r'   r   )rt   r   r'   ru   )rt   r   r'   ri   )rz   r   r'   r   ) r"   Ú
__future__r   rM   ÚosrR   Ú
subprocessÚsysÚdataclassesr   r   Úpathlibr   Útypingr   r   r	   r
   rB   r   r   r/   r5   rE   re   r‚   rp   r~   ri   r…   rŽ   rŠ   r   r$   r%   ú<module>rœ      së  ððð ð> #Ð "Ð "Ð "Ð "Ð "à €€€Ø 	€	€	€	Ø 	€	€	€	Ø Ð Ð Ð Ø 
€
€
€
Ø (Ð (Ð (Ð (Ð (Ð (Ð (Ð (Ø Ð Ð Ð Ð Ð Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2à Ð Ð Ð Ð Ð ð €�$ÐÑÔðð ð ð ð ñ ô ñ Ôðð8Oð Oð Oð Oðð ð ð ð$ð ð ð ð.4Kð 4Kð 4Kð 4Kðn #HÑ €ˆ,˜ð €�$ÐÑÔð*ð *ð *ð *ð *ñ *ô *ñ Ôð*ð$Nð Nð Nð NðD$0ð $0ð $0ð $0ðN
ð 
ð 
ð 
ð 
ð 
r$   