matplotlib/mplcairo

Unable to install from pip

sstendahl opened this issue · 6 comments

Hey,

There's a bug with the bundled cairo version with matplotlib that makes the graph cut off at scaled resolutions. This all seems to work fine on latest version of mplplot on my local machine, so I was thinking of bundling mplcairo with application Graphs for the backend, at least until that issue is fixed.

However, I need to bundle mplplot in my Flatpak. In the end, it tries to install it either through pip from source, or using a wheel as published on PyPi. There's no wheels available for Linux on aarch64 architectures unfortunately, and I don't own any aarch64 devices and cannot build these myself. So I was trying to compile this from source with pip.

Unfortunately, here I am running into issues. Just trying on my direct environment, Python 3.11.3 I'm getting the following output:

⬢[sjoerd@toolbox ~]$ python3 -m pip install mplcairo
Defaulting to user installation because normal site-packages is not writeable
Collecting mplcairo
  Using cached mplcairo-0.5.tar.gz (93 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: matplotlib>=2.2 in ./.local/lib/python3.11/site-packages (from mplcairo) (3.6.2)
Requirement already satisfied: pillow in ./.local/lib/python3.11/site-packages (from mplcairo) (9.3.0)
Requirement already satisfied: pycairo>=1.16.0 in /usr/lib64/python3.11/site-packages (from mplcairo) (1.23.0)
Requirement already satisfied: contourpy>=1.0.1 in ./.local/lib/python3.11/site-packages (from matplotlib>=2.2->mplcairo) (1.0.6)
Requirement already satisfied: cycler>=0.10 in ./.local/lib/python3.11/site-packages (from matplotlib>=2.2->mplcairo) (0.11.0)
Requirement already satisfied: fonttools>=4.22.0 in ./.local/lib/python3.11/site-packages (from matplotlib>=2.2->mplcairo) (4.38.0)
Requirement already satisfied: kiwisolver>=1.0.1 in ./.local/lib/python3.11/site-packages (from matplotlib>=2.2->mplcairo) (1.4.4)
Requirement already satisfied: numpy>=1.19 in ./.local/lib/python3.11/site-packages (from matplotlib>=2.2->mplcairo) (1.23.4)
Requirement already satisfied: packaging>=20.0 in ./.local/lib/python3.11/site-packages (from matplotlib>=2.2->mplcairo) (21.3)
Requirement already satisfied: pyparsing>=2.2.1 in ./.local/lib/python3.11/site-packages (from matplotlib>=2.2->mplcairo) (3.0.9)
Requirement already satisfied: python-dateutil>=2.7 in /usr/lib/python3.11/site-packages (from matplotlib>=2.2->mplcairo) (2.8.2)
Requirement already satisfied: six>=1.5 in /usr/lib/python3.11/site-packages (from python-dateutil>=2.7->matplotlib>=2.2->mplcairo) (1.16.0)
Building wheels for collected packages: mplcairo
  Building wheel for mplcairo (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [71 lines of output]
      /var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/installer.py:27: SetuptoolsDeprecationWarning: setuptools.installer is deprecated. Requirements should be satisfied by a PEP 517 installer.
        warnings.warn(
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-311
      creating build/lib.linux-x86_64-cpython-311/mplcairo
      copying lib/mplcairo/wx.py -> build/lib.linux-x86_64-cpython-311/mplcairo
      copying lib/mplcairo/tk.py -> build/lib.linux-x86_64-cpython-311/mplcairo
      copying lib/mplcairo/qt.py -> build/lib.linux-x86_64-cpython-311/mplcairo
      copying lib/mplcairo/multipage.py -> build/lib.linux-x86_64-cpython-311/mplcairo
      copying lib/mplcairo/macosx.py -> build/lib.linux-x86_64-cpython-311/mplcairo
      copying lib/mplcairo/gtk_native.py -> build/lib.linux-x86_64-cpython-311/mplcairo
      copying lib/mplcairo/gtk.py -> build/lib.linux-x86_64-cpython-311/mplcairo
      copying lib/mplcairo/base.py -> build/lib.linux-x86_64-cpython-311/mplcairo
      copying lib/mplcairo/_version.py -> build/lib.linux-x86_64-cpython-311/mplcairo
      copying lib/mplcairo/_util.py -> build/lib.linux-x86_64-cpython-311/mplcairo
      copying lib/mplcairo/_backports.py -> build/lib.linux-x86_64-cpython-311/mplcairo
      copying lib/mplcairo/__init__.py -> build/lib.linux-x86_64-cpython-311/mplcairo
      running build_ext
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-1xf00giz/mplcairo_b82e7a7e4c35426c80a6092b0e7f6261/setup.py", line 189, in <module>
          setup(
        File "/tmp/pip-install-1xf00giz/mplcairo_b82e7a7e4c35426c80a6092b0e7f6261/setupext.py", line 54, in __new__
          setuptools.setup(**kwargs)
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/__init__.py", line 87, in setup
          return distutils.core.setup(**attrs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
                 ^^^^^^^^^^^^^^^^^^
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 968, in run_commands
          self.run_command(cmd)
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/dist.py", line 1217, in run_command
          super().run_command(command)
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
          cmd_obj.run()
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/wheel/bdist_wheel.py", line 325, in run
          self.run_command("build")
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
          self.distribution.run_command(command)
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/dist.py", line 1217, in run_command
          super().run_command(command)
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
          cmd_obj.run()
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/_distutils/command/build.py", line 132, in run
          self.run_command(cmd_name)
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
          self.distribution.run_command(command)
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/dist.py", line 1217, in run_command
          super().run_command(command)
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 986, in run_command
          cmd_obj.ensure_finalized()
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 109, in ensure_finalized
          self.finalize_options()
        File "/tmp/pip-install-1xf00giz/mplcairo_b82e7a7e4c35426c80a6092b0e7f6261/setup.py", line 123, in finalize_options
          get_pkgconfig(f"--atleast-version={MIN_CAIRO_VERSION}", "cairo")
        File "/tmp/pip-install-1xf00giz/mplcairo_b82e7a7e4c35426c80a6092b0e7f6261/setup.py", line 57, in get_pkgconfig
          return shlex.split(subprocess.check_output(["pkg-config", info, lib],
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/lib64/python3.11/subprocess.py", line 466, in check_output
          return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/lib64/python3.11/subprocess.py", line 571, in run
          raise CalledProcessError(retcode, process.args,
      subprocess.CalledProcessError: Command '['pkg-config', '--atleast-version=1.11.4', 'cairo']' returned non-zero exit status 1.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for mplcairo
  Running setup.py clean for mplcairo
Failed to build mplcairo
ERROR: Could not build wheels for mplcairo, which is required to install pyproject.toml-based projects
⬢[sjoerd@toolbox ~]$ 

In my Flatpak environment (on which Graphs will be compiled), I'm getting similar issues:

========================================================================
Building module python3-mplcairo in /var/home/sjoerd/.var/app/org.gnome.Builder/cache/gnome-builder/flatpak-builder/build/python3-mplcairo-28
========================================================================
Running: pip3 install --verbose --exists-action=i --no-index --find-links="file://${PWD}" --prefix=${FLATPAK_DEST} "mplcairo" --no-build-isolation
Using pip 23.1 from /usr/lib/python3.10/site-packages/pip (python 3.10)
Looking in links: file:///run/build/python3-mplcairo
Processing ./mplcairo-0.5.tar.gz
  Running command python setup.py egg_info
  /usr/lib/python3.10/site-packages/setuptools/__init__.py:85: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated. Requirements should be satisfied by a PEP 517 installer. If you are using pip, you can try `pip install --use-pep517`.
    dist.fetch_build_eggs(dist.setup_requires)
  running egg_info
  creating /tmp/pip-pip-egg-info-p0umywf3/mplcairo.egg-info
  writing /tmp/pip-pip-egg-info-p0umywf3/mplcairo.egg-info/PKG-INFO
  writing dependency_links to /tmp/pip-pip-egg-info-p0umywf3/mplcairo.egg-info/dependency_links.txt
  writing requirements to /tmp/pip-pip-egg-info-p0umywf3/mplcairo.egg-info/requires.txt
  writing top-level names to /tmp/pip-pip-egg-info-p0umywf3/mplcairo.egg-info/top_level.txt
  writing manifest file '/tmp/pip-pip-egg-info-p0umywf3/mplcairo.egg-info/SOURCES.txt'
  listing git files failed - pretending there aren't any
  reading manifest file '/tmp/pip-pip-egg-info-p0umywf3/mplcairo.egg-info/SOURCES.txt'
  adding license file 'LICENSE.txt'
  writing manifest file '/tmp/pip-pip-egg-info-p0umywf3/mplcairo.egg-info/SOURCES.txt'
  Preparing metadata (setup.py) ... done
Requirement already satisfied: matplotlib>=2.2 in /app/lib/python3.10/site-packages (from mplcairo) (3.7.1)
Requirement already satisfied: pillow in /app/lib/python3.10/site-packages (from mplcairo) (9.5.0)
Requirement already satisfied: pycairo>=1.16.0 in /usr/lib/python3.10/site-packages (from mplcairo) (1.23.0)
Requirement already satisfied: contourpy>=1.0.1 in /app/lib/python3.10/site-packages (from matplotlib>=2.2->mplcairo) (1.0.7)
Requirement already satisfied: cycler>=0.10 in /app/lib/python3.10/site-packages (from matplotlib>=2.2->mplcairo) (0.11.0)
Requirement already satisfied: fonttools>=4.22.0 in /app/lib/python3.10/site-packages (from matplotlib>=2.2->mplcairo) (4.39.3)
Requirement already satisfied: kiwisolver>=1.0.1 in /app/lib/python3.10/site-packages (from matplotlib>=2.2->mplcairo) (1.4.4)
Requirement already satisfied: numpy>=1.20 in /app/lib/python3.10/site-packages (from matplotlib>=2.2->mplcairo) (1.24.2)
Requirement already satisfied: packaging>=20.0 in /app/lib/python3.10/site-packages (from matplotlib>=2.2->mplcairo) (23.1)
Requirement already satisfied: pyparsing>=2.3.1 in /app/lib/python3.10/site-packages (from matplotlib>=2.2->mplcairo) (3.0.9)
Requirement already satisfied: python-dateutil>=2.7 in /app/lib/python3.10/site-packages (from matplotlib>=2.2->mplcairo) (2.8.2)
Requirement already satisfied: six>=1.5 in /usr/lib/python3.10/site-packages (from python-dateutil>=2.7->matplotlib>=2.2->mplcairo) (1.16.0)
Building wheels for collected packages: mplcairo
  Running command python setup.py bdist_wheel
  /usr/lib/python3.10/site-packages/setuptools/__init__.py:85: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated. Requirements should be satisfied by a PEP 517 installer. If you are using pip, you can try `pip install --use-pep517`.
    dist.fetch_build_eggs(dist.setup_requires)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-cpython-310
  creating build/lib.linux-x86_64-cpython-310/mplcairo
  copying lib/mplcairo/wx.py -> build/lib.linux-x86_64-cpython-310/mplcairo
  copying lib/mplcairo/tk.py -> build/lib.linux-x86_64-cpython-310/mplcairo
  copying lib/mplcairo/qt.py -> build/lib.linux-x86_64-cpython-310/mplcairo
  copying lib/mplcairo/multipage.py -> build/lib.linux-x86_64-cpython-310/mplcairo
  copying lib/mplcairo/macosx.py -> build/lib.linux-x86_64-cpython-310/mplcairo
  copying lib/mplcairo/gtk_native.py -> build/lib.linux-x86_64-cpython-310/mplcairo
  copying lib/mplcairo/gtk.py -> build/lib.linux-x86_64-cpython-310/mplcairo
  copying lib/mplcairo/base.py -> build/lib.linux-x86_64-cpython-310/mplcairo
  copying lib/mplcairo/_version.py -> build/lib.linux-x86_64-cpython-310/mplcairo
  copying lib/mplcairo/_util.py -> build/lib.linux-x86_64-cpython-310/mplcairo
  copying lib/mplcairo/_backports.py -> build/lib.linux-x86_64-cpython-310/mplcairo
  copying lib/mplcairo/__init__.py -> build/lib.linux-x86_64-cpython-310/mplcairo
  running build_ext
  error: <urlopen error [Errno -3] Temporary failure in name resolution>
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: /usr/bin/python3 -u -c '
  exec(compile('"'"''"'"''"'"'
  # This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py
  #
  # - It imports setuptools before invoking setup.py, to enable projects that directly
  #   import from `distutils.core` to work with newer packaging standards.
  # - It provides a clear error message when setuptools is not installed.
  # - It sets `sys.argv[0]` to the underlying `setup.py`, when invoking `setup.py` so
  #   setuptools doesn'"'"'t think the script is `-c`. This avoids the following warning:
  #     manifest_maker: standard file '"'"'-c'"'"' not found".
  # - It generates a shim setup.py, for handling setup.cfg-only projects.
  import os, sys, tokenize
  
  try:
      import setuptools
  except ImportError as error:
      print(
          "ERROR: Can not execute `setup.py` since setuptools is not available in "
          "the build environment.",
          file=sys.stderr,
      )
      sys.exit(1)
  
  __file__ = %r
  sys.argv[0] = __file__
  
  if os.path.exists(__file__):
      filename = __file__
      with tokenize.open(__file__) as f:
          setup_py_code = f.read()
  else:
      filename = "<auto-generated setuptools caller>"
      setup_py_code = "from setuptools import setup; setup()"
  
  exec(compile(setup_py_code, filename, "exec"))
  '"'"''"'"''"'"' % ('"'"'/tmp/pip-install-bd6was80/mplcairo_524734b2e1c44ceca2a5540ab16a5795/setup.py'"'"',), "<pip-setuptools-caller>", "exec"))' bdist_wheel -d /tmp/pip-wheel-_n6i0o8k
  cwd: /tmp/pip-install-bd6was80/mplcairo_524734b2e1c44ceca2a5540ab16a5795/
  Building wheel for mplcairo (setup.py) ... error
  ERROR: Failed building wheel for mplcairo
  Running setup.py clean for mplcairo
  Running command python setup.py clean
  /usr/lib/python3.10/site-packages/setuptools/__init__.py:85: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated. Requirements should be satisfied by a PEP 517 installer. If you are using pip, you can try `pip install --use-pep517`.
    dist.fetch_build_eggs(dist.setup_requires)
  running clean
  removing 'build/lib.linux-x86_64-cpython-310' (and everything under it)
  'build/bdist.linux-x86_64' does not exist -- can't clean it
  'build/scripts-3.10' does not exist -- can't clean it
Failed to build mplcairo
ERROR: Could not build wheels for mplcairo, which is required to install pyproject.toml-based projects


I tried bundling all dependencies seperately into my Flatpak, but that doesn't change anything. It works fine with the wheel, but because we ship Graphs for both x86 and aarch64 architectures, this is not an option right now. The flatpak environment runs on Python 3.10.6. Which should be compatibile with mplcairo.

Do you have any ideas why the pip install seems to be broken?

Edit: Meant the aarch64 architecture that's an issue for me with the wheels. Got it confused with amd64 🤦

Just to add, the latest requirements are all installed:

⬢[sjoerd@toolbox Graphs]$ pip install pybind11
Defaulting to user installation because normal site-packages is not writeable
Collecting pybind11
  Using cached pybind11-2.10.4-py3-none-any.whl (222 kB)
Installing collected packages: pybind11
Successfully installed pybind11-2.10.4
⬢[sjoerd@toolbox Graphs]$ pip install pycairo
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pycairo in /usr/lib64/python3.11/site-packages (1.23.0)
⬢[sjoerd@toolbox Graphs]$ pip install git+https://github.com/matplotlib/mplcairoDefaulting to user installation because normal site-packages is not writeable
Collecting git+https://github.com/matplotlib/mplcairo
  Cloning https://github.com/matplotlib/mplcairo to /tmp/pip-req-build-qgfilen9
  Running command git clone --filter=blob:none --quiet https://github.com/matplotlib/mplcairo /tmp/pip-req-build-qgfilen9
  Resolved https://github.com/matplotlib/mplcairo to commit 44b09d7e4941dd19311a0b166452c408eab1aad6
  Preparing metadata (setup.py) ... done
Requirement already satisfied: matplotlib>=2.2 in /var/home/sjoerd/.local/lib/python3.11/site-packages (from mplcairo==0.5.post27+g44b09d7) (3.6.2)
Requirement already satisfied: pillow in /var/home/sjoerd/.local/lib/python3.11/site-packages (from mplcairo==0.5.post27+g44b09d7) (9.3.0)
Requirement already satisfied: pycairo>=1.16.0 in /usr/lib64/python3.11/site-packages (from mplcairo==0.5.post27+g44b09d7) (1.23.0)
Requirement already satisfied: contourpy>=1.0.1 in /var/home/sjoerd/.local/lib/python3.11/site-packages (from matplotlib>=2.2->mplcairo==0.5.post27+g44b09d7) (1.0.6)
Requirement already satisfied: cycler>=0.10 in /var/home/sjoerd/.local/lib/python3.11/site-packages (from matplotlib>=2.2->mplcairo==0.5.post27+g44b09d7) (0.11.0)
Requirement already satisfied: fonttools>=4.22.0 in /var/home/sjoerd/.local/lib/python3.11/site-packages (from matplotlib>=2.2->mplcairo==0.5.post27+g44b09d7) (4.38.0)
Requirement already satisfied: kiwisolver>=1.0.1 in /var/home/sjoerd/.local/lib/python3.11/site-packages (from matplotlib>=2.2->mplcairo==0.5.post27+g44b09d7) (1.4.4)
Requirement already satisfied: numpy>=1.19 in /var/home/sjoerd/.local/lib/python3.11/site-packages (from matplotlib>=2.2->mplcairo==0.5.post27+g44b09d7) (1.23.4)
Requirement already satisfied: packaging>=20.0 in /var/home/sjoerd/.local/lib/python3.11/site-packages (from matplotlib>=2.2->mplcairo==0.5.post27+g44b09d7) (21.3)
Requirement already satisfied: pyparsing>=2.2.1 in /var/home/sjoerd/.local/lib/python3.11/site-packages (from matplotlib>=2.2->mplcairo==0.5.post27+g44b09d7) (3.0.9)
Requirement already satisfied: python-dateutil>=2.7 in /usr/lib/python3.11/site-packages (from matplotlib>=2.2->mplcairo==0.5.post27+g44b09d7) (2.8.2)
Requirement already satisfied: six>=1.5 in /usr/lib/python3.11/site-packages (from python-dateutil>=2.7->matplotlib>=2.2->mplcairo==0.5.post27+g44b09d7) (1.16.0)
Building wheels for collected packages: mplcairo
  Building wheel for mplcairo (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [71 lines of output]
      /var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/installer.py:27: SetuptoolsDeprecationWarning: setuptools.installer is deprecated. Requirements should be satisfied by a PEP 517 installer.
        warnings.warn(
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-311
      creating build/lib.linux-x86_64-cpython-311/mplcairo
      copying lib/mplcairo/_version.py -> build/lib.linux-x86_64-cpython-311/mplcairo
      copying lib/mplcairo/wx.py -> build/lib.linux-x86_64-cpython-311/mplcairo
      copying lib/mplcairo/tk.py -> build/lib.linux-x86_64-cpython-311/mplcairo
      copying lib/mplcairo/qt.py -> build/lib.linux-x86_64-cpython-311/mplcairo
      copying lib/mplcairo/multipage.py -> build/lib.linux-x86_64-cpython-311/mplcairo
      copying lib/mplcairo/macosx.py -> build/lib.linux-x86_64-cpython-311/mplcairo
      copying lib/mplcairo/gtk_native.py -> build/lib.linux-x86_64-cpython-311/mplcairo
      copying lib/mplcairo/gtk.py -> build/lib.linux-x86_64-cpython-311/mplcairo
      copying lib/mplcairo/base.py -> build/lib.linux-x86_64-cpython-311/mplcairo
      copying lib/mplcairo/_util.py -> build/lib.linux-x86_64-cpython-311/mplcairo
      copying lib/mplcairo/_backports.py -> build/lib.linux-x86_64-cpython-311/mplcairo
      copying lib/mplcairo/__init__.py -> build/lib.linux-x86_64-cpython-311/mplcairo
      running build_ext
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-req-build-qgfilen9/setup.py", line 153, in <module>
          setup(
        File "/tmp/pip-req-build-qgfilen9/setupext.py", line 57, in setup
          setuptools.setup(**kwargs)
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/__init__.py", line 87, in setup
          return distutils.core.setup(**attrs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
                 ^^^^^^^^^^^^^^^^^^
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 968, in run_commands
          self.run_command(cmd)
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/dist.py", line 1217, in run_command
          super().run_command(command)
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
          cmd_obj.run()
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/wheel/bdist_wheel.py", line 325, in run
          self.run_command("build")
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
          self.distribution.run_command(command)
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/dist.py", line 1217, in run_command
          super().run_command(command)
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
          cmd_obj.run()
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/_distutils/command/build.py", line 132, in run
          self.run_command(cmd_name)
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
          self.distribution.run_command(command)
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/dist.py", line 1217, in run_command
          super().run_command(command)
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 986, in run_command
          cmd_obj.ensure_finalized()
        File "/var/home/sjoerd/.local/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 109, in ensure_finalized
          self.finalize_options()
        File "/tmp/pip-req-build-qgfilen9/setup.py", line 112, in finalize_options
          get_pkgconfig(f"cairo >= {MIN_CAIRO_VERSION}")
        File "/tmp/pip-req-build-qgfilen9/setup.py", line 46, in get_pkgconfig
          return shlex.split(subprocess.check_output(["pkg-config", *args],
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/lib64/python3.11/subprocess.py", line 466, in check_output
          return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/lib64/python3.11/subprocess.py", line 571, in run
          raise CalledProcessError(retcode, process.args,
      subprocess.CalledProcessError: Command '['pkg-config', 'cairo >= 1.13.1']' returned non-zero exit status 1.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for mplcairo
  Running setup.py clean for mplcairo
Failed to build mplcairo
ERROR: Could not build wheels for mplcairo, which is required to install pyproject.toml-based projects

`

Maybe useful information, but I tried this on my other development toolbox that is running the old Fedora 36 with Python 3.10.8, and there the pip install works fine. So it seems this maybe a Python 3.11 compatibility issue.

Then my issues with the Flatpak install from source may be a separate issue perhaps.

Further investigations gave me a way to get it installed on the Flatpak build, so that indeed seems a seperate issue. The issue with Pip in python 3.11 remains.

The "solution" with Flatpak is that I need to give it access to the network on build-time. Does mplcairo need network access during compilation? None of my other dependencies need this, so it seems a bit odd. Is it possible to obtain a version where this is not required, as I'm not sure if this is acceptable on Flathub where Graphs is published.

Just for future reference in case anyone stumbles upon this, the relevant (working) part of the Flatpak manifest now looks like this:

            "name": "python3-mplcairo",
            "buildsystem": "simple",
	"build-options": {
		"build-args": [ "--share=network" ]
	},            
            "build-commands": [
 		   "pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"mplcairo\" --no-build-isolation"
            ],
            "sources": [
                {
		      "type": "file",
		      "url": "https://files.pythonhosted.org/packages/73/4c/d30237614ad1c6e7b6987346e72c60db61145a09e09dd8ff28217da390db/mplcairo-0.5.tar.gz",
		      "sha256": "3d2595431ec968399ac8d63ea4b6f35baecdd071a14a031d178da3cc83fe652e"
                }
            ]

Edit: Again, I'm mostly adding this in case anyone has the same issue and stumbles upon this. But I asked and build arguments are not allowed in Flathub. So this is not a solution for Flatpak apps if you actually want to distribute them.

I think the relevant info is at https://github.com/matplotlib/mplcairo#unix?

The following additional dependencies are required:

[...]

- cairo and FreeType headers, and pkg-config information to locate them.

  If using conda, they can be installed using ::

     conda install -y -c conda-forge pycairo pkg-config

  as pycairo (also a dependency) depends on cairo, which depends on freetype.
  Note that cairo and pkg-config from the ``anaconda`` channel will *not* work.

  On Linux, they can also be installed with your distribution's package manager
  (Arch: ``cairo``, Debian/Ubuntu: ``libcairo2-dev``, Fedora: ``cairo-devel``).

Raqm (≥0.2) headers are also needed, but will be automatically downloaded if
not found.

Thank you, installing cairo-devel indeed got me further to problems with my gcc compiler. Installing the Development Tools group in my toolbox solved those remaining issues, and indeed it installed fine. The reason it worked fine from my Fedora 36 toolbox, is that I've had those tools already installed in there.

The problem with Flatpak probably has something to do with my manifest, it has happened before that it doesn't build nicely from source, and for those packages I usually just switched to the wheels available at PyPi. Either way that was not the core point of this issue and it's not definitely related to this module either, I thought they were hence naming that here as well. Installing from pip indeed works fine with the given instructions, my apologies for my poor reading comprehension when I went through this first. Closing this issue.

No worries, feel free to make any suggestions as to how this documentation could be made clearer (while sticking to a single-file README...).