NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.28k stars 13.52k forks source link

Package request: python3Packages.opencv-contrib-python #273668

Open Alexnortung opened 8 months ago

Alexnortung commented 8 months ago

Project description

Wrapper package for OpenCV python bindings

I am trying to package Fooocus, but i am having some issues with setting up this package

Metadata


Add a :+1: reaction to issues you find important.

pinpox commented 6 months ago

Did you get it to run? Trying to run foocus aswell, without much luck yet. Maybe a venv? or FHS?

Alexnortung commented 6 months ago

@pinpox, I did not get it to work. I need the python package python3Packages.opencv-contrib-python.

pinpox commented 6 months ago

@Alexnortung In the meantime here is a flake.nix that @MayNiklas created to run Fooocus. It works like a charm but builds for quite a while:

{

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/a5a03b70486cc4d76c6f0dd1e872b4bb0449a781";
  };

  outputs = { self, nixpkgs }:
    let
      supportedSystems = [ "x86_64-linux" ];
      forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
      nixpkgsFor = forAllSystems (system:
        import nixpkgs {
          inherit system; overlays = [ ];
          config = { allowUnfree = true; cudaSupport = true; };
        });
    in
    {

      devShells = forAllSystems (system: {
        default = nixpkgsFor.${system}.callPackage
          ({ mkShell, python3, ... }:
            let
              python-with-packages = python3.withPackages
                (p: with p; [
                  einops
                  gradio
                  numpy
                  opencv4
                  packaging
                  pillow
                  psutil
                  pygit2
                  requests
                  safetensors
                  torch
                  torchsde
                  torchvision
                  transformers
                ]);
            in
            mkShell {
              buildInputs = [ python-with-packages ];
            })
          { };
      });
    };
}
MayNiklas commented 6 months ago

Still: packaging fooocus might be a bit more challenging than that:

In other words: A Nix package will require some patching / modifications on top of the upstream project.

With the flake.nix I've wrote, at least you will be able to execute the project.