U
    Uc                     @   s*   d Z ddlZddlmZ ejZdd ZdS )z3Internal helper for running tests on Windows Bazel.    N)flagsc           
   
   C   s   t jdkr| d7 } t jtjd}t jd }d|| }t|dP}|D ]D}|	 
d}t|dkrhqH||d	 krH|d
   W  5 Q R  S qHW 5 Q R X td| |n:t}ttdd
 D ]}t j|}q|}	t j|	| S dS )a  Returns the executable path of a py_binary.

  This returns the executable path of a py_binary that is in another Bazel
  target's data dependencies.

  On Linux/macOS, the path and __file__ has the same root directory.
  On Windows, bazel builds an .exe file and we need to use the MANIFEST file
  the location the actual binary.

  Args:
    py_binary_name: string, the name of a py_binary that is in another Bazel
        target's data dependencies.

  Raises:
    RuntimeError: Raised when it cannot locate the executable path.
  ntz.exeZMANIFESTZTEST_WORKSPACEz{}/{}r    r      z8Cannot locate executable path for {}, MANIFEST file: {}..N)osnamepathjoinFLAGSZtest_srcdirenvironformatopenstripsplitlenRuntimeError__file__range__name__countdirname)
Zpy_binary_nameZmanifest_fileZworkspace_nameZmanifest_entryZmanifest_fdlinetokensr   _Zroot_directory r   B/tmp/pip-unpacked-wheel-yg88_g5m/absl/testing/_bazelize_command.pyget_executable_path   s.    

$ r   )__doc__r	   Zabslr   r   r   r   r   r   r   <module>   s   