# Full credit goes to https://github.com/conda/conda-recipes for providing this recipe.
# It has been subsequently adapted for automated building with conda-forge.

{% set version = "3.6.2" %}

package:
  name: matplotlib-suite
  version: {{ version }}

source:
  url: https://github.com/matplotlib/matplotlib/archive/v{{ version }}.tar.gz
  sha256: 5ac5ca25e6ecd1e7711e1f859b4b6f74f290ef517387d1502bf8012bf2b1647e
  patches:
    # s390x fails to download qhull. This patch changes the download URL to point to Github. 
    # You must manually update LOCAL_QHULL_VERSION and LOCAL_QHULL_HASH from upstream.
    - 000_use_github_url_qhull.patch  # [unix]

build:
  number: 0

outputs:
  - name: matplotlib-base
    script: build_base.bat  # [win]
    script: build_base.sh  # [not win]
    build:
      skip: true  # [py<38]
      ignore_run_exports:
        - tk  # [linux]
        - zlib
    requirements:
      build:
        - pkg-config  # [not win]
        - {{ compiler('c') }}
        - {{ compiler('cxx') }}
        - patch  # [unix]
      host:
        - python
        - pip >=9.0.1
        - certifi >=2020.06.20
        # freetype.pc requires zlib.pc
        - freetype
        - zlib
        # an explanation to the utilization of numpy can be found
        # here: https://github.com/AnacondaRecipes/matplotlib-feedstock/pull/13#issuecomment-1296704563
        - numpy   1.19  # [not (osx and arm64) and (py==37 or py==38 or py==39)]
        - numpy   1.21  # [(osx and arm64) and (py==38 or py==39)]
        - numpy   1.21  # [py==310]
        - setuptools
        - setuptools_scm >=7
        - setuptools_scm_git_archive
        - tk  # [linux]
        - wheel
      run:
        - python
        - __osx >={{ MACOSX_DEPLOYMENT_TARGET|default("10.9") }}  # [osx and x86_64]
        - cycler >=0.10
        - contourpy >=1.0.1
        - fonttools >=4.22.0
        - freetype >=2.3
        - kiwisolver >=1.0.1
        - {{ pin_compatible('numpy') }}
        - packaging >=20.0
        - pillow >=6.2.0
        - pyparsing >=2.2.1
        - python-dateutil >=2.7
        - freetype
    test:
      imports:
        - matplotlib
        - matplotlib.pyplot
        - matplotlib._image
        - matplotlib._path
        - matplotlib._qhull
        - matplotlib._tri
        - matplotlib._ttconv
        - matplotlib.backends._backend_agg
        - matplotlib.ft2font
        - matplotlib.backends._tkagg  # [not win]
        - mpl_toolkits
        - pylab
      requires:
        - pytest
        - pip
      commands:
        - pip check

  - name: matplotlib
    build:
      skip: true  # [py<38]
    requirements:
      host:
        - python
      run:
        - python
        - pyqt  >=5  # [(linux64 or win) and python_impl == "cpython"]
        - tornado >=5
        - {{ pin_subpackage('matplotlib-base', max_pin="x.x.x") }}
    test:
      imports:
        - matplotlib

  - name: mpl_sample_data
    script: install-data.sh  # [not win]
    script: install-data.bat  # [win]
    build:
      # running into some odd install issues with noarch on win32 only.
      skip: true  # [win32 or python_impl == "pypy"]
      skip: true  # [py<38]
      noarch: python
    requirements:
      host:
        - python
      run:
        - python
        # match major/minor version, but allow noarch
        - {{ pin_subpackage('matplotlib-base', max_pin="x.x") }}
    test:
      imports:
        - matplotlib.cbook
      commands:
        - python -c "import matplotlib; matplotlib.cbook.get_sample_data('msft.csv', asfileobj=False)"

about:
  home: https://matplotlib.org/
  license: LicenseRef-PSF-based
  license_url: https://matplotlib.org/stable/users/project/license.html
  license_family: PSF
  license_file: LICENSE/LICENSE
  summary: Publication quality figures in Python
  description: |
    Matplotlib produces publication-quality figures in a variety of hardcopy formats
    and interactive environments across platforms. Matplotlib can be used in
    Python scripts, Python/IPython shells, web application servers,
    and various graphical user interface toolkits.
  dev_url: https://github.com/matplotlib/matplotlib/
  doc_url: https://matplotlib.org/stable/users/index.html
  doc_source_url: https://github.com/matplotlib/matplotlib/tree/main/doc

extra:
  recipe-maintainers:
    - mdboom
    - ocefpaf
    - pelson
    - tacaswell
    - dopplershift