!rWxyQqNqMUDLECdsIf:blad.is

Poetry2nix

313 Members
https://github.com/nix-community/poetry2nix58 Servers

Load older messages


SenderMessageTime
9 Mar 2022
@vengmark2:matrix.orgl0b0 joined the room.22:05:15
@vengmark2:matrix.orgl0b0 How should I expose the Poetry executable itself when using mkPoetryEnv? I need to be able to run things like poetry add while in the Nix shell. Using mkShell with buildInputs = [ pkgs.poetry ]; seems wrong. 22:07:17
@vengmark2:matrix.orgl0b0 * How should I expose the Poetry executable itself when using mkPoetryEnv? I need to be able to run things like poetry add while in the Nix shell. Using mkShell with buildInputs = [ pkgs.poetry ]; seems wrong. And using extraPackages = ps: [ ps.poetry ]; fails with a collision message. 22:10:01
10 Mar 2022
@mou_bugtracker:matrix.orgmou
In reply to @vengmark2:matrix.org
How should I expose the Poetry executable itself when using mkPoetryEnv? I need to be able to run things like poetry add while in the Nix shell. Using mkShell with buildInputs = [ pkgs.poetry ]; seems wrong. And using extraPackages = ps: [ ps.poetry ]; fails with a collision message.

i use this approach (snippet taken from flake.nix)

        devShell = (pkgs.poetry2nix.mkPoetryEnv {
          projectDir = ./.;
          editablePackageSources = {
            whateverpackagenames = ./.;
          };
        }).env.overrideAttrs (oldAttrs: {
          buildInputs = [ pkgs.poetry ];
        });

05:43:44
@mou_bugtracker:matrix.orgmou
In reply to @tompurl:destrocodpiece.wtf
Hello! I went through the tutorial on Youtube for packaging a Flask app. I would love to do the same thing with a Django app but I assume that I would need to figure out how to start my app from the tool.poetry.scripts command in pyproject.toml. However, I can't find any resource on how exactly to do that. Currently I run python manage.py runserver. How can I specify that command from poetry?
Sorry for late reply, but this question is about poetry itself, not about it integration with nix nor the poetry2nix. So i'm afraid you should try to search answer in diffrerent community. At least i'm not aware about soulution.
14:56:47
@tompurl:destrocodpiece.wtfTom Purl (he/him)
In reply to @mou_bugtracker:matrix.org
Sorry for late reply, but this question is about poetry itself, not about it integration with nix nor the poetry2nix. So i'm afraid you should try to search answer in diffrerent community. At least i'm not aware about soulution.

Thank you mou . I appreciate the help, and there's no reason to apologize :-)

Now that I've thought about the question a bit more, I think what I meant to ask was how does one package a Python app that is a server that has some sort of startup command?

It appears to me that poetry2nix will support the "startup command" only if it can be wrapped by the tools.poetry.scripts param in a pyproject.tompl file. Do you know if this is correct?

15:04:08
@mou_bugtracker:matrix.orgmou
In reply to @tompurl:destrocodpiece.wtf

Thank you mou . I appreciate the help, and there's no reason to apologize :-)

Now that I've thought about the question a bit more, I think what I meant to ask was how does one package a Python app that is a server that has some sort of startup command?

It appears to me that poetry2nix will support the "startup command" only if it can be wrapped by the tools.poetry.scripts param in a pyproject.tompl file. Do you know if this is correct?

i do not know anything about startup scripts, but as i'm aware, scripts declared in tools.poetry.scripts will be installed as part of package installation. Look at my snippet two message earlier (about devShell). I use it with direnv integration and it grants me environment there such scripts are in PATH.
15:10:27
@tompurl:destrocodpiece.wtfTom Purl (he/him)
In reply to @mou_bugtracker:matrix.org
i do not know anything about startup scripts, but as i'm aware, scripts declared in tools.poetry.scripts will be installed as part of package installation. Look at my snippet two message earlier (about devShell). I use it with direnv integration and it grants me environment there such scripts are in PATH.
Thank you!
15:11:02
@mou_bugtracker:matrix.orgmou
In reply to @tompurl:destrocodpiece.wtf
Thank you!
You can find more detailed example in poetry2nix README. direnv integration provided by nix-direnv. But i should note: i used only flake flavor and do not have any experience with plain nix
15:13:27
@vengmark2:matrix.orgl0b0
In reply to @mou_bugtracker:matrix.org

i use this approach (snippet taken from flake.nix)

        devShell = (pkgs.poetry2nix.mkPoetryEnv {
          projectDir = ./.;
          editablePackageSources = {
            whateverpackagenames = ./.;
          };
        }).env.overrideAttrs (oldAttrs: {
          buildInputs = [ pkgs.poetry ];
        });

Thank you! I ended up with a similar approach after a bunch of experimenting:
19:36:02
@vengmark2:matrix.orgl0b0
In reply to @mou_bugtracker:matrix.org

i use this approach (snippet taken from flake.nix)

        devShell = (pkgs.poetry2nix.mkPoetryEnv {
          projectDir = ./.;
          editablePackageSources = {
            whateverpackagenames = ./.;
          };
        }).env.overrideAttrs (oldAttrs: {
          buildInputs = [ pkgs.poetry ];
        });

*

Thank you! I ended up with a similar approach after a bunch of experimenting:

{ pkgs ? import
    (
      fetchTarball
        {
          name = "21.11-2022-03-08";
          url = "https://github.com/NixOS/nixpkgs/archive/bb3dee861440695ce6d8f43d0dd3a97622cb08c4.tar.gz";
          sha256 = "0j94fz656a0xf3s7kvi8p16p52186ks6r3m1gv8i2zmiinlvv5v3";
        })
    { }
}:
let
  python = pkgs.python38;
  poetryEnv = pkgs.poetry2nix.mkPoetryEnv {
    inherit python;
    projectDir = builtins.path { path = ./.; name = "geostore"; };
    extraPackages = ps: [ ps.pip ];
  };
in
pkgs.mkShell {
  buildInputs = [
    (pkgs.poetry.override {
      inherit python;
    })
    poetryEnv
  ];
19:37:58
@vengmark2:matrix.orgl0b0 *

Thank you! I ended up with a similar approach after a bunch of experimenting:

{ pkgs ? import
    (
      fetchTarball
        {
          name = "21.11-2022-03-08";
          url = "https://github.com/NixOS/nixpkgs/archive/bb3dee861440695ce6d8f43d0dd3a97622cb08c4.tar.gz";
          sha256 = "0j94fz656a0xf3s7kvi8p16p52186ks6r3m1gv8i2zmiinlvv5v3";
        })
    { }
}:
let
  python = pkgs.python38;
  poetryEnv = pkgs.poetry2nix.mkPoetryEnv {
    inherit python;
    projectDir = builtins.path { path = ./.; name = "geostore"; };
    extraPackages = ps: [ ps.pip ];
  };
in
pkgs.mkShell {
  buildInputs = [
    (pkgs.poetry.override {
      inherit python;
    })
    poetryEnv
  ];
}```
19:38:09
@vengmark2:matrix.orgl0b0 *

Thank you! I ended up with a similar approach after a bunch of experimenting:

{ pkgs ? import
    (
      fetchTarball
        {
          name = "21.11-2022-03-08";
          url = "https://github.com/NixOS/nixpkgs/archive/bb3dee861440695ce6d8f43d0dd3a97622cb08c4.tar.gz";
          sha256 = "0j94fz656a0xf3s7kvi8p16p52186ks6r3m1gv8i2zmiinlvv5v3";
        })
    { }
}:
let
  python = pkgs.python38;
  poetryEnv = pkgs.poetry2nix.mkPoetryEnv {
    inherit python;
    projectDir = builtins.path { path = ./.; name = "geostore"; };
    extraPackages = ps: [ ps.pip ];
  };
in
pkgs.mkShell {
  buildInputs = [
    (pkgs.poetry.override {
      inherit python;
    })
    poetryEnv
  ];
}
19:38:19
@vengmark2:matrix.orgl0b0 *

Thank you! I ended up with a similar approach after a bunch of experimenting:

{ pkgs ? import
    (
      fetchTarball
        {
          name = "nixpkgs-21.11-2022-01-03";
          url = "https://github.com/NixOS/nixpkgs/archive/08370e1e271f6fe00d302bebbe510fe0e2c611ca.tar.gz";
          sha256 = "1s9g0vry5jrrvvna250y538i99zy12xy3bs7m3gb4iq64qhyd6bq";
        })
    { }
}:
let
  python = pkgs.python38;
  poetryEnv = pkgs.poetry2nix.mkPoetryEnv {
    projectDir = builtins.path { path = ./.; name = "geostore"; };
    inherit python;
    extraPackages = ps: [ ps.pip ];
  };
in
poetryEnv.env.overrideAttrs (
  oldAttrs: {
    buildInputs = [
      pkgs.nodePackages.aws-azure-login
      (pkgs.poetry.override {
        inherit python;
      })
    ];
  }
)
19:40:15
@vengmark2:matrix.orgl0b0 *

Thank you! I ended up with a similar approach after a bunch of experimenting:

{ pkgs ? import
    (
      fetchTarball
        {
          name = "nixpkgs-21.11-2022-01-03";
          url = "https://github.com/NixOS/nixpkgs/archive/08370e1e271f6fe00d302bebbe510fe0e2c611ca.tar.gz";
          sha256 = "1s9g0vry5jrrvvna250y538i99zy12xy3bs7m3gb4iq64qhyd6bq";
        })
    { }
}:
let
  python = pkgs.python38;
  poetryEnv = pkgs.poetry2nix.mkPoetryEnv {
    projectDir = builtins.path { path = ./.; name = "geostore"; };
    inherit python;
    extraPackages = ps: [ ps.pip ];
  };
in
poetryEnv.env.overrideAttrs (
  oldAttrs: {
    buildInputs = [
      pkgs.nodePackages.aws-azure-login
      (pkgs.poetry.override {
        inherit python;
      })
    ];
  }
)

This way the poetry2nix env and the Nix shell end up with the same Python environment, rather than the same Python interpreter in two different Nix store directories.

19:41:53
@vengmark2:matrix.orgl0b0 *

Thank you! I ended up with a similar approach after a bunch of experimenting:

{ pkgs ? import
    (
      fetchTarball
        {
          name = "nixpkgs-21.11-2022-01-03";
          url = "https://github.com/NixOS/nixpkgs/archive/08370e1e271f6fe00d302bebbe510fe0e2c611ca.tar.gz";
          sha256 = "1s9g0vry5jrrvvna250y538i99zy12xy3bs7m3gb4iq64qhyd6bq";
        })
    { }
}:
let
  python = pkgs.python38;
  poetryEnv = pkgs.poetry2nix.mkPoetryEnv {
    projectDir = builtins.path { path = ./.; name = "geostore"; };
    inherit python;
    extraPackages = ps: [ ps.pip ];
  };
in
poetryEnv.env.overrideAttrs (
  oldAttrs: {
    buildInputs = [
      (pkgs.poetry.override {
        inherit python;
      })
    ];
  }
)

This way the poetry2nix env and the Nix shell end up with the same Python environment, rather than the same Python interpreter in two different Nix store directories.

19:42:18
11 Mar 2022
@luctielen:matrix.orgLuc Tielen joined the room.09:54:59
@luctielen:matrix.orgLuc TielenHello, trying out poetry2nix for managing the python dependencies at our company. So far it seems to work great, except for fetching some packages from a private artifactory with credentials. Browsing through the issues, I found https://github.com/nix-community/poetry2nix/pull/390, but it uses the "old" nix-shell and not the new flake approach. Are there any docs on how to fetch a python package like this?11:04:50
13 Mar 2022
@worldofgeese:one.ems.hostworldofgeeseHas anyone tried including Hylang in their Poetry2nix projects? 16:13:40
16 Mar 2022
@gdesforges:matrix.orgGuillaume Desforges joined the room.12:23:56
@gdesforges:matrix.orgGuillaume Desforges Hi! I can't build opencv using poetry2nix, I'm getting Exception: Not found: 'python/cv2/gapi/.*\.py'...
I made a minimal reproduction: https://github.com/GuillaumeDesforges/bug-poetry2nix-opencv
Any help would be most helpful 🙏
12:25:49
@gdesforges:matrix.orgGuillaume Desforgesfound the issue: opencv wants internet 🤦‍♂️14:30:33
@gdesforges:matrix.orgGuillaume Desforgeshttps://github.com/opencv/opencv/issues/2173014:30:34
@gdesforges:matrix.orgGuillaume Desforges changed their profile picture.14:31:29
17 Mar 2022
@michael_j_ward:matrix.orgmichael_j_ward joined the room.17:37:59
@michael_j_ward:matrix.orgmichael_j_ward If I have to add an override to get connectorx to install, should I open a PR to add it in to the repo? 18:20:48
@michael_j_ward:matrix.orgmichael_j_ward

basically the same as all the other

{ pkgs ? import <nixpkgs> {} }:
let
  myAppEnv = pkgs.poetry2nix.mkPoetryEnv {
    python = pkgs.python39;
    projectDir = ./.;
    editablePackageSources = {
      my-app = ./src;
    };
    overrides = pkgs.poetry2nix.overrides.withDefaults (
      self: super: {
        connectorx = super.connectorx.overrideAttrs (
          old: {
            buildInputs = old.buildInputs ++ [ pkgs.openssl ];
          }
        );
    });
  };
in myAppEnv.env
18:21:17
@michael_j_ward:matrix.orgmichael_j_ward ^^ for clarity, that's my shell.nix 18:27:04
18 Mar 2022
@michael_j_ward:matrix.orgmichael_j_ward Additional Q: is there a recommended way to keep poetry around in nix-shell? It feels weird to me that it's not available from mkPoetryEnv 12:00:28
@k900:0upti.meK900Just add it to your shell's `nativeBuildInputs12:06:01

Show newer messages


Back to Room ListRoom Version: 6