!rWxyQqNqMUDLECdsIf:blad.is

Poetry2nix

304 Members
https://github.com/nix-community/poetry2nix | Poetry2nix is unmaintained https://github.com/nix-community/poetry2nix/issues/186557 Servers

Load older messages


SenderMessageTime
21 Oct 2024
@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.org@luna-null:matrix.org 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.org@nebucatnetzer13:matrix.org 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
@truh:matrix.orgtruhof python-ldap14:28:07
@picog:matrix.orgPico

I did try something like that:

       python-ldap = prev.python-ldap.overridePythonAttrs (
         old: {
           buildInputs = old.buildInputs or [ ] ++ [
             pkgs.openldap
             pkgs.cyrus_sasl
             # Fix for "cannot find -lldap_r: No such file or directory"
             (pkgs.writeTextFile {
               name = "openldap-lib-fix";
               destination = "/lib/libldap_r.so";
               text = "INPUT ( libldap.so )\n";
             })
           ];
+          propagatedBuildInputs = old.propagatedBuildInputs or [ ] ++ [ final.setuptools ];
         }
       );

I found that done in other parts of the code, but that didn't seem to help

14:31:57
@truh:matrix.orgtruh

I usually put it in buildInputs not propagatedBuildInputs

             pkgs.openldap
             pkgs.cyrus_sasl
             # Fix for "cannot find -lldap_r: No such file or directory"
             (pkgs.writeTextFile {
               name = "openldap-lib-fix";
               destination = "/lib/libldap_r.so";
               text = "INPUT ( libldap.so )\n";
             })

Should no longer be necessary if you poetry2nix is up to date

14:34:34
@truh:matrix.orgtruh It's already here https://github.com/nix-community/poetry2nix/blob/2b84afaf6ff1765bcb4cdd97e53a6914feb82ebf/overrides/default.nix#L2724 14:35:33
@picog:matrix.orgPicoI'm just working from a poetry2nix source tree :) 14:35:39
@picog:matrix.orgPicoSo yes, working from what is already there 14:35:57
@captaindgm:matrix.orgDaniel Garcia Medina joined the room.20:07:06
31 Oct 2024
@9456ed88e6:matrix.org9456ed88e6 joined the room.19:52:24
@9456ed88e6:matrix.org9456ed88e6

I'm running into a problem that I cannot figure out, if someone has a clue, I would very much appreciate some feedback.

I am getting an error when I use nix to run or build my python poetry project if the entry point module is not named main.

Here is the error:

~/mypackage$ nix run
Traceback (most recent call last):
  File "/nix/store/g0fsa09mpa90apcy2i02vljgd5rxxj42-python3.12-mypackage-0.5.0/bin/.mypackage-wrapped", line 6, in <module>
    from mypackage.cli import app
ModuleNotFoundError: No module named 'mypackage.cli'

Here is the structure of my project:

mypackage/
├── README.md
├── mypackage
│   ├── __init__.py
│   ├── cli.py
│   └── mymodule.py
├── flake.lock
├── flake.nix
├── poetry.lock
├── pyproject.toml

Here is the [tool.poetry.scripts] section of my pyproject.toml

[tool.poetry.scripts]
mypackage = "mypackage.cli:app"

Here is my flake.nix

{
  description = "mypackage";
  # Flake inputs
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    poetry2nix.url = "github:nix-community/poetry2nix";
  };

  # Flake outputs
  outputs = { self, nixpkgs, poetry2nix }:
    let

      # Systems supported
      allSystems = [
        "x86_64-linux" # 64-bit Intel/AMD Linux
        "aarch64-linux" # 64-bit ARM Linux
        "x86_64-darwin" # 64-bit Intel macOS
        "aarch64-darwin" # 64-bit ARM macOS
      ];

      # Helper to provide system-specific attributes
      forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
        pkgs = import nixpkgs { inherit system; config.allowUnfree = true; };
      });

    in
    {

      packages = forAllSystems
        ({ pkgs }:
          let
            inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication;
          in
          rec {
            myapp = mkPoetryApplication { projectDir = self; };
            default = myapp;
            apps.default = "${myapp}/bin/mypackage";
          });

      devShells = forAllSystems
        ({ pkgs }:
          let
            inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication;
          in
          {
            default = pkgs.mkShell
              {
                packages = with pkgs; [
                  poetry
                  (mkPoetryApplication { projectDir = self; })
                ];
              };
          });

    };

}

If I simply rename the cli.py module to main.py, and change the pyproject.toml to reflect the new name, everything works, and there is no error when running the executable produced by nix build, or running with nix run.

The structure of my project tree when it works is simply

mypackage/
├── README.md
├── mypackage
│   ├── __init__.py
│   ├── main.py <------------ This is the change.
│   └── mymodule.py
├── flake.lock
├── flake.nix
├── poetry.lock
├── pyproject.toml

Here is the [tool.poetry.scripts] section of my pyproject.toml with the associated change

[tool.poetry.scripts]
mypackage = "mypackage.main:app"

Does anyone know why I am getting the error when I try to name the module something other than main.py, how can I get everything working when I name the module cli.py?

19:55:59
@k900:0upti.meK900You probably don't have the renamed module tracked by git 19:56:34
@k900:0upti.meK900So it's filtered out when evaluating the flake19:56:42
@9456ed88e6:matrix.org9456ed88e6I have just double checked, and everything is being tracked. Thanks your suggestion tho.19:58:39
@9456ed88e6:matrix.org9456ed88e6Also I love how you're in every single nix related matrix room :P thanks for trying to answer my questions19:59:11
@k900:0upti.meK900When you rename the file, git does not track the rename 19:59:18
@k900:0upti.meK900 Unless you use git mv 19:59:23
@9456ed88e6:matrix.org9456ed88e6I have committed the changes tho, I can try with git mv to see if it makes a difference19:59:51
@9456ed88e6:matrix.org9456ed88e6No change20:03:00

Show newer messages


Back to Room ListRoom Version: 6