{% set version = "7.16.5" %}

{% set min_pandoc = "2.9.2" %}
{% set max_pandoc = "4.0.0" %}

{% set build = 0 %}

{% set pytest_args = "-k \"not (convert_full_qualified_name or post_processor)\"" %}
{% set cov_fail_under = "71" %}

{% set PYTHON = PYTHON | default("$PYTHON") %}

package:
  name: nbconvert-meta
  version: {{ version }}

source:
  url: https://pypi.org/packages/source/n/nbconvert/nbconvert-{{ version }}.tar.gz
  sha256: c83467bb5777fdfaac5ebbb8e864f300b277f68692ecc04d6dab72f2d8442344

build:
  number: {{ build }}
  noarch: python

requirements:
  host:
    - python {{ python_min }}
  run:
    - python >={{ python_min }}

outputs:
  - name: nbconvert
    build:
      noarch: generic
    requirements:
      run:
        - {{ pin_subpackage("nbconvert-core", exact=True) }}
        - {{ pin_subpackage("nbconvert-pandoc", exact=True) }}
    test:
      requires:
        - pip
      commands:
        - pip check
        - jupyter nbconvert --version
        - jupyter dejavu --version
        - jupyter nbconvert --help
        - jupyter dejavu --help

  - name: nbconvert-core
    build:
      noarch: python
      script: {{ PYTHON }} -m pip install . -vv --no-deps --no-build-isolation
      entry_points:
        - jupyter-dejavu = nbconvert.nbconvertapp:dejavu_main
        - jupyter-nbconvert = nbconvert.nbconvertapp:main
    requirements:
      host:
        - python {{ python_min }}
        - hatchling >=1.5
        - pip
      run:
        - python >={{ python_min }}
        - beautifulsoup4
        - defusedxml
        - entrypoints >=0.2.2
        - importlib-metadata >=3.6
        - jinja2 >=3.0
        - jupyter_core >=4.7
        - jupyterlab_pygments
        - markupsafe >=2.0
        - mistune >=2.0.3,<4
        - nbclient >=0.5.0
        - nbformat >=5.7
        - packaging
        - pandocfilters >=1.4.1
        - pygments >=2.4.1
        - traitlets >=5.1
        # TODO: ensure a `bleach-with-css` https://github.com/conda-forge/bleach-feedstock/pull/42
        # - bleach[css]!=5.0.0
        - bleach !=5.0.0
        - tinycss2 >=1.1.0,<1.5
      run_constrained:
        # other packages carry the full `run` dependency
        - pandoc >={{ min_pandoc }},<{{ max_pandoc }}
        # avoid mixing nbconvert-core and pre-split nbconvert
        # can't mix noarch:generic and noarch:python with exact=True
        - nbconvert ={{ version }}=*_{{ build }}

    test:
      requires:
        - python {{ python_min }}
      imports:
        - nbconvert
        - nbconvert.exporters
        - nbconvert.filters
        - nbconvert.postprocessors
        - nbconvert.preprocessors
        - nbconvert.resources
        - nbconvert.utils
        - nbconvert.writers
      commands:
        - jupyter nbconvert --version
        - jupyter dejavu --version
        - jupyter nbconvert --help
        - jupyter dejavu --help

  - name: nbconvert-qtpdf
    build:
      noarch: generic
    requirements:
      run:
        - {{ pin_subpackage("nbconvert-core", exact=True) }}
        - pyqtwebengine >=5.5
    test:
      source_files:
        - tests/files/notebook1.ipynb
      requires:
        - pip
      script_env:
        - DISPLAY=localhost:1.0  # [linux]
      commands:
        - pip check
        - jupyter nbconvert --version
        - jupyter dejavu --version
        - jupyter nbconvert --help
        - jupyter dejavu --help
        - jupyter nbconvert tests/files/notebook1.ipynb --to qtpdf  # [not linux]
        - xvfb-run -a jupyter nbconvert tests/files/notebook1.ipynb --to qtpdf  # [linux]
    about:
      home: https://jupyter.org
      license: BSD-3-Clause
      license_file: LICENSE
      description: nbconvert with extra packages for browser-based PDF generation
      doc_url: https://nbconvert.readthedocs.org/
      dev_url: https://github.com/jupyter/nbconvert

  - name: nbconvert-pandoc
    build:
      noarch: generic
    requirements:
      run:
        - {{ pin_subpackage("nbconvert-core", exact=True) }}
        # the pin is handled by the `run_constrained` in nbconvert-core
        - pandoc
    test:
      files:
        - check_pandoc.py
      requires:
        - pip
      commands:
        - pip check
        - jupyter nbconvert --version
        - jupyter dejavu --version
        - jupyter nbconvert --help
        - jupyter dejavu --help
        - python check_pandoc.py ">={{ min_pandoc }}" "<{{ max_pandoc }}"
    about:
      home: https://jupyter.org
      license: BSD-3-Clause
      license_file: LICENSE
      description: nbconvert with extra packages for pandoc-based outputs
      doc_url: https://nbconvert.readthedocs.org/
      dev_url: https://github.com/jupyter/nbconvert

  - name: nbconvert-webpdf
    build:
      noarch: generic
    requirements:
      run:
        - {{ pin_subpackage("nbconvert-core", exact=True) }}
        - playwright-python
    test:
      source_files:
        - tests/files/notebook1.ipynb
      requires:
        - pip
      script_env:
        - DISPLAY=localhost:1.0  # [linux]
      commands:
        - pip check
        - jupyter nbconvert --version
        - jupyter dejavu --version
        - jupyter nbconvert --help
        - jupyter dejavu --help
        - playwright install chromium
        - jupyter nbconvert tests/files/notebook1.ipynb --to webpdf
    about:
      description: nbconvert with extra packages for browser-based PDF generation

  - name: nbconvert-all
    build:
      noarch: generic
    requirements:
      run:
        - {{ pin_subpackage("nbconvert-core", exact=True) }}
        - {{ pin_subpackage("nbconvert-qtpdf", exact=True) }}
        - {{ pin_subpackage("nbconvert-webpdf", exact=True) }}
        - {{ pin_subpackage("nbconvert", exact=True) }}
    test:
      source_files:
        - tests
        - pyproject.toml
      requires:
        - coverage
        - flaky
        - ipykernel
        - ipywidgets >=7.9.0
        - pip
        - pytest-dependency
      commands:
        - pip check
        - jupyter nbconvert --version
        - jupyter dejavu --version
        - jupyter nbconvert --help
        - jupyter dejavu --help
        - pytest -vv {{ pytest_args }}                                                          # [not linux]
        - xvfb-run -a coverage run --branch --source=nbconvert -m pytest -vv {{ pytest_args }}  # [linux]
        - coverage report --show-missing --skip-covered --fail-under={{ cov_fail_under }}       # [linux]
    about:
      home: https://jupyter.org
      license: BSD-3-Clause
      license_file: LICENSE
      description: nbconvert with all optional packages
      doc_url: https://nbconvert.readthedocs.org/
      dev_url: https://github.com/jupyter/nbconvert

about:
  home: https://jupyter.org
  license: BSD-3-Clause
  license_file: LICENSE
  summary: Converting Jupyter Notebooks
  description: |
    The nbconvert tool, jupyter nbconvert, converts notebooks to various other
    formats via Jinja templates. The nbconvert tool allows you to convert an
    .ipynb notebook file into various static formats.
  doc_url: https://nbconvert.readthedocs.org/
  dev_url: https://github.com/jupyter/nbconvert

extra:
  feedstock-name: nbconvert
  recipe-maintainers:
    - jakirkham
    - mpacer
    - minrk
    - pelson
    - takluyver
    - mseal
    - blink1073
    - ocefpaf
    - jasongrout
    - bollwyvl
    - martinRenou
