!rWxyQqNqMUDLECdsIf:blad.is

Poetry2nix

326 Members
https://github.com/nix-community/poetry2nix63 Servers

Load older messages


SenderMessageTime
8 Feb 2022
@adis:blad.isadisbladis
In reply to @graf_blutwurst:matrix.org
ok then i was on the right track for that. do you happen to have any resources that'd help me understand what causes the recompile of pandas etc? mostly so i can predict when it happens since those take a significant chunk of time to crunch through

When some of the build inputs changes, or some parameters are different.
poetry2nix tries as much as possible to ignore nixpkgs python packages which will cause the derivations to be different from nixpkgs ~all of the time.

Practially this means that you will have to rebuild when:

  • You update nixpkgs
  • Any of the python packages that pandas/numpy depends on changes in your poetry.lock
06:08:37
@graf_blutwurst:matrix.orgDominic Eggerthat sounds sensible.thanks for your time!06:17:11
12 Feb 2022
@octavioduarte:matrix.orgOctavio Martín Duarte joined the room.15:26:44
@octavioduarte:matrix.orgOctavio Martín Duarte

Hello!
I'm suffering from a problem that seems to have been already detected and fixed...

I get this failure even for the Flask exaple from the Tweag blogpost and the video. I get the message about an infinite recursion and when I use the verbose switch it get to read that flint-core is detected as missing. Adding the package as a dependendency does not stop this from failing.

15:54:06
@mou_bugtracker:matrix.orgmouOctavio, could you provide details about your environment? Error message, pyproject.toml, your nix expression will help anyone to better identify root cause.18:45:31
14 Feb 2022
@octavioduarte:matrix.orgOctavio Martín DuarteDownload pyproject.toml02:09:18
@octavioduarte:matrix.orgOctavio Martín Duarte
In reply to @mou_bugtracker:matrix.org
Octavio, could you provide details about your environment? Error message, pyproject.toml, your nix expression will help anyone to better identify root cause.
Off course! I didn't want to send the files without being asked to but if anybody can help that would be amazing.
02:09:19
@octavioduarte:matrix.orgOctavio Martín DuarteDownload shell.nix02:09:28
@octavioduarte:matrix.orgOctavio Martín DuarteDownload default.nix02:09:37
@octavioduarte:matrix.orgOctavio Martín DuarteThis is the error.02:13:36
@octavioduarte:matrix.orgOctavio Martín DuarteDownload error.md02:13:46
@worldofgeese:one.ems.hostworldofgeeseCould I ask someone to test the Poetry2nix flake template with some trivial Python code and see if it works for them? I'm getting `error: flake 'git+file:///home/worldofgeese/projects/little-bits-of-buddha' does not provide attribute 'packages.x86_64-linux.defaultPackage.x86_64-linux', 'legacyPackages.x86_64-linux.defaultPackage.x86_64-linux' or 'defaultPackage.x86_64-linux'`22:36:56
@worldofgeese:one.ems.hostworldofgeeseI was able to solve by swapping for Serokell's Poetry2nix template22:37:20
@worldofgeese:one.ems.hostworldofgeeseHost system is Arch Linux22:37:26
15 Feb 2022
@asymmetric:matrix.dapp.org.ukasymmetric joined the room.11:46:48
@asymmetric:matrix.dapp.org.ukasymmetric hi! i'm a bit of a python newbie: how would i go about adding an output to my flake, where i run py.test? i can use mkPoetryEnv.env to get a shell with dev dependencies installed, but how do i also get tests to run? 11:48:27
@asymmetric:matrix.dapp.org.ukasymmetric i realized i can pass checkPhase = ... to mkPoetryApplication, but i cannot pass the same attrset to mkPoetryEnv, as mkPoetryEnv doesn't like having unuexpected attrs (and I'd like to not repeat myself, as I have to define overlays). i could filter out the checkPhase attribute from the attrset i pass to both function, but it seems a bit hacky. is there a better way? 12:12:55
@asymmetric:matrix.dapp.org.ukasymmetric
  outputs = { self, nixpkgs, poetry2nix }:
    let
      name = "foo";
      system = "x86_64-linux";

      pkgs = import nixpkgs {
        inherit system;
        overlays = [ poetry2nix.overlay ];
      };

      poetryAttrs = {
        projectDir = ./.;
        python = pkgs.python39;

        checkPhase = ''
          py.test tests/
        '';

        overrides = pkgs.poetry2nix.overrides.withDefaults (final: prev: {
          lmdb = prev.lmdb.overrideAttrs
            (
              old: {
                # we need to patch the hard-coded path to patch,
                # see https://github.com/jnwatson/py-lmdb/blob/80d7ce6fd5531a2b2f586d9ec871fe60126f8aba/setup.py#L117
                patchPhase = ''
                  substituteInPlace ./setup.py --replace /usr/bin/patch ${pkgs.patch}/bin/patch
                '';
              }
            );
        });
      };
    in
    {
      packages.${system} = {
        ${name} = pkgs.poetry2nix.mkPoetryApplication poetryAttrs;
      };

      devShell.${system} =
        (pkgs.poetry2nix.mkPoetryEnv poetryAttrs).env;

    };
...
}
12:15:13
@asymmetric:matrix.dapp.org.ukasymmetric devShell.${system} = (pkgs.poetry2nix.mkPoetryEnv (pkgs.lib.filterAttrs (n: v: n != "checkPhase") poetryAttrs)).env; this is the workaround i've found 12:21:18
@asymmetric:matrix.dapp.org.ukasymmetric^ugly12:21:38
@k900:0upti.meK900Do it the other way around? 12:36:16
@k900:0upti.meK900 Have the shared args in a variable, and pass sharedArgs // { checkPhase = "blah" } to mkPoetryApplication 12:36:55
@k900:0upti.meK900That's what I did anyway 12:37:03
@asymmetric:matrix.dapp.org.ukasymmetricyeah, i just don't like having the main package definition be "incomplete"12:39:16
@asymmetric:matrix.dapp.org.ukasymmetricanyway, thx!12:39:19
@mou_bugtracker:matrix.orgmou
In reply to @octavioduarte:matrix.org
Off course! I didn't want to send the files without being asked to but if anybody can help that would be amazing.

I finally got time to look into your issue.

TLDR; your project builds fine with latest version of poetry2nix.

Long answer: many errors comes from outside, from python ecosystem, you can read short explanation in document. Latest version of poetry2nix contain myriad of overrides for many packages which allow to successfully build you project. I do not know why nixpkgs does not update potry2nix. But you can check amount of overrides in this files https://github.com/nix-community/poetry2nix/tree/master/overrides .

To build your project i used flake with overlay over nixpkgs. I'm not experienced user of nix, but i believe you can use flake for poetry2nix with classic nix definitions.

Here is flake.nix i used

{
  description = "test";

  inputs.flake-utils.url = "github:numtide/flake-utils";
  inputs.nixpkgs.url = "github:NixOS/nixpkgs";
  inputs.poetry2nix.url = "github:nix-community/poetry2nix";

  outputs = { self, nixpkgs, flake-utils, poetry2nix }:
    {
      # Nixpkgs overlay providing the application
      overlay = nixpkgs.lib.composeManyExtensions [
        poetry2nix.overlay
        (final: prev: {
          # The application
          example = prev.poetry2nix.mkPoetryApplication {
            projectDir = ./.;
          };
        })
      ];
    } // (flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs {
          inherit system;
          overlays = [ self.overlay ];
        };
      in
      rec {

        defaultPackage = pkgs.example;
      }));
}
19:41:08
16 Feb 2022
@jyamad:cofree.coffeejyamadI am trying to use poetry2nix via flakes, but I need to downgrade poetry due to https://github.com/python-poetry/poetry/issues/4523 . Does anyone have an example of a flake that overrides the poetry version that poetry2nix uses?07:14:42
@jyamad:cofree.coffeejyamad
In reply to @jyamad:cofree.coffee
I am trying to use poetry2nix via flakes, but I need to downgrade poetry due to https://github.com/python-poetry/poetry/issues/4523 . Does anyone have an example of a flake that overrides the poetry version that poetry2nix uses?
It looks to me like I may be getting the right version of poetry by making an overlay, but that poetry2nix is maybe not using my overlay version of poetry.
07:18:21
@worldofgeese:one.ems.hostworldofgeese

I have a Poetry flake I can get to reliably build a Nix derivation. I've been banging my head the last two days trying to build a container image from it with dockerTools.streamLayeredImage. The data.json file I use as my "database" can't be found by the Python processing script but only inside the container. Here's the error:

$ docker run docker run -p 5000:5000 --rm -it localhost/lbob:6xwsg8ixlbpaisq1xc7ipvs5qxcs3d1m
 * Serving Flask app 'little_bits_of_buddha.app' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on all addresses.
   WARNING: This is a development server. Do not use it in a production deployment.
 * Running on http://10.0.2.100:5000/ (Press CTRL+C to quit)
[2022-02-16 17:33:30,415] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
  File "/nix/store/wmaqg26cza9vvck1wglp3xywsqabnp7n-python3.9-flask-2.0.2/lib/python3.9/site-packages/flask/app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
  File "/nix/store/wmaqg26cza9vvck1wglp3xywsqabnp7n-python3.9-flask-2.0.2/lib/python3.9/site-packages/flask/app.py", line 1518, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/nix/store/wmaqg26cza9vvck1wglp3xywsqabnp7n-python3.9-flask-2.0.2/lib/python3.9/site-packages/flask/app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
  File "/nix/store/wmaqg26cza9vvck1wglp3xywsqabnp7n-python3.9-flask-2.0.2/lib/python3.9/site-packages/flask/app.py", line 1502, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/nix/store/yr8hjra5czylkiz1pkcsclbbc7pqbyh2-python3.9-little-bits-of-buddha-0.1.0/lib/python3.9/site-packages/little_bits_of_buddha/app.py", line 10, in random_sutta
    return _random_sutta()
  File "/nix/store/yr8hjra5czylkiz1pkcsclbbc7pqbyh2-python3.9-little-bits-of-buddha-0.1.0/lib/python3.9/site-packages/little_bits_of_buddha/data.py", line 8, in _random_sutta
    with open("../data.json") as json_file:
FileNotFoundError: [Errno 2] No such file or directory: './data.json'

But the file is there:

ls /nix/store/yr8hjra5czylkiz1pkcsclbbc7pqbyh2-python3.9-little-bits-of-buddha-0.1.0/lib/python3.9/site-packages/little_bits_of_buddha/
__pycache__  app.py  data.json  data.py  run.py

Am I doing something wrong?

20:22:43
@k900:0upti.meK900You need to actually declare that the file should be installed 20:23:56

Show newer messages


Back to Room ListRoom Version: 6