{% set on_win = SUBDIR in ('win-64', 'win-32') %}
{% set version = "4.10.3" %}

package:
  name: conda
  version: {{ version }}

source:
  fn: conda-{{ version }}.tar.gz
  url: https://github.com/conda/conda/archive/{{ version }}.tar.gz
  sha256: 9e83bb20a6b9adc0bd7abccaa4738a71dc04e19a42dc51ad543539c15b2c941a
  patches:
    - gh9946_utf_16_replacement.patch

build:
  number: 0
  # These are present when the new environment is created
  # so we have to exempt them from the list of initial files
  # for conda-build to realize they should be included.
  always_include_files:
    - bin/conda                    # [unix]
    - bin/activate                 # [unix]
    - bin/deactivate               # [unix]
    - Scripts/activate.bat         # [win]
    - Scripts/activate             # [win]
    - Scripts/deactivate           # [win]

requirements:
  build:
    - python                                 # [build_platform != target_platform]
    - cross-python_{{ target_platform }}     # [build_platform != target_platform]
    - m2-filesystem                # [win]
    - m2-bash                      # [win]
    - m2-base                      # [win]

  host:
    - python
    - conda-package-handling >=1.3.0
    - menuinst >=1.4.11,<2         # [win]
    - pip
    - ruamel_yaml >=0.11.14,<0.16
    - setuptools >=31.0.1
  run:
    - python
    - conda-package-handling >=1.3.0
    - menuinst >=1.4.11,<2         # [win]
    - pycosat >=0.6.3
    - pyopenssl >=16.2.0
    - requests >=2.18.4,<3
    - ruamel_yaml >=0.11.14,<0.16
    - setuptools >=31.0.1
  run_constrained:
    - conda-build >=3
    - conda-env >=2.6
    - cytoolz >=0.8.1

test:
  source_files:
    - conftest.py
    - tests
    - setup.cfg
  requires:
    - mock
    - pytest
    - pexpect
    - responses
    - m2-filesystem  # [win]
    - m2-bash        # [win]
    - m2-base        # [win]
  imports:
    - conda
    - conda_env
  files:
    - test_conda.bat                # [win]
    - test_conda.sh                 # [unix]
  downstreams:
    - conda-smithy  # [py>=30 and py!=38 and python_impl == "cpython"]
  commands:
{% if on_win %}
    - SET CONDA_SHLVL=
    - CALL %PREFIX%\condabin\conda_hook.bat
    - conda.bat activate base
    - FOR /F "delims=" %%i IN ('python -c "import sys; print(sys.version_info[0])"') DO set "PYTHON_MAJOR_VERSION=%%i"
    - SET TEST_PLATFORM=win
    - FOR /F "delims=" %%i IN ('python -c "import random as r; print(r.randint(0,4294967296))"') DO set "PYTHONHASHSEED=%%i"
    - SET
    - where conda
    - conda info
    - conda create -y -p .\built-conda-test-env
    - conda.bat activate .\built-conda-test-env
    - ECHO %CONDA_PREFIX%
    - IF NOT "%CONDA_PREFIX%"=="%CD%\built-conda-test-env" EXIT /B 1
    - conda.bat deactivate
    - SET MSYSTEM=MINGW%ARCH%
    - SET MSYS2_PATH_TYPE=inherit
    - SET CHERE_INVOKING=1
    - FOR /F "delims=" %%i IN ('cygpath.exe -u "%PREFIX%"') DO set "PREFIXP=%%i"
    - bash -lc "source %PREFIXP%/Scripts/activate"
    # - py.test tests -m "not integration and not installed" & exit 0
{% else %}
    - unset CONDA_SHLVL
    - eval "$(python -m conda shell.bash hook)"
    - conda activate base
    - export PYTHON_MAJOR_VERSION=$(python -c "import sys; print(sys.version_info[0])")
    - export TEST_PLATFORM=$(python -c "import sys; print('win' if sys.platform.startswith('win') else 'unix')")
    - export PYTHONHASHSEED=$(python -c "import random as r; print(r.randint(0,4294967296))") && echo "PYTHONHASHSEED=$PYTHONHASHSEED"
    - env | sort
    - conda info
    - conda create -y -p ./built-conda-test-env
    - conda activate ./built-conda-test-env
    - echo $CONDA_PREFIX
    - '[ "$CONDA_PREFIX" = "$PWD/built-conda-test-env" ] || exit 1'
    - conda deactivate
    # - py.test tests -m "not integration and not installed" -vv || true
{% endif %}

about:
  home: https://conda.io
  license: BSD-3-Clause
  license_file: LICENSE.txt
  summary: OS-agnostic, system-level binary package and environment manager.
  description: >
    Conda is an open source package management system and environment management system for installing multiple versions of software packages and their dependencies and switching easily between them. It works on Linux, OS X and Windows, and was created for Python programs but can package and distribute any software.
  doc_url: https://conda.io/projects/conda/en/latest/
  dev_url: https://github.com/conda/conda

extra:
  recipe-maintainers:
    - isuruf
    - jakirkham
    - kalefranz
    - mcg1969
    - mingwandroid
    - msarahan
    - mwcraig
    - ocefpaf
    - patricksnape
    - pelson
    - scopatz
    - mbargull
    - jezdez
