!rWxyQqNqMUDLECdsIf:blad.is

Poetry2nix

314 Members
https://github.com/nix-community/poetry2nix57 Servers

You have reached the beginning of time (for this room).


SenderMessageTime
26 Jan 2024
@tyberius_prime:matrix.orgTyberiusPrime (smilodon inopinatus)
In reply to @angryant:envs.net
I am having trouble building a Poetry project which has tiktoken as a dependency. I am assuming the issue is related to https://github.com/nix-community/poetry2nix/issues/261 - but I am unsure how to fix it.

I think your issue is that your overlay is expecing there to be a <nixpkgs>.tiktoken, when it would be at least <nixpkgs>.python310Packages.tiktoken or such.

Are you using mkPoetryApplication or the like?
here's a minimal example taht does this for autograd-gamma (and setuptools) in a project of mine

{
  description = "Application packaged using poetry2nix";

  inputs = {
    flake-utils.url = "github:numtide/flake-utils";
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    poetry2nix = {
      url = "github:TyberiusPrime/poetry2nix/rpds-py";
      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.
      pkgs = nixpkgs.legacyPackages.${system};
      inherit (poetry2nix.lib.mkPoetry2Nix {inherit pkgs;}) mkPoetryApplication overrides;
    in {
      packages = {
        myapp = mkPoetryApplication {
          projectDir = self;
          preferWheels = true;
          overrides =
            overrides.withDefaults
            (
              self: super: {
                autograd-gamma = super.autograd-gamma.overridePythonAttrs (old: {
                  propagatedBuildInputs = (old.propagatedBuildInputs or []) ++ [self.setuptools];
                });
                           }
            );
        };
        default = self.packages.${system}.myapp;
      };

      devShells.default = pkgs.mkShell {
        inputsFrom = [self.packages.${system}.myapp];
        packages = [pkgs.poetry];
      };
    });
}
10:45:02
@angryant:envs.net@angryant:envs.net
In reply to @tyberius_prime:matrix.org

I think your issue is that your overlay is expecing there to be a <nixpkgs>.tiktoken, when it would be at least <nixpkgs>.python310Packages.tiktoken or such.

Are you using mkPoetryApplication or the like?
here's a minimal example taht does this for autograd-gamma (and setuptools) in a project of mine

{
  description = "Application packaged using poetry2nix";

  inputs = {
    flake-utils.url = "github:numtide/flake-utils";
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    poetry2nix = {
      url = "github:TyberiusPrime/poetry2nix/rpds-py";
      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.
      pkgs = nixpkgs.legacyPackages.${system};
      inherit (poetry2nix.lib.mkPoetry2Nix {inherit pkgs;}) mkPoetryApplication overrides;
    in {
      packages = {
        myapp = mkPoetryApplication {
          projectDir = self;
          preferWheels = true;
          overrides =
            overrides.withDefaults
            (
              self: super: {
                autograd-gamma = super.autograd-gamma.overridePythonAttrs (old: {
                  propagatedBuildInputs = (old.propagatedBuildInputs or []) ++ [self.setuptools];
                });
                           }
            );
        };
        default = self.packages.${system}.myapp;
      };

      devShells.default = pkgs.mkShell {
        inputsFrom = [self.packages.${system}.myapp];
        packages = [pkgs.poetry];
      };
    });
}

Thanks! I am using mkPoetryPackages as I just need the packages in a composite environment where the Poetry setup is only part of things. For now I have bypassed the issue via preferWheels, but I'll give your setup a closer look to see if I can sort things out without.

  poetry = pkgs.poetry2nix.mkPoetryPackages {
    projectDir = pythonPath;
    python = pkgs.python311;
    preferWheels = true;
  };
10:49:38
@angryant:envs.net@angryant:envs.net *

Thanks! I am using mkPoetryPackages as I just need the packages in a composite environment where the Poetry setup is only part of things. For now I have bypassed the issue via preferWheels, but I'll give your setup a closer look to see if I can sort things out without.

  poetry = pkgs.poetry2nix.mkPoetryPackages {
    projectDir = pythonPath;
    python = pkgs.python311;
    preferWheels = true;
  };
10:49:53
@tyberius_prime:matrix.orgTyberiusPrime (smilodon inopinatus)
In reply to @angryant:envs.net

Thanks! I am using mkPoetryPackages as I just need the packages in a composite environment where the Poetry setup is only part of things. For now I have bypassed the issue via preferWheels, but I'll give your setup a closer look to see if I can sort things out without.

  poetry = pkgs.poetry2nix.mkPoetryPackages {
    projectDir = pythonPath;
    python = pkgs.python311;
    preferWheels = true;
  };
mkPoetryPackages appears to take overrides as well.
10:50:37
@angryant:envs.net@angryant:envs.netI would assume as much. It is a very promising direction.10:51:17
@tyberius_prime:matrix.orgTyberiusPrime (smilodon inopinatus)Just beware, there's a minor issue with the order that overrides.withDefaults applies, and you might have to read the source and do it the other way around if you want to add an override where poetry2nix already has one.10:51:20

Show newer messages


Back to Room ListRoom Version: 6