!rWxyQqNqMUDLECdsIf:blad.is

Poetry2nix

323 Members
https://github.com/nix-community/poetry2nix62 Servers

Load older messages


SenderMessageTime
16 Oct 2024
@artturin:matrix.orgArtturin
In reply to @artturin:matrix.org

Weird, override exists for it on unstable and nixos-24.05

nix-repl> python3Packages.tokenizers.override
{ __functionArgs = { ... }; __functor = «lambda @ /home/artturin/nixpkgs/lib/trivial.nix:895:19»; }
Oh yeah poetry2nix doesn't use those
04:32:51
@artturin:matrix.orgArtturinI think04:33:55
@artturin:matrix.orgArtturinI wonder if this works https://github.com/nix-community/poetry2nix/blob/8a18db56dd62edd26458a87e4d335b7df84c3f3f/overrides/default.nix#L88404:34:09
@artturin:matrix.orgArtturin Maybe missing a lib.makeOverridable call somewhere 04:34:34
@artturin:matrix.orgArtturin
In reply to @phanirithvij:matrix.org

maybe offtopic and/or unrelated but I have the same error with override with home-manager with https://github.com/nix-community/home-manager/pull/5930 when I do nix build .#test-espanso-basic-configuration

       error: attribute 'override' missing

       at /nix/store/60sn02zhawl3kwn0r515zff3h6hg6ydz-source/pkgs/top-level/all-packages.nix:4867:21:

         4866|   };
         4867|   espanso-wayland = espanso.override {
             |                     ^
         4868|     x11Support = false;

Not using callPackage (which applies makeOverridable) or makeOverridable will cause override to be missing

callPackage is used so neither of those are the problem https://github.com/NixOS/nixpkgs/blob/6e918e75e8bed152f24787aaad718649dc1963fe/pkgs/top-level/all-packages.nix#L4858

04:43:34
@artturin:matrix.orgArtturinWrong room anyways, I looked and couldn't see the problem.04:54:07
@akshaykarle:matrix.orgakshaykarle joined the room.09:56:30
18 Oct 2024
@kritnich:kritni.ch@kritnich:kritni.ch left the room.11:01:03
19 Oct 2024
@opacity=0:matrix.orgopacity=0 joined the room.15:07:29
20 Oct 2024
@laurents:fsfe.orglaurents

Hello! I'm trying to package a python app into a docker image with poetry2nix and then streamLayeredImage. I'm struggling to get my own code into the result. My code is organised like:

+ my_project
|- + ofd_runner
|   | ...
| pyproject.toml
| poetry.lock
| flake.nix

In flake.nix I do:

myEnv = pkgs.poetry2nix.mkPoetryEnv {
  projectDir = ./.;
  preferWheels = true;
};
dockerImage = pkgs.docker.streamLayeredImage {
          name = "ofd_user_code";
          tag = "latest";
          contents = [
            pkgs.bash
            pkgs.coreutils
            ofdUserCodeEnv
          ];
          config = {
            Cmd = [
              "${myEnv}/bin/dagster"
              "api"
              "grpc"
              "-h"
              "0.0.0.0"
              "-p"
              "4000"
              "-m"
              "ofd_runner"
            ];
            Env = [
              "DAGSTER_HOME=${dagsterHome}"
            ];
            WorkingDir = "${myEnv}/lib/python3.11/site-packages";
          };

In pyproject.toml, I have a set of dependencies which end up in my docker image, I can do import polars in the python in that docker image, but import ofd_runner won't work. Why is that? How do I get my own code in ofd_runner to land in my image?

19:19:23
@laurents:fsfe.orglaurents
In reply to @laurents:fsfe.org

Hello! I'm trying to package a python app into a docker image with poetry2nix and then streamLayeredImage. I'm struggling to get my own code into the result. My code is organised like:

+ my_project
|- + ofd_runner
|   | ...
| pyproject.toml
| poetry.lock
| flake.nix

In flake.nix I do:

myEnv = pkgs.poetry2nix.mkPoetryEnv {
  projectDir = ./.;
  preferWheels = true;
};
dockerImage = pkgs.docker.streamLayeredImage {
          name = "ofd_user_code";
          tag = "latest";
          contents = [
            pkgs.bash
            pkgs.coreutils
            ofdUserCodeEnv
          ];
          config = {
            Cmd = [
              "${myEnv}/bin/dagster"
              "api"
              "grpc"
              "-h"
              "0.0.0.0"
              "-p"
              "4000"
              "-m"
              "ofd_runner"
            ];
            Env = [
              "DAGSTER_HOME=${dagsterHome}"
            ];
            WorkingDir = "${myEnv}/lib/python3.11/site-packages";
          };

In pyproject.toml, I have a set of dependencies which end up in my docker image, I can do import polars in the python in that docker image, but import ofd_runner won't work. Why is that? How do I get my own code in ofd_runner to land in my image?

apparently I had to use mkPoetryApplication and then use .dependencyEnv to get my code in there.
22:56:03
21 Oct 2024
@adrblo:matrix.orgadrblo joined the room.14:36:10
@opacity=0:matrix.orgopacity=0 Hi, I am trying to package a python package using poetry2nix. Unfortunately i need to override both the buildInputs and one of the dependencies. I am following the relevant edge cases documentation, however I am stuck with the error error: value is a set while a list was expected.
I presume this is because defaultPoetryOverrides.extend and overrides.withDefaults do not work together. Has anyone encountered this issue before?
14:39:28
@opacity=0:matrix.orgopacity=0

This is the corresponding flake:

  description = "SMURFS";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    poetry2nix.url = "github:nix-community/poetry2nix";
  };

  outputs = { self, nixpkgs, poetry2nix }:
    let
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};smurfs =
        let
          inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) defaultPoetryOverrides overrides mkPoetryApplication;

          pypkgs-build-requirements = {
            lightkurve = [ "setuptools" ];
            fbpca = [ "setuptools" ];
            memoization = [ "setuptools" ];
          };

          p2n-overrides = defaultPoetryOverrides.extend
            (final: prev:
              builtins.mapAttrs
                (package: build-requirements:
                  (builtins.getAttr package prev).overridePythonAttrs (old: {
                    buildInputs = (old.buildInputs or [ ]) ++
                      (builtins.map
                        (pkg:
                          if builtins.isString pkg
                          then builtins.getAttr pkg prev
                          else pkg)
                        build-requirements);
                  }))
                pypkgs-build-requirements
            );

          lightkurve-override = final: prev: {
            lightkurve = prev.lightkurve.overridePythonAttrs
              (old: rec {
                version = "2.5.0";
                src = prev.pkgs.fetchFromGitHub {
                  owner = "Alpha-Ursae-Minoris";
                  repo = "lightkurve";
                  rev = "1ec6609da1bd980883593ac1a6354639310f773c";
                  hash = "sha256-6/2CiQ1DMTIX4XV+WkeyI6uBKe032VZ4kHU3FSHhie8=";
                };
              });
          };

          combined-overrides = p2n-overrides ++ lightkurve-override;
        in
        mkPoetryApplication
          {
            projectDir = ./.;
            overrides = overrides.withDefaults combined-overrides;
            #preferWheels = true;
          };
    in
    {
      apps.${system}.default = {
        type = "app";
        # Replace <script> with the name in the [tool.poetry.scripts] section of your pyproject.toml
        program = "${smurfs}/bin/<smurfs>";
      };
    };
}
14:41:04
@opacity=0:matrix.orgopacity=0 *

This is the corresponding flake:

  description = "SMURFS";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    poetry2nix.url = "github:nix-community/poetry2nix";
  };

  outputs = { self, nixpkgs, poetry2nix }:
    let
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};
      smurfs =
        let
          inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) defaultPoetryOverrides overrides mkPoetryApplication;

          pypkgs-build-requirements = {
            lightkurve = [ "setuptools" ];
            fbpca = [ "setuptools" ];
            memoization = [ "setuptools" ];
          };

          p2n-overrides = defaultPoetryOverrides.extend
            (final: prev:
              builtins.mapAttrs
                (package: build-requirements:
                  (builtins.getAttr package prev).overridePythonAttrs (old: {
                    buildInputs = (old.buildInputs or [ ]) ++
                      (builtins.map
                        (pkg:
                          if builtins.isString pkg
                          then builtins.getAttr pkg prev
                          else pkg)
                        build-requirements);
                  }))
                pypkgs-build-requirements
            );

          lightkurve-override = final: prev: {
            lightkurve = prev.lightkurve.overridePythonAttrs
              (old: rec {
                version = "2.5.0";
                src = prev.pkgs.fetchFromGitHub {
                  owner = "Alpha-Ursae-Minoris";
                  repo = "lightkurve";
                  rev = "1ec6609da1bd980883593ac1a6354639310f773c";
                  hash = "sha256-6/2CiQ1DMTIX4XV+WkeyI6uBKe032VZ4kHU3FSHhie8=";
                };
              });
          };

          combined-overrides = p2n-overrides ++ lightkurve-override;
        in
        mkPoetryApplication
          {
            projectDir = ./.;
            overrides = overrides.withDefaults combined-overrides;
            #preferWheels = true;
          };
    in
    {
      apps.${system}.default = {
        type = "app";
        # Replace <script> with the name in the [tool.poetry.scripts] section of your pyproject.toml
        program = "${smurfs}/bin/<smurfs>";
      };
    };
}
14:42:14
@ersei:ersei.net@ersei:ersei.net left the room.14:53:00
@adrblo:matrix.orgadrblo set a profile picture.15:08:59
@artur:glasgow.socialmoved to @amadaluzia:tchncs.de changed their display name from (lambda (f l) (format nil "~a ~a")) "Artur" "Manuel" to (artur 'manuel).20:03:22
23 Oct 2024
@virtu:matrix.imvirtu I'm building a python application that has bcc as a dependency which provides python bindings. What's the best way to get these bindings into my PYTHONPATH for both a package and a devshell? 08:37:32
@luna-null:matrix.orgluna-null changed their display name from Autumn to luna-null.09:49:14
@truh:matrix.orgtruhI'd try starting withe build expression in the nixpkgs repo and replacing buildPythonApplication with buildPythonPackage and then put that into the p2n overrides.10:25:52
@truh:matrix.orgtruh* I'd try starting with the build expression in the nixpkgs repo and replacing buildPythonApplication with buildPythonPackage and then put that into the p2n overrides.10:26:07
@adrblo:matrix.orgadrblo changed their display name from Adrian Block to adrblo.20:15:31
@nebucatnetzer13:matrix.orgnebucatnetzer13 left the room.21:42:20
25 Oct 2024
@lholh:matrix.org@lholh:matrix.org joined the room.03:55:22
@renato-trevisan:matrix.orgRenato Trevisan joined the room.07:17:32
@lholh:matrix.org@lholh:matrix.org left the room.22:42:33
27 Oct 2024
@kiako:mozilla.org@kiako:mozilla.org joined the room.19:37:09
29 Oct 2024
@picog:matrix.orgPico

Hi folks.

I tried to bump python to 3.12 for a project that uses poetry2nix
python-ldap seems to fail to build now with

  /nix/store/89arss4li8g0g0nabm8a1q6dalzamvph-python3-3.12.4/bin/python3.12 /build/tmpid30f39w.py
  Traceback (most recent call last):
    File "/build/tmpid30f39w.py", line 1, in <module>
      from distutils.util import byte_compile
  ModuleNotFoundError: No module named 'distutils'
  error: command '/nix/store/89arss4li8g0g0nabm8a1q6dalzamvph-python3-3.12.4/bin/python3.12' failed with exit code 1
  error: subprocess-exited-with-error

  × Building wheel for python-ldap (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> See above for output

Disutils was removed from the standard library but this should still work because setuptools provides a replacement?
Any idea what could be going wrong?

14:01:04
@truh:matrix.orgtruhmaybe you need to add setuptools to the buildInputs?14:27:56

Show newer messages


Back to Room ListRoom Version: 6