Hi all,
Trying to build a python development using flakes and direnv. Having issues with matplotlib actually producing a plot as it seems to not default to having a GUI backend.
I have tried to use tkinter (using poetry and as an external package) but for some reason it shows this error: ModuleNotFoundError: No module named ‘_tkinter’ when running python code in the shell, which led me to try using GTK3.
I believe I am close to getting GTK3 to work as I am able to install its requirements pycairo and PyGObject. However, when I run nix develop I get the following error:
> Found ninja-1.11.1 at /nix/store/ykfsx9m7vvp8xq3i4vgkymcx51a7ckjy-ninja-1.11.1/bin/ninja
> meson: enabled parallel building
> building
> Executing pipBuildPhase
> Creating a wheel...
> WARNING: The directory '/homeless-shelter/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
> ERROR: Directory '.' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.
I am not sure how to resolve this. In the little I can find from google it seems that I may need to override the pycairo package, but I am not sure how to go about doing this as I am still new to the Nix ecosystem. I have tried downgrading pycairo to 1.21.0 to see if this impacted it but no change.
Any advice on either error would be greatly appreciated!
This is my flake:
{
description = "Application packaged using poetry2nix";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
flake-utils.lib.eachDefaultSystem (system:
let
# see https://github.com/nix-community/poetry2nix/tree/master#api for more functions and examples.
inherit (poetry2nix.legacyPackages.${system}) mkPoetryEnv;
pkgs = import nixpkgs {inherit system;};
python = pkgs.python310;
pythonEnv = mkPoetryEnv {
inherit python;
projectDir = ./.;
preferWheels = true;
};
in
{
#packages.default = mkPoetryEnv {
# projectDir = ./.;
# python = pkgs.python310;
#};
devShells.default = pkgs.mkShell {
buildInputs = [pythonEnv];
packages = [
poetry2nix.packages.${system}.poetry
pkgs.cairo
pkgs.pkg-config
pkgs.gobject-introspection
pkgs.tk
];
};
});
}
This is my pyproject.toml
[tool.poetry]
name = "test"
version = "0.1.0"
description = ""
authors = ["djmaupin <dmaupin@bond.edu.au>"]
readme = "README.md"
[tool.poetry.dependencies]
python = ">=3.10,<3.12"
numpy = "^1.24.2"
scipy = "^1.10.1"
pandas = "^1.5.3"
matplotlib = "^3.7.1"
setuptools = "^67.6.0"
ninja = "^1.11.1"
pygobject = "^3.44.0"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"