§
    ®	ÊjY  ã                  ó¨   — d Z ddlmZ ddlZddl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Zd	Zd
Zdd„Zdd„Zefdd„Z e¦   «         \  ZZg d¢ZdS )u©
  What version the code being imported actually is.

â›” AN INSTALL RECORD IS NOT A DESCRIPTION OF THE CODE, AND FOR AN EDITABLE
INSTALL IT STOPS BEING ONE THE MOMENT SOMEBODY PULLS. `importlib.metadata`
answers about the DISTRIBUTION the installer put there. For a wheel that is the
same artifact as the code, so the number is right and there is nothing truer to
read. For `pip install -e` the metadata is written once and the code keeps
moving, and nothing says the two have parted.

Measured on the machine this is developed on, minutes after the checkout was
brought to zero commits behind `origin/main`: the record said 0.16.2 while the
tree said 0.22.1, six releases apart. Pulling does not touch the record, which
is what makes this a defect in the code rather than a stale checkout.

â›” AND THE NUMBER IS WHAT A MEASUREMENT NAMES. This package is the thing under
test in every bench that drives a browser, so "measured against
invisible-playwright X" is the sentence that carries the result. Read from the
program, X was the moment somebody ran `pip install -e`, not the code being
measured. A finding was about to be written with a version six releases wrong;
it survived because its author had read the number off the TREE instead, which
is luck rather than method. The rule those benches already carry - a red against
an old dependency is not evidence about the product - keeps being broken because
nothing answered "which version am I measuring?" truthfully.

The version of the code is:

  - a normal install: the install record, because the metadata and the code
    came out of the same build;
  - an editable install: the version the SOURCE TREE declares, because that is
    the code that will run, plus a `+editable` local segment (PEP 440) so it
    can never be read as the published release of the same number. An editable
    tree can carry uncommitted work, so a bare `0.22.1` would invite a report
    against a release that does not contain the code being run.

Which of the two an install is comes from what the installer WROTE, not from a
guess about `__file__`: PEP 610 puts `direct_url.json` beside the metadata,
carrying `dir_info.editable` and the source directory. A wheel install has no
such file at all.

The install record stays, under a name that cannot be mistaken for the version.
`invisible_core` made this split first and names it the same way, deriving its
own `__version__` from the seal it ships; it is not a shared implementation and
must not become one by copying, because the core derives from an artifact it
PACKAGES while this reads the tree an install points at. `aihawk` carries the
same reading as this module for the same reason, so a correction here is worth
looking at there.
é    )ÚannotationsN)ÚDistributionÚPackageNotFoundErrorÚdistribution)ÚPath)Úurlparse)Úurl2pathnamezinvisible-playwrightz0.0.0+unknownz	+editableÚdistr   ÚreturnúPath | Nonec                óÀ  — |                       d¦  «        }|sdS 	 t          j        |¦  «        }n# t          $ r Y dS w xY wt	          |t
          ¦  «        sdS |                     d¦  «        pi                      d¦  «        sdS |                     d¦  «        pd}|                     d¦  «        sdS t          t          t          |¦  «        j        ¦  «        ¦  «        S )zÙThe directory an EDITABLE install points at, or None for a normal one.

    Everything here is read from the record the installer wrote. The absence of
    `direct_url.json` is how a wheel install says it is one.
    zdirect_url.jsonNÚdir_infoÚeditableÚurlÚ zfile:)Ú	read_textÚjsonÚloadsÚ
ValueErrorÚ
isinstanceÚdictÚgetÚ
startswithr   r	   r   Úpath)r
   ÚwrittenÚrecordr   s       úMC:\Projects\Muse2API\.venv\Lib\site-packages\invisible_playwright/_version.pyÚsource_treer   C   sî   € ð �nŠnÐ.Ñ/Ô/€GØð ØˆtðÝ”˜GÑ$Ô$ˆˆøÝð ð ð Øˆtˆtðøøøå�f�dÑ#Ô#ð ØˆtØ�JŠJ�zÑ"Ô"Ð( b×-Ò-¨jÑ9Ô9ð ØˆtØ
�*Š*�UÑ
Ô
Ð
!˜r€CØ�>Š>˜'Ñ"Ô"ð ð ˆtÝ•�X c™]œ]Ô/Ñ0Ô0Ñ1Ô1Ð1s   ›0 °
>½>Útreer   ú
str | Nonec                ó  — 	 t          j        | dz                       d¬¦  «        ¦  «        }n# t          t          f$ r Y dS w xY w|                     d¦  «        pi                      d¦  «        }t          |t          ¦  «        r|r|ndS )aÙ  The version that source tree declares, or None when it does not say one.

    `pyproject.toml` is where the version lives and the metadata is a copy of it
    taken at build time, so this goes back to the source of the copy rather than
    adding a second source. A tree declaring `dynamic = ["version"]` says
    nothing readable without running its build backend, and answering None there
    falls back to the record, which is the same answer as before this module.
    zpyproject.tomlzutf-8)ÚencodingNÚprojectÚversion)Útomllibr   r   ÚOSErrorr   r   r   Ústr)r   ÚparsedÚdeclareds      r   Údeclared_byr*   \   sŸ   € ðÝ”ØÐ$Ñ$×/Ò/¸Ð/ÑAÔAñCô Cˆˆøå•ZÐ ð ð ð Øˆtˆtðøøøà—
’
˜9Ñ%Ô%Ð+¨×0Ò0°Ñ;Ô;€HÝ! (­CÑ0Ô0ÐG°XÐGˆ8ˆ8À4ÐGs   ‚+. ®AÁAÚnamer'   útuple[str, str]c                óÐ   — 	 t          | ¦  «        }n# t          $ r t          dfcY S w xY w|j        }t	          |¦  «        }|€||fS t          |¦  «        }|€||fS |t          z   |fS )a€  (the version of the CODE, the version in the install record).

    The two differ exactly when the install is editable and the tree has moved
    since it was installed, which on a machine where this is developed is most
    of the time. `name` is a parameter so the behaviour can be tested against a
    real editable install of a real distribution rather than against a double.
    r   )r   r   ÚUNKNOWNr$   r   r*   ÚEDITABLE)r+   r
   r   r   r)   s        r   Úversionsr0   n   s—   € ðÝ˜DÑ!Ô!ˆˆøÝð ð ð õ ˜ˆ{ÐÐÐðøøøð Œ\€FÝ�tÑÔ€DØ€|Ø�vˆ~ÐÝ˜4Ñ Ô €HØÐØ�vˆ~Ðð •hÑ Ð&Ð&s   ‚ ’(§()Ú__version__Ú__install_record_version__r0   r   r*   ÚDISTRIBUTIONr/   r.   )r
   r   r   r   )r   r   r   r    )r+   r'   r   r,   )Ú__doc__Ú
__future__r   r   r%   Úimportlib.metadatar   r   r   Úpathlibr   Úurllib.parser   Úurllib.requestr	   r3   r.   r/   r   r*   r0   r1   r2   Ú__all__© ó    r   ú<module>r=      s  ðð.ð .ð^ #Ð "Ð "Ð "Ð "Ð "à €€€Ø €€€Ø OÐ OÐ OÐ OÐ OÐ OÐ OÐ OÐ OÐ OØ Ð Ð Ð Ð Ð Ø !Ð !Ð !Ð !Ð !Ð !Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'ð &€ð €ð €ð2ð 2ð 2ð 2ð2Hð Hð Hð Hð$ &ð 'ð 'ð 'ð 'ð 'ð4 +3¨(©*¬*Ñ '€Ð'ðPð Pð P€€€r<   