Django + pycairo?

I’m working in a Django package (moving over from Replit), but I can’t install my pycairo dependency. I get the following error:

Collecting pycairo>=1.20.0 (from rlPyCairo<1,>=0.2.0->reportlab[pycairo]>=4.0.4->xhtml2pdf==0.2.13->-r requirements.txt (line 11))
  Using cached pycairo-1.27.0.tar.gz (661 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [20 lines of output]
      + meson setup /tmp/pip-install-vjvp1qnz/pycairo_1eadf329e0d54daab7515c41e911cf08 /tmp/pip-install-vjvp1qnz/pycairo_1eadf329e0d54daab7515c41e911cf08/.mesonpy-d2cxk8ay -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md -Dwheel=true -Dtests=false --native-file=/tmp/pip-install-vjvp1qnz/pycairo_1eadf329e0d54daab7515c41e911cf08/.mesonpy-d2cxk8ay/meson-python-native-file.ini
      The Meson build system
      Version: 1.5.1
      Source dir: /tmp/pip-install-vjvp1qnz/pycairo_1eadf329e0d54daab7515c41e911cf08
      Build dir: /tmp/pip-install-vjvp1qnz/pycairo_1eadf329e0d54daab7515c41e911cf08/.mesonpy-d2cxk8ay
      Build type: native build
      Project name: pycairo
      Project version: 1.27.0
      
      ../meson.build:1:0: ERROR: Unknown compiler(s): [['cc'], ['gcc'], ['clang'], ['nvc'], ['pgcc'], ['icc'], ['icx']]
      The following exception(s) were encountered:
      Running `cc --version` gave "[Errno 2] No such file or directory: 'cc'"
      Running `gcc --version` gave "[Errno 2] No such file or directory: 'gcc'"
      Running `clang --version` gave "[Errno 2] No such file or directory: 'clang'"
      Running `nvc --version` gave "[Errno 2] No such file or directory: 'nvc'"
      Running `pgcc --version` gave "[Errno 2] No such file or directory: 'pgcc'"
      Running `icc --version` gave "[Errno 2] No such file or directory: 'icc'"
      Running `icx --version` gave "[Errno 2] No such file or directory: 'icx'"
      
      A full log can be found at /tmp/pip-install-vjvp1qnz/pycairo_1eadf329e0d54daab7515c41e911cf08/.mesonpy-d2cxk8ay/meson-logs/meson-log.txt
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Any ideas on how I can work with this?

That is because Pycairo requires the following packages to be built on

packages = [
  pkgs.python3

  pkgs.stdenv.cc
  pkgs.pkg-config
  pkgs.cairo.dev
  pkgs.xorg.libX11.dev
  pkgs.xorg.libxcb.dev
  pkgs.xorg.xorgproto
];

Right, I totally get that it’s a dependency issue - but the question is: is there any way around this? gcc and clang are available if I execute them independently.

How so by way around this? According to pycairo error log showed that gcc and clang were not installed.

Edit: There is a file at .idx/dev.nix, which you can install those packages that I mentioned, once set it, click on rebuild environment and pycairo can be installed as expected

Yeah, that is what the error log says, but it’s not really true since gcc and clang are still accessible to the user.

If you type in gcc or clang in the interactive terminal, it will know to pull in the binaries and know how to use them…but for some reason neither poetry nor pip can use them…

I forgot to mention that you can install those packages on .idx/dev.nix file, once set it, you click on rebuild environment and it should work as expected