{% set version = "2.7.15" %}
{% set sha256 = "18617d1f15a380a919d517630a9cd85ce17ea602f9bbdc58ddc672df4b0239db" %}

package:
  name: python
  version: {{ version }}

source:
  - url: https://www.python.org/ftp/python/{{ version }}/Python-{{ version }}.tgz
    sha256: {{ sha256 }}
    patches:
      {% if 'toolchain' in compiler('c') %}
      # use one set of patches for the toolchain (old compiler) build
      - osx-dist.patch                  # [osx and x86_64]
      - win-find_exe.patch              # [win]
      - win-library_bin.patch           # [win]
      - 0008-Win32-Fixes-for-Windows-GCC-interop-needed-by-RPy2-a.patch
      - 0017-Fix-find_library-so-that-it-looks-in-sys.prefix-lib-.patch
      - PR_6724.patch
      {% else %}
      # use another set of patches for the gcc (new compiler) build
      # these are the same patches as used in the AnacondaRecipes feedstock
      - 0001-backport-Python-3.6-_PYTHON_SYSCONFIGDATA_NAME.patch
      #- 0002-Add-Anaconda-Distribution-version-logic.patch
      - 0003-Darwin-Hack-sys.-exec_-prefix-if-run-from-python.app.patch
      - 0004-Darwin-Add-arch-x86_64-to-UnicCCompiler-ld_args.patch
      - 0005-Win32-distutils-Also-look-for-executable.bat.patch
      # TODO :: This breaks conda activate and deactivate.
      - 0006-Win32-Ensure-Library-bin-is-in-os.environ-PATH.patch
      - 0007-Win32-Change-FD_SETSIZE-from-512-to-2048.patch
      - 0008-Win32-Fixes-for-Windows-GCC-interop-needed-by-RPy2-a.patch
      - 0009-Do-not-pass-g-to-GCC-when-not-Py_DEBUG.patch
      - 0010-Darwin-Look-in-sysroot-usr-lib-include-if-sysroot-is.patch
      - 0011-runtime_library_dir_option-Use-1st-word-of-CC-as-com.patch
      - 0012-Mark-sysconfigdata.py-as-utf-8.patch
      - 0013-Fix-find_library-so-that-it-looks-in-sys.prefix-lib-.patch
      - 0014-Fix-cross-compilation-on-Debian-based-distros.patch
      {% endif %}
      # use an additional set of patches for any build
      - enable-loadable-sqlite-extensions.patch
  - url: https://github.com/python/cpython-source-deps/archive/bzip2-1.0.6.zip      # [win]
    folder: externals/bzip2-1.0.6                                                   # [win]
    sha256: c42fd1432a2667b964a74bc423bb7485059c4a6d5dc92946d59dbf9a6bdb988d        # [win]
  - url: https://github.com/python/cpython-source-deps/archive/bsddb-4.7.25.0.zip   # [win]
    folder: externals/bsddb-4.7.25.0                                                # [win]
    sha256: 0bc1f79d2bbff8159cf56103db615cc011458b7b0f5fc4c8c3db3132f026abbc        # [win]
  - url: https://github.com/python/cpython-source-deps/archive/openssl-1.0.2o.zip   # [win]
    folder: externals/openssl-1.0.2o                                                # [win]
    sha256: 9db2a35ef254b57e16a47916810a3bf1cd639b512b5fe6c1cb51afc985113595        # [win]
  - url: https://github.com/python/cpython-source-deps/archive/sqlite-3.14.2.0.zip  # [win]
    folder: externals/sqlite-3.14.2.0                                               # [win]
    sha256: c1ff98c76c11dc10b2abe94d72ea5bae7da64ba8da9455a9af5dc3eae0f2f880        # [win]
  - url: https://github.com/python/cpython-source-deps/archive/tcl-8.5.19.0.zip     # [win]
    folder: externals/tcl-8.5.19.0                                                  # [win]
    sha256: 8520a7d6df448770ec129f497b0b16fdddc6876905ffce2ad13d12180598ce48        # [win]
  - url: https://github.com/python/cpython-source-deps/archive/tk-8.5.19.0.zip      # [win]
    folder: externals/tk-8.5.19.0                                                   # [win]
    sha256: b5a0ab7bcd8f02b695a2877cc6c964b696727e3bd0156b033f710dc0288127d1        # [win]
  - url: https://github.com/python/cpython-source-deps/archive/tix-8.4.3.5.zip      # [win]
    folder: externals/tix-8.4.3.5                                                   # [win]
    sha256: f0769bdf97cc1835b4565e26664a28b3d9a11ae655075027c14ccb35a6ff8281        # [win]
  - url: https://github.com/python/cpython-bin-deps/archive/nasm-2.11.06.zip        # [win]
    folder: externals/nasm-2.11.06                                                  # [win]
    sha256: de3c87b26a80e789986d8e6950c6304175d3829afe9c6c7211eb7257266ab0ac        # [win]


build:
  number: 1011
  no_link:
    - bin/python2.7     # [unix]
    - DLLs/_ctypes.pyd  # [win]
  # script_env:
  #   - python_branding
  # We delete the shared libraries.
  ignore_run_exports:   # [unix]
    - bzip2             # [unix]
  skip: True            # [win and vc != 9]
  string: h{{ PKG_HASH }}_{{ PKG_BUILDNUM }}_cpython
  run_exports:
    noarch:
      - python
    weak:
      - python_abi 2.7.* *_cp27m   # [not linux]
      - python_abi 2.7.* *_cp27mu  # [linux]


requirements:
  build:
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    - {{ cdt('xorg-x11-proto-devel') }}  # [linux]
    - {{ cdt('libx11-devel') }}          # [linux]
    - make                               # [unix]
    - pkg-config                         # [unix]
  host:
    - bzip2                              # [unix]
    - sqlite                             # [unix]
    - zlib                               # [unix]
    - openssl                            # [unix]
    - readline                           # [unix]
    - tk                                 # [unix]
    - ncurses                            # [unix]
    - libffi                             # [unix]
    - ld_impl_{{ target_platform }}      # [linux]
  run:
    - ld_impl_{{ target_platform }}      # [linux]
  run_constrained:
    - python_abi 2.7.* *_cp27m           # [not linux]
    - python_abi 2.7.* *_cp27mu          # [linux]

test:
  commands:
    - python -V
    - pydoc -h
    - python-config --help  # [unix]
    - idle -h
    - python -c "import sysconfig; print sysconfig.get_config_var('CC')"
    {% if 'toolchain' not in compiler('c') %}
    -  _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_x86_64_conda_cos6_linux_gnu python -c "import sysconfig; print sysconfig.get_config_var('CC')"  # [linux64]
    {% endif %}

about:
  home: http://www.python.org/
  license: PSF
  license_file: LICENSE
  summary: General purpose programming language
  description: |
    Python is a widely used high-level, general-purpose, interpreted, dynamic
    programming language. Its design philosophy emphasizes code
    readability, and its syntax allows programmers to express concepts in
    fewer lines of code than would be possible in languages such as C++ or
    Java. The language provides constructs intended to enable clear programs
    on both a small and large scale.
  doc_url: https://www.python.org/doc/versions/
  doc_source_url: https://github.com/python/pythondotorg/blob/master/docs/source/index.rst
  dev_url: https://docs.python.org/devguide/

extra:
  recipe-maintainers:
    - jakirkham
    - jjhelmus
    - mingwandroid
    - msarahan
    - pelson
