B
    q\+              
   @   s~  d Z ddlZddlZddlmZ dZdZdZG dd deZ	ej
ed	d
 edD k rhe	ded5ddZdd Zye W n0 ek
r   ddlm
Z
 ddlZe e_Y nX yddlma W n ek
r   daY nX yddlma W n ek
r   daY nX dtkrdZn
dtZdd Zes8e  ddlmZ G dd dejZe Zddl m!Z! e!"e#d Z$dd  Z%d!d" Z&d#d$ Z'e'  Z(Z)ddl*Z*e*+ Z,esdd%l-m.Z.m/Z/ e. Z,e%  dd&l0m1Z1 d'd( Z2d)d*d+d,d-d.d/d(d0d1g
Z3dd2l4m5Z6 xre7 D ]hZ8e89d3r&e8:d3s
e8e3ks
e8d d4krhe;e< e8 e6rhe< e8 j=9e=d s
e< e8= q
W [8[6dS )6z
Astropy is a package intended to contain core functionality and some
common tools needed for performing astronomy and astrophysics research with
Python. It also provides an index for other astronomy packages and tools for
managing them.
    N)warnz3.5z1.13.0z2.3.0c               @   s   e Zd ZdS )UnsupportedPythonErrorN)__name__
__module____qualname__ r   r   /lib/python3.7/site-packages/astropy/__init__.pyr      s   r   c             c   s   | ]}t |V  qd S )N)int).0valr   r   r   	<genexpr>   s    r   .z$Astropy does not support Python < {}c             C   s\   | dkr"t jt jtt j} nt j| r:t j| } t j| }t jt j|dS )zs
    Returns whether the source for this module is directly in an astropy
    source distribution or checkout.
    Nz.astropy-root)	ospathjoindirname__file__pardirisfileabspathexists)r   Z
source_dirr   r   r   _is_astropy_source   s    	r   c              C   sB   t jd} | sdS t| ddo@tj| jddko@t	| jS )zk
    Returns whether we are currently being imported in the context of running
    Astropy's setup.py.
    __main__Fr   cozsetup.py)
sysmodulesgetgetattrr   r   basenamer   rstripr   )Zmain_modr   r   r   _is_astropy_setup0   s    r    )version_info   )version )githashdevz"http://docs.astropy.org/en/latest/zhttp://docs.astropy.org/en/{0}/c              C   sV   d} yddl }W n tk
r$   Y nX ddlm} ||t} | sRdt}t||S )zX
    Check that Numpy is installed and it is of the minimum version we
    require.
    Fr   Nr"   )
minversionz;Numpy version {0} or later must be installed to use Astropy)numpyImportErrorutilsr'   __minimum_numpy_version__format)Zrequirement_metr(   r'   msgr   r   r   _check_numpy_   s    
r.   )configc               @   s^   e Zd ZdZeddZejejdkdddgdZ	ejd	d
ddgdZ
ejd	dddgdZd	S )Confz1
    Configuration parameters for `astropy`.
    Fz`When True, use Unicode characters when outputting values, and displaying widgets at the console.Zwin32zGWhen True, use ANSI color escape sequences when writing to the console.zastropy.utils.console.USE_COLORzastropy.logger.USE_COLOR)aliasesNzMaximum number of lines in the display of pretty-printed objects. If not provided, try to determine automatically from the terminal size.  Negative numbers mean no limit.zinteger(default=None)zastropy.table.pprint.max_lines)ZdescriptionZcfgtyper1   zMaximum number of characters per line in the display of pretty-printed objects.  If not provided, try to determine automatically from the terminal size. Negative numbers mean no limit.zastropy.table.pprint.max_width)r   r   r   __doc___configZ
ConfigItemZunicode_outputr   platformZ	use_colorZ	max_linesZ	max_widthr   r   r   r   r0      s$   
r0   )
TestRunnerc              C   s   ddl m}  dd }yddlm} W nj tk
r   t rtd y
t  W q t	k
r } z|d t
|tst W d d }~X Y qX n Y nX tjt}y| jt| W nD | jjk
r } z"|jd d	 }t| j| W d d }~X Y nX d S )
Nr"   )r/   c             S   sB   t |  t  x$ttjD ]}|drtj|= qW tdd S )Nzastropy.Zastropy)logerror_teardown_loglistr   r   
startswithr)   )messagekeyr   r   r   _rollback_import   s    

z-_initialize_astropy.<locals>._rollback_import)	_compilerzYou appear to be trying to import astropy from within a source checkout without building the extension modules first.  Attempting to (re)build extension modules:a  An error occurred while attempting to rebuild the extension modules.  Please try manually running `./setup.py develop` or `./setup.py build_ext --inplace` to see what the issue was.  Extension modules must be successfully compiled and importable in order to import astropy.r   zT Cannot install default profile. If you are importing from source, this is expected.)r$   r/   r*   r>   r)   r   r6   Zwarning_rebuild_extensionsBaseException
isinstance	Exceptionr   r   r   r   ZconfigurationZupdate_default_config__package__Z ConfigurationDefaultMissingErrorargsr   Z"ConfigurationDefaultMissingWarning)r/   r=   r>   excZ
config_direZwmsgr   r   r   _initialize_astropy   s*    

	
rG   c           	   C   s&  dd l } dd l}ddlm} ttjd}t }ttj	
tj	ttj zV| jtjdddg||d}|d	*}x"| d krt| |d
 qvW W d Q R X W d t| |  X |jdkrtd|jyddlma W n tk
r   Y nX yddlma W n tk
r    Y nX d S )Nr   r"   )Spinnerwzsetup.pyZ	build_extz	--inplace)stdoutstderrzRebuilding extension modulesg?zRunning setup.py build_ext --inplace failed with error code {0}: try rerunning this command manually to check what the error was.)r#   )r%   )
subprocesstimeZutils.consolerH   openr   devnullgetcwdchdirr   r   r   r   r   Popenr   
executableZpollnextZsleepclose
returncodeOSErrorr,   r#   __version__r)   r%   __githash__)rL   rM   rH   rO   Zold_cwdZspZspinnerr   r   r   r?      s6    




r?   c           	   C   sd   t jt jtd} t| d:}| ddd  }t|dkrHdS d	|d }W d Q R X |S )NZCITATIONrz@ARTICLEr"   r   r$   z@ARTICLE{0})
r   r   r   r   r   rN   readsplitlenr,   )Zcitation_fileZcitationZrefsZbibtexreferencer   r   r   _get_bibtex  s     r^   )	_init_logr8   )find_api_pagec             C   sP   ddl m} ddl}t}d|kr&d}nd| }d||d| i}|| dS )	z
    Search the online Astropy documentation for the given query.
    Opens the results in the default web browser.  Requires an active
    Internet connection.

    Parameters
    ----------
    query : str
        The search query.
    r   )	urlencodeNr&   Zlatestvz.http://docs.astropy.org/en/{0}/search.html?{1}q)Zurllib.parsera   
webbrowserrX   r,   rN   )Zqueryra   rd   r#   Zurlr   r   r   online_help'  s    re   rX   rY   r+   
__bibtex__testr6   r`   online_docs_rootconf)
ModuleType___)N)>r2   r   r   warningsr   Z__minimum_python_version__r+   Z__minimum_asdf_version__rB   r   r!   tupler\   r,   r   r    Z_ASTROPY_SETUP_	NameErrorbuiltinsr#   rX   r)   r%   rY   rh   r.   r$   r/   r3   ZConfigNamespacer0   ri   Ztests.runnerr5   Zmake_test_runner_in__path__rg   rG   r?   r^   Z__citation__rf   ZloggingZ	getLoggerr6   Zloggerr_   r8   Z
utils.miscr`   re   Z__dir_inc__typesrj   Z__module_type__dirZvarnamer:   endswithrA   localsr   r   r   r   r   <module>   sx   




9,



