!rWxyQqNqMUDLECdsIf:blad.is

Poetry2nix

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

Load older messages


SenderMessageTime
17 Mar 2022
@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
@k900:0upti.meK900 * Just add it to your shell's nativeBuildInputs 12:06:02
@michael_j_ward:matrix.orgmichael_j_ward I apologize, I'm only a week in to learniing nix. I've looked around a bit, i feel like this should be trivial but i can't figure out where to update the shell's nativeBuildInputs 12:56:35
@k900:0upti.meK900 Just add nativeBuildInputs = [ pkgs.poetry ] to your mkShell call 12:58:54
@michael_j_ward:matrix.orgmichael_j_ward

Took me a bit but got it

in myAppEnv.env

becomes

in pkgs.mkShell {
  buildInputs = [ myAppEnv ];
  nativeBuildInputs = [ pkgs.poetry ];
}
13:15:42
@michael_j_ward:matrix.orgmichael_j_ward So that poetry ends up disconnected from the app environment, i.e. i can run pytest but poetry run pytest fails 13:19:00
@k900:0upti.meK900That is normal 13:20:34
@k900:0upti.meK900poetry2nix doesn't actually create a Poetry environment 13:20:50
@k900:0upti.meK900It translates the lock file directly into Nix 13:20:57
@michael_j_ward:matrix.orgmichael_j_ward

removing any x-y problem:

I'm attempting to set up the dev flow.

My understanding is we use shell.nix to get into your project-specific dev shell. From there you can add / remove dependencies, run tests et cetera.

Do you recommend sticking with a simpler shell.nix for that purpose, not using poetry2nix?

{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
    buildInputs = [ pkgs.python3 pkgs.poetry ];
}
13:28:28
@k900:0upti.meK900If you want Poetry to be managing the environment, then yes, probably13:36:02
@michael_j_ward:matrix.orgmichael_j_wardwell not so much for managing the python virtual environment, but i still want to use poetry for dependency resolution and locking, right?13:41:18
@k900:0upti.meK900Yes, you can do that with poetry2nix and something like direnv13:47:32
@k900:0upti.meK900To automatically reload the shell when the dependencies change13:47:47
@jmgilman:matrix.orgJoshua Gilman set a profile picture.22:17:56
20 Mar 2022
@worldofgeese:one.ems.hostworldofgeese
WARNING: Built wheel for hy is invalid: Metadata 1.2 mandates PEP 440 version, but 'unknown' is not
Failed to build hy

Looks like pip has a no-verify option. Can I pass --no-verify into mkPoetryEnv, which is what I'm using to source this dev dependency into my devShell?

18:04:17
@worldofgeese:one.ems.hostworldofgeese I swapped hy = { git = "https://github.com/hylang/hy.git", python = ">=3.9,<3.11" } for hy = {version = "1.0a4", allow-prereleases = true, python = ">=3.9,<3.11"}, did a poetry update and now mkPoetryEnv returns Hy 1.04a, which is the latest pre-release. It would be nice to get the tip of the tip master branch but this works fine for my purposes now 21:48:26
@worldofgeese:one.ems.hostworldofgeese* I swapped `hy = { git = "https://github.com/hylang/hy.git", python = ">=3.9,<3.11" }` for `hy = {version = "1.0a4", allow-prereleases = true, python = ">=3.9,<3.11"}`, did a `poetry update` and now `mkPoetryEnv` returns Hy 1.04a, which is the latest pre-release. It would be nice to get the tip of the master branch but this works fine for my purposes now21:54:44
21 Mar 2022
@tompurl:destrocodpiece.wtfTom Purl (he/him)
In reply to @worldofgeese:one.ems.host
I swapped hy = { git = "https://github.com/hylang/hy.git", python = ">=3.9,<3.11" } for hy = {version = "1.0a4", allow-prereleases = true, python = ">=3.9,<3.11"}, did a poetry update and now mkPoetryEnv returns Hy 1.04a, which is the latest pre-release. It would be nice to get the tip of the master branch but this works fine for my purposes now
Thank you for sharing your solution.
00:20:28
22 Mar 2022
@sephi:matrix.orgsephi Is there a way to use the environment of a derivation to add more files to it right before the Python package is created? I’m creating a derivation for a Django project, and I’d like to collect static files to a directory that’s inside my package. I’m currently doing this by using mkPoetryApplication to create the package, and then have a second mkPoetryApplication with ${appWithoutStatic}/bin/django-admin collectstatic in configurePhase. This works but I was wondering if this is achievable without creating 2 derivations. 15:06:07
@andreas.schraegle:helsinki-systems.deAndreas Schrägle joined the room.23:35:54
23 Mar 2022
@asymmetric:matrix.dapp.org.ukasymmetric joined the room.13:36:58
@asymmetric:matrix.dapp.org.ukasymmetric

i'm trying to build a package that depends on cryptography 36.0.2, and it fails with:

error: hash mismatch in fixed-output derivation '/nix/store/cb7576730h5ny4x6177dcxy3gl2qvfvl-cryptography-36.0.2-vendor.tar.gz.drv':
         specified: sha256-kozYXkqt1Wpqyo9GYCwN08J+zV92ZWFJY/f+rulxmeQ=
            got:    sha256-6C4N445h4Xf2nCc9rJWpSZaNPilR9GfgbmKvNlSIFqg=

this is because the hash is hard-coded here, and it's now wrong.

what's the idea here? how do we keep that hash updated? should i just override on my end?

13:38:41
25 Mar 2022
@asymmetric:matrix.dapp.org.ukasymmetric could poetry2nix automatically detect and handle this edge case? 12:21:59
26 Mar 2022
@mou_bugtracker:matrix.orgmou
In reply to @sephi:matrix.org
Is there a way to use the environment of a derivation to add more files to it right before the Python package is created? I’m creating a derivation for a Django project, and I’d like to collect static files to a directory that’s inside my package. I’m currently doing this by using mkPoetryApplication to create the package, and then have a second mkPoetryApplication with ${appWithoutStatic}/bin/django-admin collectstatic in configurePhase. This works but I was wondering if this is achievable without creating 2 derivations.
i'm newbie with nix, but as far as i can understand, proper way to achieve desired, is to make override with custom build paramaters. poetry2nix uses nixpkgs.buildPythonPackage. So i believe there are plenty of post* hooks, which you can use to add aditional step to your build. You only need to figure out proper way to override resulting derivation.
08:45:18
@asymmetric:matrix.dapp.org.ukasymmetric
In reply to @mou_bugtracker:matrix.org
i'm newbie with nix, but as far as i can understand, proper way to achieve desired, is to make override with custom build paramaters. poetry2nix uses nixpkgs.buildPythonPackage. So i believe there are plenty of post* hooks, which you can use to add aditional step to your build. You only need to figure out proper way to override resulting derivation.
are you replying to me? sorry can't see what you're replying to
08:45:58

Show newer messages


Back to Room ListRoom Version: 6