{% set name = "mamba" %}
{% set version = "2.1.1" %}

package:
  name: mamba-split
  version: {{ version }}

source:
  url: https://github.com/mamba-org/mamba/archive/refs/tags/{{ version }}.tar.gz
  sha256: 789d3d89fe8ca9f06344da21797e3d949ad1ff0ae4c633dc242a333e0ee37485

build:
  number: 0

outputs:
  - name: libmamba
    version: {{ version }}
    script: build_mamba.sh                       # [unix]
    script: build_mamba.bat                      # [win]
    build:
      run_exports:
        - {{ pin_subpackage('libmamba', max_pin='x.x') }}
      ignore_run_exports:
        - spdlog
        - python  # [win]
    requirements:
      build:
        - {{ compiler('cxx') }}
        - {{ stdlib("c") }}
        - cmake
        - ninja
        - python  # [win]
      host:
        - libsolv >=0.7.23
        - libcurl >=8.4.0
        - openssl
        - libarchive
        - nlohmann_json <3.12
        - cpp-expected
        - reproc
        - reproc-cpp >=14.2.4.post0
        - spdlog
        - yaml-cpp
        - cli11
        - fmt
        - winreg                                 # [win]
        - zstd
        - simdjson >=3.3.0
      run:
        # `nlohmann_json` is pinned because we expose it in the API of libmamba
        # (`nlohmann_json` objects are put in version namespaces because the author
        # does not want to take any risk regarding ABI compatibility)
        #
        # Since `nlohmann_json` is a heaer only library, it does not have run_export,
        # and we don't have the choice, we need to pin it here exactly
        #
        # Therefore, any library exchanging `nlohmann_json` objects with libmamba
        # must be built with exactly the same version of nlohmann_json as that
        # used to build mamba.
        - {{ pin_compatible('nlohmann_json', max_pin='x.x.x') }}
        # Similar reasons apply to `cpp-expected`.
        - {{ pin_compatible('cpp-expected', max_pin='x.x.x') }}

    test:
      commands:
        # Profile script must not be installed for libmamba
        # TODO: remove `etc/profile.d/mamba.sh` after 30th Sept. 2025
        - test ! -f "${PREFIX}/etc/profile.d/mamba.sh"  # [unix]
        - if exist %LIBRARY_PREFIX%\etc\profile.d\mamba.sh (exit 1)  # [win]
        # Headers and cmake files
        - test -d ${PREFIX}/include/mamba  # [unix]
        - test -f ${PREFIX}/include/mamba/version.hpp  # [unix]
        - test -f ${PREFIX}/lib/cmake/libmamba/libmambaConfig.cmake  # [unix]
        - test -f ${PREFIX}/lib/cmake/libmamba/libmambaConfigVersion.cmake  # [unix]
        - test -e ${PREFIX}/lib/libmamba${SHLIB_EXT}  # [unix]
        - if not exist %LIBRARY_PREFIX%\include\mamba\version.hpp (exit 1)  # [win]
        - if not exist %LIBRARY_PREFIX%\lib\cmake\libmamba\libmambaConfig.cmake (exit 1)  # [win]
        - if not exist %LIBRARY_PREFIX%\lib\cmake\libmamba\libmambaConfigVersion.cmake (exit 1)  # [win]
        - if not exist %LIBRARY_PREFIX%\bin\libmamba.dll (exit 1)  # [win]
        - if not exist %LIBRARY_PREFIX%\lib\libmamba.lib (exit 1)  # [win]
        {% set version_split = version.split('.') %}
        - cat $PREFIX/include/mamba/version.hpp | grep "LIBMAMBA_VERSION_MAJOR {{ version_split[0] }}"  # [unix]
        - cat $PREFIX/include/mamba/version.hpp | grep "LIBMAMBA_VERSION_MINOR {{ version_split[1] }}"  # [unix]
        - cat $PREFIX/include/mamba/version.hpp | grep "LIBMAMBA_VERSION_PATCH {{ version_split[2] }}"  # [unix]

  - name: libmambapy
    version: {{ version }}
    script: build_mamba.sh                       # [unix]
    script: build_mamba.bat                      # [win]
    build:
      string: py{{ CONDA_PY }}h{{ PKG_HASH }}_{{ PKG_BUILDNUM }}
      run_exports:
        - {{ pin_subpackage('libmambapy', max_pin='x.x') }}
      ignore_run_exports:
        - spdlog
      skip: True  # [python_impl == 'pypy']
    requirements:
      build:
        - {{ compiler('cxx') }}
        - {{ stdlib("c") }}
        - cmake
        - ninja
        - python                                 # [build_platform != target_platform]
        - cross-python_{{ target_platform }}     # [build_platform != target_platform]
        - pybind11                               # [build_platform != target_platform]
        - pybind11-abi                           # [build_platform != target_platform]
      host:
        - python
        - scikit-build
        - pip
        - setuptools <79
        - pybind11
        - pybind11-abi
        - openssl
        - yaml-cpp
        - cpp-expected
        - spdlog
        - fmt
        - termcolor-cpp
        - nlohmann_json <3.12
        - {{ pin_subpackage('libmamba', exact=True) }}
        # zstd is not a direct dependency but this specification is needed to
        # distinguish builds of libmambapy for specific specific version of zstd.
        - zstd
      run:
        - python
        - {{ pin_subpackage('libmamba', exact=True) }}

    test:
      imports:
        - libmambapy
        - libmambapy.bindings
      commands:
        - python -c "import libmambapy; assert libmambapy.__version__ == '{{ version }}'"

  - name: mamba
    version: {{ version }}
    script: build_mamba.sh                       # [unix]
    script: build_mamba.bat                      # [win]
    build:
      ignore_run_exports_from:
        - libcurl                     # [unix]
        - openssl                     # [unix]
        - spdlog
        - fmt
        - {{ compiler('cxx') }}       # [linux]
        - python                      # [win]
        - libsolv
    requirements:
      build:
        - {{ compiler('cxx') }}
        - {{ stdlib("c") }}
        - cmake
        - ninja
        - vcpkg-tool      # [win]
        - python          # [win]
        - curl >=8.4.0    # [win]
        - zlib            # [win]
      host:
        - cli11 >=2.2,<3
        - reproc
        - reproc-cpp
        - {{ pin_subpackage('libmamba', exact=True) }}
        - spdlog
        # zstd is not a direct dependency but this specification is needed to
        # distinguish build of mamba for specific specific version of zstd.
        - zstd
      run:
        - {{ pin_subpackage('libmamba', exact=True) }}

    test:
      commands:
        - test -f "${PREFIX}/bin/mamba"                  # [unix]
        - test -f "${PREFIX}/condabin/mamba"             # [unix]
        # TODO: remove `etc/profile.d/mamba.sh` after 30th Sept. 2025
        - test -f "${PREFIX}/etc/profile.d/mamba.sh"     # [unix]
        # Execute this script
        - . ${PREFIX}/etc/profile.d/mamba.sh     # [unix]
        - if not exist %LIBRARY_BIN%\mamba.exe (exit 1)  # [win]
        - if not exist %PREFIX%\condabin\mamba.bat (exit 1)  # [win]
        - mamba --help
        - ${PREFIX}/condabin/mamba --help          # [unix]
        - CALL %PREFIX%/condabin/mamba.bat --help       # [win]
        - export MAMBA_ROOT_PREFIX="$(mktemp -d)"  # [unix]
        - mkdir %TEMP%\mamba                       # [win]
        - set "MAMBA_ROOT_PREFIX=%TEMP%\mamba"     # [win]
        - mamba clean --all --dry-run    # [unix]
        # The following test is segfaulting but we couod not reproduce it outside the build
        # environment, so we're moving on with the 2.0.0beta0 release.
        # - mamba repoquery depends mamba  # [unix]
        - mamba create -n test --override-channels -c conda-forge --yes python=3.9
        - '"${MAMBA_ROOT_PREFIX}/envs/test/bin/python" --version'       # [unix]
        - '%MAMBA_ROOT_PREFIX%\envs\test\python.exe --version'          # [win]
        - '"${MAMBA_ROOT_PREFIX}/envs/test/bin/python" -c "import os"'  # [unix]
        - '%MAMBA_ROOT_PREFIX%\envs\test\python.exe -c "import os"'     # [win]

about:
  home: https://github.com/mamba-org/mamba
  license: BSD-3-Clause
  license_file: LICENSE
  license_family: BSD
  summary: A fast drop-in alternative to conda, using libsolv for dependency resolution
  description: |
    # Mamba, the Fast Cross-Platform Package Manager

    [![Build Status](https://github.com/mamba-org/mamba/workflows/CI/badge.svg)](https://github.com/mamba-org/mamba/actions)
    [![Join the Gitter Chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mamba-org/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
    [![docs](https://readthedocs.org/projects/mamba/badge/?version=latest&style=flat)](https://mamba.readthedocs.io/en/latest)

    `mamba` is a reimplementation of the conda package manager in C++.

    - parallel downloading of repository data and package files using multi-threading
    - libsolv for much faster dependency solving, a state of the art library used in the RPM package manager of Red Hat, Fedora and OpenSUSE
    - core parts of `mamba` are implemented in C++ for maximum efficiency

    At the same time, `mamba` utilizes the same command line parser, package installation and deinstallation code and transaction verification routines as `conda` to stay as compatible as possible.

    Mamba is part of a bigger ecosystem to make scientific packaging more sustainable. You can read our [announcement blog post](https://medium.com/@QuantStack/open-software-packaging-for-science-61cecee7fc23).
    The ecosystem also consists of `quetz`, an open source `conda` package server and `boa`, a fast `conda` package builder.

    ### Installation

    Please refer to the [`mamba` and `micromamba` installation guide](https://mamba.readthedocs.io/en/latest/installation.html) in the documentation.

    ### Additional features in Mamba and Micromamba

    `mamba` and `micromamba` come with features on top of stock `conda`.

    ### `repoquery`

    To efficiently query repositories and query package dependencies you can use `mamba repoquery` or `micromamba repoquery`.
    See the [repoquery documentation](https://mamba.readthedocs.io/en/latest/user_guide/mamba.html#repoquery) for details.

    ### Installing lock files

    `micromamba` can be used to install lock files generated by [conda-lock](https://conda-incubator.github.io/conda-lock/) without having to install `conda-lock`. Simply invoke e.g. `micromamba create -n my-env -f conda-lock.yml` with an environment lockfile named `*-lock.yml` or `*-lock.yaml`.

  dev_url: https://github.com/mamba-org/mamba

extra:
  recipe-maintainers:
    - jjerphan
    - AntoinePrv
    - adriendelsalle
    - SylvainCorlay
    - JohanMabille
    - wolfv
    - ericmjl
