!rWxyQqNqMUDLECdsIf:blad.is

Poetry2nix

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

Load older messages


SenderMessageTime
13 Jun 2024
@ixxie:matrix.orgixxie

I'm not sure what to make of this... here is the flake for the backend (it's in ${monorepo}/backend):

{
  description = "MyApp Backend - Python, Uvicorn & FastAPI";

  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};
      # create a custom "mkPoetryApplication" API function that under the hood uses
      # the packages and versions (python3, poetry etc.) from our pinned nixpkgs above:
      inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication;
      myapp = mkPoetryApplication { projectDir = ./.; };
    in
    {
      apps.${system}.backend = {
        type = "app";
        program = "${myapp}/bin/backend";
      };
    };
}

But I get the following error:

warning: Git tree '/home/ixxie/myapp' is dirty
error:
       … while calling a functor (an attribute set with a '__functor' attribute)
         at /nix/store/lpqygnph8c5l7ajkmqr4rff0pvkfz1f6-source/default.nix:407:13:
          406|
          407|       app = py.pkgs.buildPythonPackage (
             |             ^
          408|         passedAttrs // inputAttrs // {

       … while evaluating a branch condition
         at /nix/store/dydg48djlykksz8cxq0xjplyxpa9pvf4-source/pkgs/development/interpreters/python/python-packages-base.nix:28:7:
           27|     in
           28|       if builtins.isAttrs result then result
             |       ^
           29|       else if builtins.isFunction result then {

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: expected a set but found null: null
08:44:08
@ixxie:matrix.orgixxie How do I control the name of the package created with mkPoetryApplication and installed with nix profile install? 11:29:47
@tyberius_prime:matrix.orgTyberiusPrime (smilodon inopinatus)
In reply to @ixxie:matrix.org
How do I control the name of the package created with mkPoetryApplication and installed with nix profile install?
I thought it was taken from pyproject.toml? the source indicate that this is true
12:08:17
@tyberius_prime:matrix.orgTyberiusPrime (smilodon inopinatus) adisbladis: Hi, are you still working on poetry2nix? 12:09:01
@tyberius_prime:matrix.orgTyberiusPrime (smilodon inopinatus) ixxie: I think you just call mkPoetryApplication and then they're all in ./results/bin 12:09:58
@ixxie:matrix.orgixxie
In reply to @tyberius_prime:matrix.org
I thought it was taken from pyproject.toml? the source indicate that this is true

I've set the name in pyproject.toml, and set pname in mkPoetryApplication but when I run nix profile install .#package-name but then I still get something like this:

> nix profile list

Name:               path/from/git/root/to/flake
Flake attribute:    packages.x86_64-linux.default
Original flake URL: git+file:///home/ixxie/project?dir=path/from/git/root/to/flake
Locked flake URL:   git+file:///home/ixxie/project?dir=path/from/git/root/to/flake
Store paths:        /nix/store/4r112qhr7f3vsxj3jx4ynvyb8560vjxf-python3.11-cli-0.1
12:15:12
@ixxie:matrix.orgixxieI mean it installs well, I'm just wondering why the name is like this12:16:43
@tyberius_prime:matrix.orgTyberiusPrime (smilodon inopinatus)well, the name (pname + version) ends up in the store path, which I giuess is where the python3.11-cli comes from (cli being set in your pyproject.toml). I suppose you want to change 'Name:'?12:16:49
@ixxie:matrix.orgixxie
In reply to @tyberius_prime:matrix.org
well, the name (pname + version) ends up in the store path, which I giuess is where the python3.11-cli comes from (cli being set in your pyproject.toml).

I suppose you want to change 'Name:'?
yep, because that would be how I refer to it when managing it with nix profile
12:17:18
@tyberius_prime:matrix.orgTyberiusPrime (smilodon inopinatus)(I don't use nix profile, so I can't comment on where it's getting the name from.)12:17:30
@tyberius_prime:matrix.orgTyberiusPrime (smilodon inopinatus)I mean you can change the flake attribute easily enough, so 'flake attribute' is something you could change, at the price of having to do nix profile install /path/to/flake#name12:18:41
@ixxie:matrix.orgixxie
In reply to @tyberius_prime:matrix.org
I mean you can change the flake attribute easily enough, so 'flake attribute' is something you could change, at the price of having to do nix profile install /path/to/flake#name
yeah the attribute hasn't been an issue
12:24:42
@ixxie:matrix.orgixxiethanks anyway12:24:45
@tyberius_prime:matrix.orgTyberiusPrime (smilodon inopinatus)no worries12:26:41
15 Jun 2024
@roastedcheesee:matrix.org@roastedcheesee:matrix.org joined the room.17:32:41
@roastedcheesee:matrix.org@roastedcheesee:matrix.org

hey, how can I override the generated inputs in mkPoetryApplication? I know I can override the dependencies but I can't manage to add inputs to the package itself

      mkPoetryApplication {
        projectDir = src;
        patches = [ ./salmon.patch ];
        overrides = defaultPoetryOverrides.extend (self: super: {
          bencoder-pyx = super.bencoder-pyx.overridePythonAttrs (old: {
            buildInputs = (old.buildInputs or []) ++ [ super.setuptools super.cython ];
          });
          pyimgurapi = super.pyimgurapi.overridePythonAttrs (old: {
            buildInputs = (old.buildInputs or []) ++ [ super.poetry ];
          });
          heybrochecklog = super.heybrochecklog.overridePythonAttrs (old: {
            patches = (old.patches or []) ++ [ ./salmon.patch ]; # ffs
            buildInputs = (old.buildInputs or []) ++ [ super.setuptools super.poetry ];
          });
          dottorrent = super.dottorrent.overridePythonAttrs (old: {
            buildInputs = (old.buildInputs or []) ++ [ super.setuptools ];
          });
          bs4 = super.bs4.overridePythonAttrs (old: {
            buildInputs = (old.buildInputs or []) ++ [ super.setuptools ];
          });
          pyimgur = super.pyimgur.overridePythonAttrs (old: {
            buildInputs = (old.buildInputs or []) ++ [ super.setuptools ];
          });
        });
      };

this is what I have so far, I tried overriding it together with the other dependencies but it had no effect

17:36:02
18 Jun 2024
@yusu:matrix.orgJosefine changed their display name from Jonas Katzke to Josefine.07:32:34
20 Jun 2024
@tyberius_prime:matrix.orgTyberiusPrime (smilodon inopinatus)Poetry2nix is IDF, right? how do I get a dependency on that IDF? I'm trying a wild thing, where I teach poetry mercurial by prefetching the mercurial repo (&rev) into the nix store, and rewriting the lock files a bit, but I can only build it in impure mode since even if I stick the fetchhg into the build inputs of the python package, that's not there when poetry2nix does it's thing (and why would it...)09:10:10
@tyberius_prime:matrix.orgTyberiusPrime (smilodon inopinatus)hah, all I need to do is overwrite src!09:51:06
@tyberius_prime:matrix.orgTyberiusPrime (smilodon inopinatus)of course09:51:09
@eightysteele:matrix.orgAaron Steele joined the room.16:39:05
@elonsroadster:matrix.orgcolonelpanicDoes anyone have any what is going on with libcst? seems like its not extracting a tar archive that it should be: error: opening file '/nix/store/201zc10pdd4ls1gmpsmbl710lm0q6ai7-libcst-1.1.0.tar.gz/native/Cargo.lock': Not a directory17:00:51
@eightysteele:matrix.orgAaron Steele

potentially silly question: how to get keyrings-google-artifactregistry-auth working in mkPoetryEnv? i include it as a buildInput and it works in the shellHook, but when i add a private source in tool.poetry.source' and try nix-shell`, i get these errors:

building '/nix/store/had00ag5f29zdjwlv5hmmc596cl60sjv-genjax-0.4.0-py3-none-any.whl.drv'...
Reading index https://us-west1-python.pkg.dev/probcomp-caliban/probcomp/simple/genjax/
Traceback (most recent call last):
  File "/nix/store/0rzh74dywg10ggl3ds6khsdpc84nbp96-fetch-from-legacy.py", line 82, in <module>
    response = urllib.request.urlopen(req, context=context)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/urllib/request.py", line 525, in open
    response = meth(req, response)
               ^^^^^^^^^^^^^^^^^^^
  File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/urllib/request.py", line 634, in http_response
    response = self.parent.error(
               ^^^^^^^^^^^^^^^^^^
  File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/urllib/request.py", line 563, in error
    return self._call_chain(*args)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/urllib/request.py", line 496, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/urllib/request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 401: Unauthorized
17:12:06
@eightysteele:matrix.orgAaron Steele *

potentially silly question: how to get keyrings-google-artifactregistry-auth working in mkPoetryEnv? i include it as a buildInput and it works in the shellHook, but when i add a private source in tool.poetry.source and try nix-shell, i get these errors:

building '/nix/store/had00ag5f29zdjwlv5hmmc596cl60sjv-genjax-0.4.0-py3-none-any.whl.drv'...
Reading index https://us-west1-python.pkg.dev/probcomp-caliban/probcomp/simple/genjax/
Traceback (most recent call last):
  File "/nix/store/0rzh74dywg10ggl3ds6khsdpc84nbp96-fetch-from-legacy.py", line 82, in <module>
    response = urllib.request.urlopen(req, context=context)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/urllib/request.py", line 525, in open
    response = meth(req, response)
               ^^^^^^^^^^^^^^^^^^^
  File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/urllib/request.py", line 634, in http_response
    response = self.parent.error(
               ^^^^^^^^^^^^^^^^^^
  File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/urllib/request.py", line 563, in error
    return self._call_chain(*args)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/urllib/request.py", line 496, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/urllib/request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 401: Unauthorized
17:12:27
@eightysteele:matrix.orgAaron Steelethere was a related issue here, although it's not clear how to use the workaround: https://github.com/nix-community/poetry2nix/issues/672#issuecomment-174410995317:13:32
@eightysteele:matrix.orgAaron Steele(thanks for any guidance!!)17:13:46
@eightysteele:matrix.orgAaron Steele

here's my default.nix

{ pkgs ? import <nixpkgs> { } }:
let
  poetry2nix = pkgs.callPackage (builtins.fetchTarball
    "https://github.com/nix-community/poetry2nix/archive/master.tar.gz") { };
  python312 = pkgs.python312;
  keyrings = pkgs.python312Packages.keyrings-google-artifactregistry-auth;
  gexEnv = poetry2nix.mkPoetryEnv {
    projectDir = ./.;
    editablePackageSources = { gex = ./gex; };
    python = python312;
    pyproject = ./pyproject.toml;
    poetrylock = ./poetry.lock;
    preferWheels = true;
  };
in pkgs.mkShell {
  buildInputs = [ gexEnv pkgs.google-cloud-sdk keyrings ];
  shellHook = ''
    # keyrings are available here and I'm authenticated in google cloud
  '';
}
17:16:02
21 Jun 2024
@tyberius_prime:matrix.orgTyberiusPrime (smilodon inopinatus)
In reply to @elonsroadster:matrix.org
Does anyone have any what is going on with libcst?

seems like its not extracting a tar archive that it should be:

error: opening file '/nix/store/201zc10pdd4ls1gmpsmbl710lm0q6ai7-libcst-1.1.0.tar.gz/native/Cargo.lock': Not a directory

that looks like the override is broken. I encountered something similar recently trying to wrap polaris.

But the nixpkgs libcst module - at least in master - uses fetchFromGitHub, so it really shouldn't have a tarball. And I don't see an override in poetry2nix Hm.

06:12:24
@tyberius_prime:matrix.orgTyberiusPrime (smilodon inopinatus)does poetry2nix at all try to detect the build system? or is it all manual overrides?06:12:38
@elonsroadster:matrix.orgcolonelpanicI think it might be the cargo tarball?06:24:00

Show newer messages


Back to Room ListRoom Version: 6