<!-- Thank you for contributing to Pyodide! All improvements are welcome,
     so don't be afraid to make a PR. -->

<!-- [IMPORTANT] Note on CI failures:
     Currently, we are having issues with selenium-based tests.
     Don't panic if the CI fails on your PR because of timeouts.
     It's probably not your fault. We will investigate :) -->

### Description

<!-- Please explain what your PR is about:
     - reasoning for the change
     - some details of updated code
     - any noteworthy choices to be aware of
	Please refer to any related issues by #<issue_id> -->

Bumping MPL version - it turns out that Hist (which uses boost-histogram) depends on mplhep, which in turn requires matplotlib 3.4+. So I migrated the patches and bumped MPL.

I noticed micropip doesn't seem to respect extras, that is, `await micropip.install("hist[plot]")` doesn't seem to work. (will investigate later)

* Updated matplotlib to 3.5
    * Added fonttools
* Updated yt to 4
    * Added `cmyt` and `unyt`, which I am pretty sure are yt specific. At least by looking at the name. 😆 
    * Also `colorspacious`
    * Also `tdqm`
    * Also `tomli` and `tomli-w` (backported from the next yt release to avoid adding a dead dependency `toml`)

Closes #2088 too. Also 3.5 was the first version to officially support 3.10, I think.
chore: matplotlib 3.5.1, yt 4. <!-- Thank you for contributing to Pyodide! All improvements are welcome,
     so don't be afraid to make a PR. -->

<!-- [IMPORTANT] Note on CI failures:
     Currently, we are having issues with selenium-based tests.
     Don't panic if the CI fails on your PR because of timeouts.
     It's probably not your fault. We will investigate :) -->

### Description

<!-- Please explain what your PR is about:
     - reasoning for the change
     - some details of updated code
     - any noteworthy choices to be aware of
	Please refer to any related issues by #<issue_id> -->

Bumping MPL version - it turns out that Hist (which uses boost-histogram) depends on mplhep, which in turn requires matplotlib 3.4+. So I migrated the patches and bumped MPL.

I noticed micropip doesn't seem to respect extras, that is, `await micropip.install("hist[plot]")` doesn't seem to work. (will investigate later)

* Updated matplotlib to 3.5
    * Added fonttools
* Updated yt to 4
    * Added `cmyt` and `unyt`, which I am pretty sure are yt specific. At least by looking at the name. 😆 
    * Also `colorspacious`
    * Also `tdqm`
    * Also `tomli` and `tomli-w` (backported from the next yt release to avoid adding a dead dependency `toml`)

Closes #2088 too. Also 3.5 was the first version to officially support 3.10, I think.
package:
  name: matplotlib
  version: 3.3.3

source:
  url: https://files.pythonhosted.org/packages/7b/b3/7c48f648bf83f39d4385e0169d1b68218b838e185047f7f613b1cfc57947/matplotlib-3.3.3.tar.gz
  sha256: b1b60c6476c4cfe9e5cf8ab0d3127476fd3d5f05de0f343a452badaad0e4bdec

  patches:
    - patches/disable_macosx_backend.patch
    - patches/fix-freetype.patch
    - patches/hardcoded-font-cache.patch
    - patches/fix-threading.patch

  extras:
    - - src/browser_backend.py
      - lib/matplotlib/backends/browser_backend.py
    - - src/wasm_backend.py
      - lib/matplotlib/backends/wasm_backend.py
    - - src/html5_canvas_backend.py
      - lib/matplotlib/backends/html5_canvas_backend.py
    - - src/setup.cfg
      - ./setup.cfg

build:
  cflags: -s USE_FREETYPE=1 -s USE_LIBPNG=1 -s USE_ZLIB=1
  ldflags: -s USE_FREETYPE=1 -s USE_LIBPNG=1 -s USE_ZLIB=1
  replace-libs:
    - png16=png
  post: |
    cd build/matplotlib-3.3.3/dist/matplotlib-3.3.3/
    wget -O matplotlib/mpl-data/fonts/ttf/Humor-Sans.ttf http://antiyawn.com/uploads/Humor-Sans-1.0.ttf
    rm -rf matplotlib/backends/qt_editor
    rm -rf matplotlib/backends/web_backend
    rm -rf sphinxext
    cp $PKGDIR/src/fontlist.json matplotlib
    mkdir -p $PKGDIR/../../build/fonts
    cp matplotlib/mpl-data/fonts/ttf/* $PKGDIR/../../build/fonts/

requirements:
  run:
    - distutils
    - cycler
    - kiwisolver
    - numpy
    - pillow
    - pyparsing
    - python-dateutil
    - pytz

test:
  imports:
    - matplotlib
    - mpl_toolkits

package:
  name: matplotlib
  version: 3.5.1

source:
  url: https://files.pythonhosted.org/packages/8a/46/425a44ab9a71afd2f2c8a78b039c1af8ec21e370047f0ad6e43ca819788e/matplotlib-3.5.1.tar.gz
  sha256: b2e9810e09c3a47b73ce9cab5a72243a1258f61e7900969097a817232246ce1c

  patches:
    - patches/disable_macosx_backend.patch
    - patches/hardcoded-font-cache.patch
    - patches/fix-threading.patch

  extras:
    - - src/browser_backend.py
      - lib/matplotlib/backends/browser_backend.py
    - - src/wasm_backend.py
      - lib/matplotlib/backends/wasm_backend.py
    - - src/html5_canvas_backend.py
      - lib/matplotlib/backends/html5_canvas_backend.py
    - - src/setup.cfg
      - ./mplsetup.cfg

build:
  cflags: -s USE_FREETYPE=1 -s USE_LIBPNG=1 -s USE_ZLIB=1
  ldflags: -s USE_FREETYPE=1 -s USE_LIBPNG=1 -s USE_ZLIB=1
  replace-libs:
    - png16=png
  post: |
    cd build/matplotlib-3.5.1/dist/matplotlib-3.5.1/
    wget -O matplotlib/mpl-data/fonts/ttf/Humor-Sans.ttf http://antiyawn.com/uploads/Humor-Sans-1.0.ttf
    rm -rf matplotlib/backends/qt_editor
    rm -rf matplotlib/backends/web_backend
    rm -rf sphinxext
    cp $PKGDIR/src/fontlist.json matplotlib
    mkdir -p $PKGDIR/../../build/fonts
    cp matplotlib/mpl-data/fonts/ttf/* $PKGDIR/../../build/fonts/

requirements:
  run:
    - cycler
    - distutils
    - fonttools
    - kiwisolver
    - numpy
    - packaging
    - pillow
    - pyparsing
    - python-dateutil
    - pytz

test:
  imports:
    - matplotlib
    - mpl_toolkits
