
@K7]c           @` s   d  Z  d d l m Z m Z m Z d d l Z d d l Z d d l m Z d d l	 m
 Z
 m Z m Z m Z d d l m Z m Z m Z m Z m Z m Z m Z m Z m Z 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 Z d d l Z d d l  Z  y d d l  m! Z" Wn! e# k
 rId d l  m" Z" n Xd 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/ m0 Z0 d d l1 m2 Z2 m3 Z3 d d l4 m5 Z5 m6 Z6 d Z7 d Z8 d Z9 d Z: d Z; d Z< d Z= d Z> d Z? d Z@ d d d d d d d d  d! d" d# d$ d% d& d' d( d) d* d+ d, g ZA d- d. d/ d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d: f ZB d; d< d= d> d? d@ dA dB dC dD dE dF dG dH dI f ZC e jD dJ  ZE i dK dL 6dM dN 6dO dP 6dQ dR 6dS dT 6dU dV 6ZF dW   ZG dX   ZH dY   ZI dZ   ZJ d[   ZK d\   ZL d]   ZM d^   ZN d_   ZO eP d`  ZQ eP da  ZR eS db  ZT dc   ZU dd   ZV de   ZW df   ZX dg dh eY eY eY eY eS eP eS dh di eY eS dj eS eY eY dk  ZZ dl   Z[ f  dm  Z\ f  dn  Z] do   Z^ dp   Z_ d S(q   s6   
Tools for converting Cran packages to conda recipes.
i    (   t   absolute_importt   divisiont   print_functionN(   t   chain(   t   makedirst   listdirt   sept   environ(
   t   basenamet   commonprefixt   existst   isabst   isdirt   isfilet   joint   normpatht   realpatht   relpath(   t   CSafeDumper(   t
   SafeDumper(   t   sourcet   metadata(   t   get_or_merge_config(   t	   text_typet	   iteritemst   TemporaryDirectoryt   cc_conda_build(   t   allowed_license_familiest   guess_license_family(   t   rm_rft   ensure_list(   t   get_package_variantst   DEFAULT_VARIANTSsQ     {archive_keys}
  {git_url_key} {git_url}
  {git_tag_key} {git_tag}
  {patches}
s*     url: {cranurl}{sel}
  {hash_entry}{sel}
s+   {{% set version = '{cran_version}' %}}{sel}sV  {version_source}
{version_binary1}
{version_binary2}

{{% set posix = 'm2-' if win else '' %}}
{{% set native = 'm2w64-' if win else '' %}}

package:
  name: {packagename}
  version: {{{{ version|replace("-", "_") }}}}

source:
{source}
{binary1}
{binary2}

build:
  merge_build_host: True{sel_src_and_win}
  # If this is a new build for the same version, increment the build number.
  number: {build_number}
  {noarch_generic}

  # This is required to make R link correctly on Linux.
  rpaths:
    - lib/R/lib/
    - lib/
  {script_env}
{suggests}
requirements:
  build:{build_depends}

  host:{host_depends}

  run:{run_depends}

test:
  commands:
    # You can put additional test commands to be run here.
    - $R -e "library('{cran_packagename}')"           # [not win]
    - "\"%R%\" -e \"library('{cran_packagename}')\""  # [win]

  # You can also put a file called run_test.py, run_test.sh, or run_test.bat
  # in the recipe that will be run at test time.

  # requires:
    # Put any additional test requirements here.

about:
  {home_comment}home:{homeurl}
  license: {license}
  {summary_comment}summary:{summary}
  license_family: {license_family}
  {license_file}

{extra_recipe_maintainers}

# The original CRAN metadata for this package was:

{cran_metadata}

# See
# https://docs.conda.io/projects/conda-build for
# more information about meta.yaml

s'  #!/bin/bash

# 'Autobrew' is being used by more and more packages these days
# to grab static libraries from Homebrew bottles. These bottles
# are fetched via Homebrew's --force-bottle option which grabs
# a bottle for the build machine which may not be macOS 10.9.
# Also, we want to use conda packages (and shared libraries) for
# these 'system' dependencies. See:
# https://github.com/jeroen/autobrew/issues/3
export DISABLE_AUTOBREW=1

# R refuses to build packages that mark themselves as Priority: Recommended
mv DESCRIPTION DESCRIPTION.old
grep -va '^Priority: ' DESCRIPTION.old > DESCRIPTION
$R CMD INSTALL --build .

# Add more build steps here, if they are necessary.

# See
# https://docs.conda.io/projects/conda-build
# for a list of environment variables that are set during the build process.
s
  #!/bin/bash

if {source_pf_bash}; then
  export DISABLE_AUTOBREW=1
  mv DESCRIPTION DESCRIPTION.old
  grep -v '^Priority: ' DESCRIPTION.old > DESCRIPTION
  $R CMD INSTALL --build .
else
  mkdir -p $PREFIX/lib/R/library/{cran_packagename}
  mv * $PREFIX/lib/R/library/{cran_packagename}

  if [[ $target_platform == osx-64 ]]; then
    pushd $PREFIX
      for libdir in lib/R/lib lib/R/modules lib/R/library lib/R/bin/exec sysroot/usr/lib; do
        pushd $libdir || exit 1
          for SHARED_LIB in $(find . -type f -iname "*.dylib" -or -iname "*.so" -or -iname "R"); do
            echo "fixing SHARED_LIB $SHARED_LIB"
            install_name_tool -change /Library/Frameworks/R.framework/Versions/3.5.0-MRO/Resources/lib/libR.dylib "$PREFIX"/lib/R/lib/libR.dylib $SHARED_LIB || true
            install_name_tool -change /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libR.dylib "$PREFIX"/lib/R/lib/libR.dylib $SHARED_LIB || true
            install_name_tool -change /usr/local/clang4/lib/libomp.dylib "$PREFIX"/lib/libomp.dylib $SHARED_LIB || true
            install_name_tool -change /usr/local/gfortran/lib/libgfortran.3.dylib "$PREFIX"/lib/libgfortran.3.dylib $SHARED_LIB || true
            install_name_tool -change /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libquadmath.0.dylib "$PREFIX"/lib/libquadmath.0.dylib $SHARED_LIB || true
            install_name_tool -change /usr/local/gfortran/lib/libquadmath.0.dylib "$PREFIX"/lib/libquadmath.0.dylib $SHARED_LIB || true
            install_name_tool -change /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libgfortran.3.dylib "$PREFIX"/lib/libgfortran.3.dylib $SHARED_LIB || true
            install_name_tool -change /usr/lib/libgcc_s.1.dylib "$PREFIX"/lib/libgcc_s.1.dylib $SHARED_LIB || true
            install_name_tool -change /usr/lib/libiconv.2.dylib "$PREFIX"/sysroot/usr/lib/libiconv.2.dylib $SHARED_LIB || true
            install_name_tool -change /usr/lib/libncurses.5.4.dylib "$PREFIX"/sysroot/usr/lib/libncurses.5.4.dylib $SHARED_LIB || true
            install_name_tool -change /usr/lib/libicucore.A.dylib "$PREFIX"/sysroot/usr/lib/libicucore.A.dylib $SHARED_LIB || true
            install_name_tool -change /usr/lib/libexpat.1.dylib "$PREFIX"/lib/libexpat.1.dylib $SHARED_LIB || true
            install_name_tool -change /usr/lib/libcurl.4.dylib "$PREFIX"/lib/libcurl.4.dylib $SHARED_LIB || true
            install_name_tool -change /usr/lib/libc++.1.dylib "$PREFIX"/lib/libc++.1.dylib $SHARED_LIB || true
            install_name_tool -change /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libc++.1.dylib "$PREFIX"/lib/libc++.1.dylib $SHARED_LIB || true
          done
        popd
      done
    popd
  fi
fi
so   #!/bin/bash
mkdir -p $PREFIX/lib/R/library/{cran_packagename}
mv * $PREFIX/lib/R/library/{cran_packagename}
fi
s9   "%R%" CMD INSTALL --build .
IF %ERRORLEVEL% NEQ 0 exit 1
s  if "%target_platform%" == "win-64" goto skip_source_build
"%R%" CMD INSTALL --build .
IF %ERRORLEVEL% NEQ 0 exit 1
exit 0
:skip_source_build
mkdir %PREFIX%\lib\R\library
robocopy /E . "%PREFIX%\lib\R\library\{cran_packagename}"
if %ERRORLEVEL% NEQ 1 exit 1
exit 0
s   
    - t   Sitet   Archst   Dependst   Enhancest   Importst   Licenset   License_is_FOSSt   License_restricts_uset	   LinkingTot   MD5sumt   NeedsCompilationt   OS_typet   Packaget   Patht   Priorityt   Suggestst   Versiont   Titlet   Authort
   Maintainert   baset   compilert   datasetst   graphicst	   grDevicest   gridt   methodst   parallelt   splinest   statst   stats4t   tcltkt   toolst   utilst   MASSt   latticet   Matrixt   nlmet   survivalt   boott   clustert	   codetoolst   foreignt
   KernSmootht   rpartt   classt   nnett   spatialt   mgcvs   ^\s*(?P<name>[a-zA-Z0-9.+\-]{1,})(\s*\(\s*(?P<relop>[>=<]+)\s*(?P<version>[0-9a-zA-Z:\-+~.]+)\s*\))?(\s*\[(?P<archs>[\s!\w\-]+)\])?\s*$s
   =~ linux.*t   linuxs   == linux-32t   linux32s   == linux-64t   linux64s	   == win-32t   win32s	   == win-64t   win64s	   == osx-64t   osxc         C` s   t  S(   N(   t   True(   t   package_name(    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pyt   package_exists   s    c         C` s  |  j  d d d d t j } | j d d d d d | j d	 d d
 d d | j d d d d d | j d d d | j d d d | j d d d | j d d d d d | j d d d | j d d d d d | j d d d  | j d! d" dF d d# d d( | j d) d d d* d+ d d, | j d- d d d d. | j d/ d d d d0 | j d1 d d2 d* d3 d d4 | j d5 d d2 d* d6 d d7 | j d8 d d d d9 | j d: d d; d" dG d d' d dA | j dB dC d t j dD d   d dE d  S(H   Nt   crant   helps   
    Create recipe skeleton for packages hosted on the Comprehensive R Archive
    Network (CRAN) (cran.r-project.org).
        t   formatter_classt   packagest   nargst   +s-   CRAN packages to create recipe skeletons for.s   --output-dirs5   Directory to write recipes to (default: %(default)s).t   defaultt   .s   --output-suffixsL   Suffix to add to recipe dir, can contain other dirs (eg: -feedstock/recipe).t    s   --add-maintainers@   Add this github username as a maintainer if not already present.s	   --versions(   Version to use. Applies to all packages.s	   --git-tags"   Git tag to use for GitHub recipes.s
   --all-urlst   actiont
   store_trues`   Look at all URLs, not just source URLs. Use this if it can't
                find the right URL.s
   --cran-urls+   URL to use for as source package repositorys
   --r-interps   r-bases   Declare R interpreter packages   --use-binaries-versU   Repackage binaries from version provided by argument instead of building from source.s   --use-when-no-binaryt   choicest   srct   olds   src-olds   old-srct   errors  Sometimes binaries are not available at the correct version for
                a given platform (macOS). You can use this flag to specify what
                fallback to take, either compiling from source or using an older
                binary or trying one then the other.s   --use-noarch-generict   destt   use_noarch_generics?   Mark packages that do not need compilation as `noarch: generic`s   --use-rtools-wins/   Use Rtools when building from source on Windowss   --recursives=   Create recipes for dependencies if they do not already exist.s   --no-recursivet   store_falset	   recursivesC   Don't create recipes for dependencies if they do not already exist.s   --no-archivet   archives&   Don't include an Archive download url.s   --version-compares   Compare the package version of the recipe with the one available
        on CRAN. Exits 1 if a newer version is available and 0 otherwise.s   --update-policyt   stores   skip-up-to-dates   skip-existingt	   overwrites   merge-keep-build-nums   merge-incr-build-nums  Dictates what to do when existing packages are encountered in the
        output directory (set by --output-dir). In the present implementation, the
        merge options avoid overwriting bld.bat and build.sh and only manage copying
        across patches, and the `build/{number,script_env}` fields. When the version
        changes, both merge options reset `build/number` to 0. When the version does
        not change they either keep the old `build/number` or else increase it by one.s   -ms   --variant-config-filest   skeleton_config_yamls}   Variant config file to add.  These yaml files can contain
        keys such as `cran_mirror`.  Only one can be provided here.(   Rg   Rh   s   src-olds   old-srcRi   (   Ri   s   skip-up-to-dates   skip-existingRp   s   merge-keep-build-nums   merge-incr-build-num(   t
   add_parsert   argparset   ArgumentDefaultsHelpFormattert   add_argumentR   t   gett   None(   t   reposR[   (    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pyRr   )  s             	c         C` s   i  } x |  D] } | s q n  yC d | k rI | j  d d  \ } } n | j  d d  \ } } Wn" t k
 r t j d |  n X| | | <q W|  | d <| S(   Ns   : i   t   :s$   Error: Could not parse metadata (%s)t
   orig_lines(   t   splitt
   ValueErrort   syst   exit(   t   linest   dt   linet   kt   v(    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pyt   dict_from_cran_lines  s    
c   	      C` s+  d } d } d } t } t } |  j d  x t |   D] \ } } | j |  r d | j   } | r | su t  | | 7} d |  | <q t } | d } |  | | } t } d |  | <q8 | r8 | s t  | |  | <t } d } d } q8 q8 W| rg  |  D] } | r | ^ q }  n  |  j d  |  S(   sw  
    >>> chunk = [
        'Package: A3',
        'Version: 0.9.2',
        'Depends: R (>= 2.15.0), xtable, pbapply',
        'Suggests: randomForest, e1071',
        'Imports: MASS, R.methodsS3 (>= 1.5.2), R.oo (>= 1.15.8), R.utils (>=',
        '        1.27.1), matrixStats (>= 0.8.12), R.filesets (>= 2.3.0), ',
        '        sampleSelection, scatterplot3d, strucchange, systemfit',
        'License: GPL (>= 2)',
        'NeedsCompilation: no']
    >>> remove_package_line_continuations(chunk)
    ['Package: A3',
     'Version: 0.9.2',
     'Depends: R (>= 2.15.0), xtable, pbapply',
     'Suggests: randomForest, e1071',
     'Imports: MASS, R.methodsS3 (>= 1.5.2), R.oo (>= 1.15.8), R.utils (>= 1.27.1), matrixStats (>= 0.8.12), R.filesets (>= 2.3.0), sampleSelection, scatterplot3d, strucchange, systemfit, rgl,'
     'License: GPL (>= 2)',
     'NeedsCompilation: no']
    t    s   	Rc   i   (   R   s   	N(   Rw   t   Falset   appendt	   enumeratet
   startswitht   lstript   AssertionErrorRX   (	   t   chunkt   continuationt   continued_ixt   continued_linet   had_continuationt   accumulating_continuationst   iR   t   c(    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pyt!   remove_package_line_continuations  s8    


"c         C` s+   t  j |  d t j d d  j d d  S(   s  
    Quote a string for use in YAML.

    We can't just use yaml.dump because it adds ellipses to the end of the
    string, and it in general doesn't handle being placed inside an existing
    document very well.

    Note that this function is NOT general.
    t   Dumpers   
...
Rc   s   
s   
  (   t   yamlt   dumpR   t   replace(   t   string(    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pyt   yaml_quote_string  s    
c         C` sj   g  } d } xN |  j    D]@ } | j   } | d k o@ | d k sS | j |  n  | } q Wd j |  S(   NRc   s   
(   t
   splitlinest   rstripR   R   (   R   R   t	   last_lineR   (    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pyt   clear_whitespace
  s    
c         C` s   |  d | d } | j  |  } y | j   WnB t j j k
 rs } | j j d k rm t j d |  n    n X| j	 } t
 t | j     } | | d <| S(   Ns   /web/packages/s   /DESCRIPTIONi  s   ERROR: %s (404 Not Found)t   orig_description(   Rv   t   raise_for_statust   requestst
   exceptionst	   HTTPErrort   responset   status_codeR}   R~   t   textR   R   R   (   t   cran_urlt   packaget   sessiont   urlt   rt   et   DESCRIPTIONR   (    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pyt   get_package_metadata  s    	
c         C` s   t  j d d d d d d g d t  j d t  j d	 |  j } | j   \ } } | j d
  } | j d
  } | s{ | j r t j d |  n  | j	   j
   } | s t j d  n  t d | d  | d S(   Nt   gits   for-each-refs	   refs/tagss   --sort=-committerdates   --format=%(refname:short)s	   --count=1t   stdoutt   stderrt   cwds   utf-8s   Error: git tag failed (%s)s   Error: no tags founds   Using tag %si(   t
   subprocesst   Popent   PIPEt   work_dirt   communicatet   decodet
   returncodeR}   R~   t   stripR   t   print(   t   configt   pR   R   t   tags(    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pyt   get_latest_git_tag$  s     c           C` s"   t  j d d  j   j   d k S(   s   Gets whether the SSL_NO_VERIFY environment variable is set to 1 or True.

    This provides a workaround for users in some corporate environments where
    MITM style proxies make it difficult to fetch data over HTTPS.
    t   SSL_NO_VERIFYRc   t   1t   true(   R   R   (   R   Rv   R   t   lower(    (    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pyt   _ssl_no_verify:  s    c         C` s   t  j   } t   | _ y d d  l } d d  l } Wn$ t k
 rZ | r t d  q n+ X| j | d | j	 j
 t |  d   } | S(   Ni    sR   Tip: install CacheControl and lockfile (conda packages) to cache the CRAN metadatat   caches
   .web_cache(   R   t   SessionR   t   verifyt   cachecontrolt   cachecontrol.cachest   ImportErrorR   t   CacheControlt   cachest	   FileCacheR   (   t
   output_dirt   verboseR   R   (    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pyt   get_sessionC  s    c         C` s   t  | d | } | r) t d |   n  | j |  d  } | j   | j } g  | j d  D] } t | j    ^ q_ } d   t t	 |  D S(   NR   s   Fetching metadata from %ss   /src/contrib/PACKAGESs   

c         S` s#   i  |  ] } | | d  j     q S(   R-   (   R   (   t   .0R   (    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pys
   <dictcomp>]  s   	 (
   R   R   Rv   R   R   R{   R   R   t   mapR   (   R   R   R   R   R   t   PACKAGESR   t   package_list(    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pyt   get_cran_metadataT  s    
	+c         C` s   g  } y |  j  | g   } Wn g  } n X| s8 | rY | j | j d  d d  n  x- | D]% } | j d j d t d |   q` W| S(   Nt   /iRy   s   {indent}{old_val}t   indentt   old_val(   t	   get_valueR   R{   t   formatt   INDENT(   t   mt   keyt   allow_emptyt   resultt   old_valsR   (    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pyt
   make_arraya  s    
!#c         C` s   d  } t t |  |   r3 t t |  |   } nr t t |  | |   rh t t |  | |   } n= t t |  d | |   r t t |  d | |   } n  | S(   Ns   r-(   Rw   R
   R   R   (   R   t   output_suffixR   R   (    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pyt   existing_recipe_dirn  s     c         C` s"   |  j  |  r |  t |   S|  S(   N(   t   endswitht   len(   R   t   end(    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pyt	   strip_endy  s    c         C` s  t  |  r d St d |  t | d  } t | t  } d | k rZ t | d  } n  t |  j   } t | d  } | r t | |  } n  | j d  r | d } n  | j d  r| j d d	  } t |  } t	 j
 d
 |  j d  j   } t |  | d |  } n t |  rxt | |  f  } | |  k rYt d | |  f   n  | } t |  | d |  } nA d | k r| } t |  | d |  } n t |  | |  } } | ry t j |  }	 Wqd }	 qXn d }	 | }
 | rE|	 rEd | k rE|	 j d d	  } d | k rE| } |	 j d d  }
 qEn  t |  d | |  } t d | | | f  i | d 6| d 6|
 d 6|	 d 6| d 6S(   s  
    Converts `package` (*) into a tuple of:

    pkg_name (without leading 'r-')
    location (in a subdir of output_dir - may not exist - or at GitHub)
    old_git_rev (from existing metadata, so corresponds to the *old* version)
    metadata or None (if a recipe does *not* already exist)

    (*) `package` could be:
    1. A package name beginning (or not) with 'r-'
    2. A GitHub URL
    3. A file:// URL to a tarball
    4. A relative path to a recipe from output_dir
    5. An absolute path to a recipe (fatal unless in the output_dir hierarchy)
    6. Any of the above ending (or not) in sep or '/'

    So this function cleans all that up:

    Some packages may be from GitHub but we'd like the user not to have to worry
    about that on the command-line (for pre-existing recipes). Also, we may want
    to get version information from them (or existing metadata to merge) so lets
    load *all* existing recipes (later we will add or replace this metadata with
    any that we create).
    s   Parsing input package %s:R   s
   github.coms   .gits
   -feedstocks   r-i   s   file://Rc   s	   (.*)_(.*)i   s;   package %s specified with abs path outside of output-dir %ss   source/git_urls   source/git_revs)   .. name: %s location: %s new_location: %ss   pkg-namet   locations   old-git-revs   old-metadatas   new-locationN(   R   Rw   R   R   R   R   R   R   R   t   ret   matcht   groupR   R   R	   t   RuntimeErrorR   t   MetaDataR   R   (   R   R   t   git_tagR   t   pkg_nameR   t   pkg_filenamet   existing_locationt   commpR   t   old_git_revt   git_urlt   new_location(    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pyt   package_to_inputs_dict  s`    !
c         ` s  d d  l   d d l m   d i     f d  } |  d | d } | d } | | |  } x | D] } t |  } | j d  \ } }	 }
 |
 j |  \ }
 }	 }	 | | d	 k r | d	 | j   j |
 | f  qf |
 | f g | d	 | j   <qf Wd  S(
   Ni    (   t   BeautifulSoupRc   c         ` s    j  |  d | } | j r* | j } n
 | j   S  | d  } g  | j d  D]1 } | j  d  j |  rS |  | j  d  ^ qS } | S(   Nt   paramss   html.parsert   at   href(   Rv   t   okR   R   t   find_allR   (   R   t   extR   R   t   response_textt   soupt   nodet   parent(   R   R   (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pyt   get_url_paths  s    	
GR   t   dirR   t   _t   binaries(   R   t   bs4R   R   t
   rpartitionR   t   extend(   R   t   detailsR  R   R   R   R   t   filenamet   pkgR  t   ver(    (   R   R   s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pyt   get_available_binaries  s    

$Rb   Rc   s   r-baseRg   c   g      C` s  | d k rS | d k rS | d k rS | d k rS t  d j |   t j d  n  t |  } t | d | } | s t    } t | |  d } Wd  QXt | j	 d	 t
 d	   d } n  t |   d k r |	 r t d
   n  |
 d k r|  rt d   n  i  } g  } | j d  } t | |  } i i d d 6d d 6d d 6t d 6d 6i d d 6d j |  d 6d d 6| rt n t d 6d 6i d d 6d j |  d 6d d 6| rt n t d 6d 6} xM t |  D]? \ } } t   | d <| d k r| d rt | |  qqWxK |  D]C } t | | | |  } | r"| j i i | d 6| d 6 q"q"Wx' | j   D] \ } } | j |  qvWxi| r| | j   d } | d  } | d }  | od! | k }! | ot |  ot j |  }" | d  }# | d" }$ t  d# j |    |! s*|" rt | j  |! rjt j j  i i | d$ 6d 6d% | }% t! j" |% j# d  |% j$ j% |% j$ j  | r| n	 t& |  }& t' j( d& d' |& g d( t' j) d) t' j) d* | j }' |' j*   \ }( }) |( j+ d+  }( |) j+ d+  }) |' j, r/t j d, |& |) j-   f  n  |( rKt  |( d- t j. n  |) rt  |) d- t j/ qnZ t j j  i i | d. 6d 6d% | }% t! j0 |% j# d  |% j$ j |% j$ j1 | |% j$ j  t2 | j d/  }* t |*  s`t2 | j d0 d/  }+ t2 | j | j3 d  d1 d/  }, t |+  r.|+ }* q`t |,  rC|, }* q`t j d2 | |+ |, f  n  t4 |*   }- t5 |- j6    }. Wd  QXt7 t8 |. j9     }/ |. |/ d3 <|/ d4 j:   } |/ | | <n |  } |  | k rt j d5 |   n  | | j:   d4 } |! r@|" r@t; |  }0 | | j:   j t< | | |0   n  | | j:   }1 | | j:   j i | d6 6d7 | j:   d8 6d9 d: 6d d; 6d9 d< 6d9 d= 6d9 d> 6d? d@ 6d9 dA 6d? dB 6d9 dC 6 | | j:   }/ d9 |/ dD <d9 |/ dE <| r| |/ dF <t= dG   n  |1 dH |/ dI <|/ dI j> dJ dK  |/ dL <|	 rMt j |	 |$ |/ dL   n  g  }2 g  }3 g  }4 d }5 |
 j? dM  r| dN r| dN }% t@ |% dO  }2 t@ |% dP  }3 t@ |% dQ |  }4 |% jA   |/ dL k rtB |% jC dR d   }5 |5 |
 dS k rd n d 7}5 qn  | rfdT j dU tD dV |  }6 |6 |4 k rft |4  sSt@ i  dQ t  }4 n  |4 j |6  qfn  t |4  r|4 d jE   |4 jF d dW  n  d9 j2 |4  |/ dX <d9 j2 |2  |/ d: <d9 j2 |3  |/ dY <|5 |/ d; <d  }7 tH jI |  }8 i  }9 x/t |8  D]!\ } } d9 }: |/ dI | dI <|/ dL | dL <| d k r>	t n) | | d k og	|/ dI | d | d k }; |; sN
| d k r	t  dZ  t j d  qN
| j? d  rN
| | d k r	| jJ d  r	t }; t | d <qq	t  d[  t j d  n  | d | d1 d | d\ <| d | d1 d | dL <| dL j> dK dJ  | dI <t }; qN
n  d  }7 tK jL   }< | d r|; r|" r
tM |  }= tN | |$  }: |: }> }? | }7 n |! s
| d k rd] j | | dI | d  }@ d^ j |  | d }= d_ j | d  }: | d` j | d  }> |> |@ }? t  da j | |?   y8 t! jO | j1 d9 i |? d. 6| dJ |@ db 6 \ }7 }A Wqt  dc j |?   t j d  qXn  i  }B | d |B d <| dI |B dI <| dL |B dL <|7 r:|< j t4 |7 dd  j6    |? | d\ <|= |B de <|: |B df <|> |B dg <dh j |< jP    |B di <|7 |B dj <n  | d k r|! rd9 |B dk <dl |B dm <dn |B do <dp }C |C |B di <d9 |B de <d9 |B d\ <|# |B d$ <|& |B dq <d9 |B dr <qds |B dk <d9 |B dm <d9 |B do <dt |: |= |B d\ <d9 |B d$ <d9 |B dq <n | d\ |B d\ <|/ d: |B d: <|B |9 | <qqWdu dv d d g }D |D }E d }F xq t |9  D]c \ } } | d k rxH t |  D] \ }G }H |H |/ |G <qtWqO| d }I |E jQ |I  |F d 7}F qOW|E |D k rd9 }J dw }K dx }L nY dy dz j2 |E  d{ }J dy dz j2 d|   |E D  d{ }K dy dz j2 d}   |E D  d{ }L |J |/ d~ <|K |/ d <|L |/ d <|E |/ d <d |9 k r#|9 d }B |J |B d <|B de }= df |B k r|B df }: | r|" rtD |: |B d\ <qtD |: |= |J tD |: d j |  |= |J |B d\ <qdt |: |= |J |B d\ <n  |! s#d j |B   |B dr <q#n  d j2 g  |1 d D] }M |M r4d |M ^ q4 |/ d <d }F d9 |/ d <|/ d <x t |9  D] \ } } | d k rtR j |   |/ d <tS j |   |/ d <q|dy | d d{ | d <tT j |   |/ d tU |F  <tS j |   |/ d tU |F  <|F d 7}F q|W|1 j	 d d  |/ d <tV |/ d tW  |/ d <tX |/ d  |/ d <d |1 k r{|/ d c d 7<n  |1 j	 d  d k r|/ d c d 7<n  d |1 k rd9 |/ d@ <dt tY |1 d  |/ dA <n9 d9 |/ d@ <|! rd j |  |/ dA <n d j |  |/ dA <| s,|1 j	 d d  d k r9d9 |/ d <n
 d |/ d <d |1 k rtd9 |/ dB <dt tY |1 d  |/ dC <n  d |1 k rd |1 d |/ d <n
 d9 |/ d <g  |1 j	 d d9  j3 d  D] }N |N j-   r|N j-   ^ q}O g  |1 j	 d d9  j3 d  D] }N |N j-   r|N j-   ^ q}P g  |1 j	 d d9  j3 d  D] }N |N j-   r;|N j-   ^ q;}Q i  }R tZ   }S xt[ t\ |P |O |Q   D] }N t] j^ |N  }T |T st j d | |N f  n  |T j_ d  }U |U |S k rqn  |S j` |U  |T j_ d  }V |T j_ d  pd9 }W |T j_ dF  p d9 }X |X j> dJ dK  }X |W sH|X sHta  |V rht j d | |N f  n  d j d |W dF |X  |R |U <qWd |R k rd9 |R d <n  |! }Y |1 j	 d d  d k rt j4 |9 d dj  &}Z tb g  |Z D] }- |- jc j:   jJ d  ^ q }[ |[ rt n. tb g  |Z D] }- |- jc j:   jJ d  ^ q  }\ tb g  |Z D] }- |- jc j:   jJ d  ^ qQ }] tb g  |Z D] }- |- jc j:   jJ d  ^ q }^ tb |^ |[ |] |\ f  rt n. tb g  |Z D] }- |- jc j:   jJ d  ^ q }_ Wd  QXn t }\ }] }[ }^ }_ d |R k s/d |R k r8t }] n  |] rGt }\ n  xd d d g D]}` g  }a |` d k r&|\ r|a j d j dU tD d |L   |a j d j dU tD d |K   n  |] r|a j d j dU tD d |L   |a j d j dU tD d |K   n  |[ rD|a j d j dU tD d |L   |a j d j dU tD d |K   n  | rt }\ }] }[ }^ }_ |a j d j dU tD d |K   n  |^ s|_ s|Y r|a j d j dU tD d |K   n  |Y r|a j d j dU tD   n  |^ r|a j d j dU tD d |K   |a j d j dU tD d |K   |a j d j dU tD d |J   |a j d j dU tD d |L   |a j d j dU tD d |K   |a j d j dU tD   n  |_ r|a j d j dU tD d |J   |^ s|a j d j dU tD d |K   n  |a j d j dU tD d |K   n  |a j d j dU tD d |K   nC |` d k ri|\ sD|] sD|[ ri|a j d j dU tD d |K   qin  |` d k s|` d k rx\td |R  D]K}U |U te k rqn  |U d k r|a jF d d j dU tD d |   qd7 |U j:   }b |R |U r|a j d j d |b dF |R |U dU tD   n |a j d j d |b dU tD   | r|U j:   }c |c | k rt | | | |c  } |c | d k sta d |U | d f   |c | k sta  | j i i | d 6|c 6 | j |c  qqqWn  d9 j2 |a  |/ d |` <qWWqWx| D]} | | }/ |/ d d" }$ tf |$  rr|	 rr|
 d k rVtg d |$   q|
 d k rt |$  qnI |
 d k rth | |/ d dN  rqn  |
 d k r|/ d dN rqn  |/ d }d d   t |/  D }/ y ti t2 |$   Wn n Xt  d | j:    t4 t2 |$ d  d  # }- |- jj t5 tk j |/     Wd  QXtf t2 |$ d   sl|
 d k r;t4 t2 |$ d  d   }- |d tl k r|- jj tm j |/    n |d g  k r|- jj tn j |/    na g  |d D] } to | ^ q}e d j2 g  |e D] }N d |N d ^ q |/ d <|- jj tp j |/    Wd  QXn  tf t2 |$ d   s]|
 d k rt4 t2 |$ d  d  j }- t g  |d D] }f |f j? d  r|f ^ q d k r|- jj tq j |/    n |- jj tr j |/    Wd  QXqqWd  S(   NRi   Rg   Rh   s   old-srcs2   ERROR: --use_when_no_binary={} not yet implementedi   t   variant_config_filesi    t   cran_mirrors7   --version-compare only works with one package at a times%   At least one package must be suppliedR   s   {others}t   selectors   src/contrib/R  s   .tar.gzR   t   use_thisR   RV   s   bin/windows/contrib/{}/s   .zips   win-64RW   s!   bin/macosx/el-capitan/contrib/{}/s   .tgzs   osx-64R  t   inputss   pkg-nameR   s
   github.coms   new-locations   Making/refreshing recipe for {}R   R   R   t   checkoutR   R   R   s   utf-8s2   Error: 'git checkout %s' failed (%s).
Invalid tag?t   fileR   R   R  isJ   %s does not appear to be a valid R package (no DESCRIPTION file in %s, %s)R   R-   s   Package %s not foundt   cran_packagenames   r-t   packagenameRc   t   patchest   build_numbert   build_dependst   host_dependst   run_dependst   #t   home_commentt   homeurlt   summary_commentt   summaryt   binary1t   binary2t   versions2   Package versions from CRAN are not yet implementedR1   t   cran_versiont   -R  t   conda_versiont   merges   old-metadatas   source/patchess   build/script_envs   extra/recipe-maintainerss   build/numbers   merge-incr-build-nums   {indent}{add_maintainer}R   t   add_maintainers	   extra:
  t   extra_recipe_maintainerst
   script_envs=   ERROR: --use-when-no-binary is error (and there is no binary)sf   ERROR: No binary nor old binary found (maybe pass --use-when-no-binary=old-src to fallback to source?)t   cranurls   {}_{}{}s   {}_{{{{ version }}}}s   {{{{ cran_mirror }}}}/{}s   /{}s   Downloading {} from {}t   fnsH   logic error, file {} should exist, we found it in a dir listing earlier.t   rbR
  t   contrib_urlt   contrib_url_rendereds
   sha256: {}t
   hash_entryt   cached_patht   url_keys   git_url:t   git_url_keys   git_tag:t   git_tag_keys=   # You can add a hash for the file here, (md5, sha1 or sha256)R   t   archive_keyss   url:R   RR   RU   s	     # [win]s     # [not win]s     # [s    or t   ]c         s` s$   |  ] } | j  d   r | Vq d S(   t   winN(   R   (   R   t   fs(    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pys	   <genexpr>  s    c         s` s$   |  ] } | j  d   s | Vq d S(   R7  N(   R   (   R   R8  (    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pys	   <genexpr>  s    t   sel_srct   sel_src_and_wint   sel_src_not_wint   from_sourcet   sels   Archive/{}/s/   {url_key}{sel}    {cranurl}
  {hash_entry}{sel}s   
Rz   s   # %st   cran_metadatat   version_binary1t   version_binary2t   version_sourcet   binaryt   version_binaryR&   Rw   t   licenset   license_familyt   license_fileR'   s    (FOSS)R(   t   yess    (Restricts use)t   URLs    {}s&    https://CRAN.R-project.org/package={}R+   t   not   noarch_generics   noarch: generict   DescriptionR0   s   # Suggests: %st   suggestsR#   t   ,R%   R)   s1   Could not parse version from dependency of %s: %st   namet   archst   relops@   Don't know how to handle archs from dependency of package %s: %ss   {relop}{version}t   Rs   .fs   .f90s   .f77s   .cs   .cxxs   .cpps   .ccs   .c++s
   /configures	   /makefiles	   /makevarst   Rcppt   RcppArmadillot   buildt   hostt   runs0   {indent}{{{{ compiler('c') }}}}            {sel}s0   {indent}{{{{ compiler('m2w64_c') }}}}      {sel}s0   {indent}{{{{ compiler('cxx') }}}}          {sel}s0   {indent}{{{{ compiler('m2w64_cxx') }}}}    {sel}s0   {indent}{{{{ compiler('fortran') }}}}      {sel}s0   {indent}{{{{ compiler('m2w64_fortran') }}}}{sel}s&   {indent}rtools                   {sel}s*   {indent}{{{{posix}}}}filesystem      {sel}s   {indent}{{{{posix}}}}gits*   {indent}{{{{posix}}}}sed             {sel}s*   {indent}{{{{posix}}}}grep            {sel}s*   {indent}{{{{posix}}}}autoconf        {sel}s*   {indent}{{{{posix}}}}automake        {sel}s*   {indent}{{{{posix}}}}automake-wrapper{sel}s   {indent}{{{{posix}}}}pkg-configs*   {indent}{{{{posix}}}}make            {sel}s*   {indent}{{{{posix}}}}coreutils       {sel}s*   {indent}{{{{posix}}}}zip             {sel}s*   {indent}{{{{native}}}}gcc-libs       {sel}s   {indent}{r_name}t   r_names   {indent}{name} {version}s   {indent}{name}s%   name %s != inputs_dict['pkg-name'] %ss
   %s_dependss=   directory already exists (and --update-policy is 'error'): %sRp   s   skip-up-to-dates   skip-existingc         S` sC   i  |  ]9 \ } } t  j d  t |   j d d  j   |  q S(   t   NFKDt   asciit   ignore(   t   unicodedatat	   normalizeR   t   encodeR   (   R   R   R   (    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pys
   <dictcomp>  s   	s   Writing recipe for %ss	   meta.yamlt   ws   build.shs    || s   [[ $target_platform s    ]]t   source_pf_bashs   bld.batR7  i   (   s   .fs   .f90s   .f77(   s   .cxxs   .cpps   .ccs   .c++(   s	   /makefiles	   /makevars(s   R   R   R}   R~   R   R   R   R   R   Rv   R    R   R|   R   R   RX   R   R   t   dictR  R   t   updatet   itemsR   t   popR   t   tarfilet
   is_tarfileR   R   R   R   t   fromdictR   t
   git_sourcet   get_sectionR   t	   git_cacheR   R   R   R   R   R   R   R   R   R   t   unpackt	   src_cacheR   R{   t   openR   t   readR   R   R   R   R   R   t   NotImplementedErrorR   R   R   R#  t   intR   R   t   sortt   insertRw   t   copyt   deepcopyR   t   hashlibt   sha256R   R   t   download_to_cachet	   hexdigestt   removet   SOURCE_METAt   VERSION_METAt   BINARY_METAt   strR   R   t   get_license_fileR   t   sett   listR   t   VERSION_DEPENDENCY_REGEXR   R   t   addR   t   anyRN  t   sortedt   R_BASE_PACKAGE_NAMESR
   R   t
   up_to_dateR   t   writet	   CRAN_METAt   allt   CRAN_BUILD_SH_SOURCEt   CRAN_BUILD_SH_BINARYt    target_platform_bash_test_by_selt   CRAN_BUILD_SH_MIXEDt   CRAN_BLD_BAT_SOURCEt   CRAN_BLD_BAT_MIXED(g   t   in_packagesR   R   R(  R#  R   R   Rm   Rn   t   version_comparet   update_policyt   r_interpt   use_binaries_verRk   t   use_when_no_binaryt   use_rtools_winR   R  t   tt   _variantt   package_dictsR   R>  t   cran_layout_templatet   archive_typet   archive_detailsR   t   inputs_dictRY   t   package_dictR  R   R   t   is_github_urlRe  R   t   dir_pathR   t   new_git_tagR   R   R   R   t   sub_description_pkgt   sub_description_namet   ft   description_textR   R   t   cran_packageR  R*  R)  R  t   new_maintainerR1  t   cran_layoutt	   availableR.  t   avaliable_artefactRu  R
  R/  t   package_urlt   filename_renderedR  t   available_detailst   hash_msgt   _allR<  t	   binary_idR   R   R=  R9  R:  R;  t   lt   st   dependst   importst   linkst   dep_dictt   seenR   RN  RO  RP  R  t   need_gitt   tft   need_ft   need_ct   need_cxxt   need_autotoolst	   need_maket   dep_typet   depst
   conda_namet
   lower_namet   from_sourcest   tpbtR8  (    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pyt   skeletonize  s   #


&	

!

&(		&$"			




"	




	
	)	

















	!!







6	+




444			 11+14		
%

	

""	%"4c         C` sY   t  j |   } | j   } t |   } t d | | f  t d | | f  | | k S(   Ns#   Local recipe for %s has version %s.s!   The version on CRAN for %s is %s.(   R   R   R#  R   R   (   t
   recipe_dirt   newest_conda_versionR   t   local_versionR   (    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pyR  9  s    c         C` s   g  } t  |   } x | D] } | j d  s t |  rB q n  | d } | rq | | k pg | | k rq q n  | | k r t d |  q n  t t |  |  | | d j d d   t d |  | j |  q W| S(   Ns   r-i   s   Skipping %s, not found on CRANR1   R%  R  s   Updating %s(   R   R   R   R   R  R   R   R   (   R   R>  R^   t	   to_updatet   recipest   recipet   recipe_name(    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pyt   get_outdatedE  s     
c         C` s   g  } t  |   } xm | D]e } | j d  s t |  rB q n  | d } | rq | | k pg | | k rq q n  | j |  q W| S(   Ns   r-i   (   R   R   R   R   (   R   R>  R^   t   existingR  R  R  (    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pyt   get_existing^  s    
c         C` st   | \ } } } } | d } | s& t  Sd | k r6 t  S| |  k rF t  S| j   |  | d j d d  k rp t  St S(   Ni   s
   github.comR1   R%  R  (   R   R#  R   RX   (   R>  R   t
   r_pkg_nameR   R   R   t   cran_pkg_name(    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pyR  p  s    
&c         C` s   i d d d d g d 6d d g d 6d	 d
 d g d 6d d d d d g d 6d d g d 6d d g d 6d d d d g d 6} d } xH | j    D]4 } |  | | k r | j d | | d   } Pq q Wd! } | S("   s  
    Most R packages on CRAN do not include a license file. Instead, to avoid
    duplication, R base ships with common software licenses:

    complete: AGPL-3, Artistic-2.0, GPL-2, GPL-3, LGPL-2, LGPL-2.1, LGPL-3
    template: BSD_2_clause BSD_3_clause, MIT

    The complete licenses can be included in conda binaries by pointing to the
    license file shipped with R base. The template files are more complicated
    because they would need to be combined with the license information provided
    by the package authors (e.g. copyright owners and date).

    This function returns the path to the license file for the unambiguous
    cases. Any time an R package refers to one of the templates or a custom
    license file (e.g. 'GPL-2 | file LICENSE'), an empty string is returned.
    s   AGPL-3s   AGPL (>= 3)t   AGPLs!   GNU Affero General Public Licenset   agpl3s   Artistic-2.0s   Artistic License 2.0t	   artistic2s   GPL-2s
   GPL (>= 2)s!   GNU General Public License (>= 2)t   gpl2s   GPL-3s
   GPL (>= 3)s!   GNU General Public License (>= 3)t   GPLs   GNU General Public Licenset   gpl3s   LGPL-2s   LGPL (>= 2)t   lgpl2s   LGPL-2.1s   LGPL (>= 2.1)t   lgpl21s   LGPL-3s   LGPL (>= 3)t   LGPLs!   GNU Lesser General Public Licenset   lgpl3sM   license_file: '{{{{ environ["PREFIX"] }}}}/lib/R/share/licenses/{license_id}'t
   license_idi    Rc   (   t   keysR   (   t   license_textt	   d_licenset   license_file_templateR  RF  (    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pyR}    s"    
		(`   t   __doc__t
   __future__R    R   R   Rs   Rr  t	   itertoolsR   t   osR   R   R   R   t   os.pathR   R	   R
   R   R   R   R   R   R   R   R   R   R}   Rt  R   Rd  R[  R   R   R   R   t   conda_buildR   R   t   conda_build.configR   t   conda_build.conda_interfaceR   R   R   R   t   conda_build.license_familyR   R   t   conda_build.utilsR   R   t   conda_build.variantsR   R    Ry  R{  Rz  R  R  R  R  R  R  R   t	   CRAN_KEYSR  t   R_RECOMMENDED_PACKAGE_NAMESt   compileR  R  RZ   Rr   R   R   R   R   R   R   R   RX   R   R   R   R   R   R   R   R  Rw   R  R  R  R  R  R}  (    (    (    s9   lib/python2.7/site-packages/conda_build/skeletons/cran.pyt   <module>   s   "F"C)				

					;									S	  J		