{% set version = "0.15.2" %}

package:
  name: modin-packages
  version: {{ version }}

source:
  url: https://github.com/modin-project/modin/archive/refs/tags/{{ version }}.tar.gz
  sha256: 576e17fa06622105be9cc57faa319c5e4a918a0ec456cedcb4ec03f16f72ada5
  patches:
    # Remove all requirements from setup.py - they should be handled here.
    # The point is to create a "patch failed" conflict when dependencies change
    # in upstream so this doesn't go unnoticed.
    - patches/0001-Remove-some-dependencies-from-omnisci-env.yml-to-be-.patch
    - patches/0002-Remove-dependencies-from-setup.py-to-be-handled-by-c.patch

build:
  number: 0
  skip: true  # [py<38]

requirements:
  build:
    - patch     # [unix]
    - m2-patch  # [win]

# the outputs map the modin options on PyPI (see upstream definition
# https://github.com/modin-project/modin/blob/0.10.1/setup.py#L40-L45)
# from "modin[<option>]" to "modin-<option>" as a conda-forge package
outputs:
  - name: modin-all
    build:
      skip: true  # [py<38]
    requirements:
      host:
        - python
      run:
        - python
        - {{ pin_subpackage('modin-core', exact=True) }}
        - {{ pin_subpackage('modin-dask', exact=True) }}
        # ray does not have OSX builds yet - modin-ray and modin-omnisci are mutually exclusive because of pyarrow 6.0.1
        - {{ pin_subpackage('modin-ray', exact=True) }}           # [win64 and py<310]
        # Note: modin-omnisci is conda-only, its dependencies were never published on PyPI
        - {{ pin_subpackage('modin-omnisci', exact=True) }}       # [linux and x86]
        # - {{ pin_subpackage('modin-remote', exact=True) }}       # turned off for now, see below
        # - {{ pin_subpackage('modin-spreadsheet', exact=True) }}  # turned off for now, see below
        # - {{ pin_subpackage('modin-sql', exact=True) }}          # turned off for now, see below
    test:
      imports:
        # dummy test; actual tests are in subpackages
        - modin

  # compatibility with packagename before split into options
  - name: modin
    build:
      skip: true  # [py<38]
    requirements:
      host:
        - python
      run:
        - python
        # modin needs at least one engine; use dask as it is more light-weight than ray
        - {{ pin_subpackage('modin-dask', exact=True) }}
    test:
      imports:
        - modin
        - modin.pandas

  - name: modin-core
    build:
      skip: true  # [py<38]
      script: python -m pip install . --no-deps --ignore-installed -vv
    requirements:
      host:
        - pip
        - python
        - setuptools
        - wheel
      run:
        - python
        - packaging
        - pandas ==1.4.3
        - numpy >=1.18.5
        - fsspec
        - psutil
        - setuptools # TODO: remove when logging metaclass is removed
    test:
      imports:
        - modin
        - modin.pandas
      commands:
        - pip check
      requires:
        - pip

  - name: modin-dask
    build:
      skip: true  # [py<38]
    requirements:
      host:
        - python
      run:
        - python
        - {{ pin_subpackage('modin-core', exact=True) }}
        - dask >=2.22.0,<2022.2.0
        - distributed >=2.22.0,<2022.2.0
    test:
      imports:
        - modin
        - modin.pandas
      commands:
        - python -c "import modin.pandas as pd, modin.config as cfg; cfg.Engine.put('Dask'); df = pd.DataFrame([])"

  - name: modin-ray
    build:
      # There is no Ray in conda-forge for MacOS yet, see conda-forge/ray-packages-feedstock#2.
      skip: true  # [not ((linux and x86) or win64)]
      skip: true  # [py<38 or py>39]
    requirements:
      host:
        - python
      run:
        - python
        - {{ pin_subpackage('modin-core', exact=True) }}
        # Pin ray to < 1.13.0 to work around GH#4564
        # TODO(https://github.com/modin-project/modin/issues/4564): let ray go past 1.13.0.
        - ray-default >=1.4.0,<1.13
        # Following https://github.com/ray-project/ray/pull/25648, pin protobuf < 4,
        # because versions >= 4.0.0 are incompatible with ray<1.13.0.
        - protobuf <4
        # aioredis 2.x breaks Ray
        # ref: https://github.com/conda-forge/ray-packages-feedstock/issues/38
        - aioredis <2
        - pyarrow >=4.0.1
        # TODO: remove redis dependency pin when GH modin-project/#4398 is resolved
        - redis-py >=3.5.0,<4.0.0
    test:
      imports:
        - modin
        - modin.pandas
      commands:
        - python -c "import modin.pandas as pd, modin.config as cfg; cfg.Engine.put('Ray'); df = pd.DataFrame([])"

  - name: modin-omnisci
    build:
      # there is no OmniSci on anything but Linux for now
      skip: true  # [not (linux and x86)]
      skip: true  # [py<38]
    requirements:
      host:
        - python
      run:
        - python
        - {{ pin_subpackage('modin-core', exact=True) }}
        # pyarrow included in pyomniscidbe 5.10.1 repacked version
        # - pyarrow =6
        - pyomniscidbe ==5.10.1
      run_constrained:
        # ------------------------------------------------------------------------
        # repack of pyarrow 6.0.1 requires preventing installation with other 
        # versions of pyarrow.
        # ------------------------------------------------------------------------
        - pyarrow ==6.0.1
    test:
      requires:
        - pytest
        - numpy
        - pandas
      imports:
        - modin
        - modin.pandas
      source_files:
        - modin/
        - examples/data/
      commands:
        - python -c "import modin.experimental.pandas as pd, modin.config as cfg; cfg.Engine.put('Native'); cfg.StorageFormat.put('OmniSci'); df = pd.DataFrame([])"
        - cd modin/experimental/core/execution/native/implementations/omnisci_on_native/test/ && pytest test_dataframe.py

  - name: modin-sql
    build:
      # Dependencies dfsql, mindsdb_sql are not in conda-forge yet.
      skip: true
    requirements:
      host:
        - python
      run:
        - python
        - {{ pin_subpackage('modin-core', exact=True) }}
        - dfsql >=0.4.2
        - pyparsing <=2.4.7
    test:
      imports:
        # are there more specific imports?!
        - modin

  - name: modin-remote
    build:
      # Dependency rpyc is not in conda-forge yet.
      # Also requires ray-autoscaler which is now absent because
      # its dependencies on conda-forge are too ancient.
      skip: true
    requirements:
      host:
        - python
      run:
        - python
        - {{ pin_subpackage('modin-core', exact=True) }}
        - boto3
        - cloudpickle
        - rpyc ==4.1.5
    test:
      imports:
        # are there more specific imports?!
        - modin

  # TODO: bring https://pypi.org/project/modin-spreadsheet/ to conda-forge
  # as modin-spreadsheet-core, leave modin-spreadsheet to be a subpackage here;
  # see discussion with upstream developers here:
  # https://github.com/conda-forge/modin-feedstock/pull/14/files#r595534632
  - name: modin-spreadsheet
    build:
      # dependency modin-spreadsheet-core is not in conda-forge yet
      skip: true
    requirements:
      host:
        - python
      run:
        - python
        - {{ pin_subpackage('modin-core', exact=True) }}
        - modin-spreadsheet >=0.1.0
    test:
      imports:
        # are there more specific imports?!
        - modin

about:
  home: https://github.com/modin-project/modin
  license: Apache-2.0
  license_family: Apache
  license_file: LICENSE
  summary: Speed up your Pandas workflows by changing a single line of code
  doc_url: https://modin.readthedocs.io/
  dev_url: https://github.com/modin-project/modin

extra:
  recipe-maintainers:
    - devin-petersohn
    - h-vetinari
    - vnlitvinov
    - maksimbo1
  feedstock-name: modin
