!rWxyQqNqMUDLECdsIf:blad.is

Poetry2nix

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

Load older messages


SenderMessageTime
25 Jul 2022
@collinarnett:matrix.orgCollin Arnett

I'm having trouble getting my script to work when using my poetry app with nix run however it works fine from poetry. Eg

$ nix run                                                        
warning: Git tree '/home/collin/projects/vframe' is dirty
Traceback (most recent call last):
  File "/nix/store/x9ngddmswb3n7l7d3w4vvkzyg3a668ig-python3.9-vframe-0.1.0/bin/.vframe-wrapped", line 6, in <module>
    from src.cli import cli
ModuleNotFoundError: No module named 'src'
$ poetry run vframe                                  
usage: vf [command]

VFRAME CLI (0.2.0)

positional arguments:
  [command]

optional arguments:
  -h, --help  show this help message and exit

Commands and plugins:
	pipe                Image processing pipeline
	modelzoo            ModelZoo scripts
	utils               Utility scripts

Here's the project structure.

├── poetry.lock
├── pyproject.toml
├── README.md
└── src
    ├── cli.py
    ├── commands
    ├── __pycache__
    └── vframe

my script is

[tool.poetry.scripts]
vframe = "src.cli:cli"

I assume this is a pretty trivial issue but this is not my repo, I'm just packaging it so the directory structure needs to stay somewhat the same.

16:34:04
@k900:0upti.meK900 You probably want from .cli import cli 16:35:21
@k900:0upti.meK900 Or possibly include = ["src"] in pyproject.toml 16:36:00
@k900:0upti.meK900Either way this is an upstream problem16:36:05
@collinarnett:matrix.orgCollin Arnett I forgot to mention that my flake defines the projectDir as ./.. This would normally be an upstream issue but they use anaconda so I'm trying to move their project to poetry so I'm trying to work around how they have things setup so as not to step on their toes. 16:41:33
@k900:0upti.meK900 The right way to do it would be to move src to vframe 16:45:34
@k900:0upti.meK900 And then use vframe.cli:cli as the entry point 16:45:44
@k900:0upti.meK900 I think there's also some magic declaration you can use in pyproject.toml to take the files from src and install them as a differently named package 16:46:58
@k900:0upti.meK900But I don't remember the details16:47:01
@collinarnett:matrix.orgCollin Arnett
In reply to @k900:0upti.me
I think there's also some magic declaration you can use in pyproject.toml to take the files from src and install them as a differently named package
I'll look into this. Thanks for the tip 😄. I just want the author of this repo to enjoy nix as much as I do so I'm trying to make things easy on them lol
16:48:14
27 Jul 2022
@plato:matrix.orgplato I have this package pytango which has a Makefile and a setup.py. I have the feeling Nix/poetry2nix only tries the Makefile and not setup.py. Can I validate this or force it to use setuptools? 13:07:01
@k900:0upti.meK900Poetry does not understand makefiles, so this is very unlikely 13:12:14
@plato:matrix.orgplato I have a poetry project that uses poetry2nix, but pytango is not using poetry. 13:39:58
28 Jul 2022
@vertebralsilence:matrix.orgvertebralsilence joined the room.13:28:26
@vertebralsilence:matrix.orgvertebralsilence I have a monorepo with a bunch of local, path-based deps, all of which use develop = true. I can't seem to use buildPoetryApplication when any of them has a local dep because I guess there's a clash between the derivations? The main derivation creates them to be editable, but if I've built them separately with buildPoetryApplication, poetry fails to find them. Is there a way I can build these without changing all the pyproject files? 13:42:12
29 Jul 2022
@vertebralsilence:matrix.orgvertebralsilenceok it all just seems to work if I add "develop" to the path removal hook...04:47:44
2 Aug 2022
@zeorin:matrix.orgXandor Schiefer left the room.11:02:11
4 Aug 2022
@plato:matrix.orgplato I've asked this before but had to leave early. I have a dependency for my poetry package. This dependency has a setup.py and is supposed to be built with the usual python setup.py build. When I use poetry2nix, it tries to build the dependency with make. The repo also has a Makefile.
Can I force it to be built with setuptools instead?
10:36:06
@adis:blad.isadisbladis
In reply to @plato:matrix.org
I've asked this before but had to leave early. I have a dependency for my poetry package. This dependency has a setup.py and is supposed to be built with the usual python setup.py build. When I use poetry2nix, it tries to build the dependency with make. The repo also has a Makefile.
Can I force it to be built with setuptools instead?
If included as a path dependency it should be fine I think?
10:46:32
@adis:blad.isadisbladisIs this public anywhere?10:46:53
@plato:matrix.orgplatoYes: https://gitlab.com/tango-controls/pytango10:47:46
@plato:matrix.orgplato(That's the dependency, not my package)10:47:52
@adis:blad.isadisbladisIs your package public?10:48:00
@plato:matrix.orgplatoSadly, no10:48:06
@adis:blad.isadisbladisHow are you adding this thing as a dependency?10:48:44
@plato:matrix.orgplatoDo we have a preferred pastebin? I can share the Nix file10:48:51
@adis:blad.isadisbladis
In reply to @plato:matrix.org
Do we have a preferred pastebin? I can share the Nix file
I mostly just paste directly in matrix nowadays
10:49:11
@adis:blad.isadisbladisIt's fine10:49:25
@plato:matrix.orgplato
let
  pkgs = import (import ./nix/sources.nix { }).nixpkgs { };
  omniorb_4_2 = with pkgs; stdenv.mkDerivation rec {
    pname = "omniorb";
    version = "4.2.5";

    src = fetchurl {
      url = "mirror://sourceforge/project/omniorb/omniORB/omniORB-${version}/omniORB-${version}.tar.bz2";
      sha256 = "1fvkw3pn9i2312n4k3d4s7892m91jynl8g1v2z0j8k1gzfczjp7h";
    };

    nativeBuildInputs = [ pkg-config ];
    buildInputs = [ python3 ];

    enableParallelBuilding = true;
    hardeningDisable = [ "format" ];
  };
  tango = pkgs.stdenv.mkDerivation rec {
    pname = "tango";
    version = "9.3.5";

    src = pkgs.fetchurl {
      url = "https://gitlab.com/api/v4/projects/24125890/packages/generic/TangoSourceDistribution/${version}/${pname}-${version}.tar.gz";
      sha256 = "1i59023gqm6sk000520y4kamfnfa8xqy9xwsnz5ch22nflgqn9px";
    };

    enableParallelBuilding = true;
    nativeBuildInputs = with pkgs; [ pkg-config jdk ];
    buildInputs = with pkgs; [ zlib omniorb_4_2 zeromq cppzmq ];

    configureFlags = with pkgs; [
      "--enable-java=yes"
      "--enable-dbserver=yes"
      "--with-java=${openjdk8}/bin/java"
      "--with-mysqlclient-lib=${mariadb-connector-c}/lib/mariadb/"
      "--with-mysqlclient-include=${mariadb-connector-c.dev}/include/mariadb"
    ];

    postInstall = ''
      mkdir -p $out/share/sql
      for fn in cppserver/database/*sql; do
        sed -e "s#^source #source $out/share/sql/#" "$fn" > $out/share/sql/$(basename "$fn")
      done
    '';
  };
  poetry2nix-latest-src = pkgs.fetchFromGitHub {
    owner = "nix-community";
    repo = "poetry2nix";
    rev = "1.31.0";
    hash = "sha256-0o856HWRRc5q02+vIhlIW4NpeQUDvCv3CuP1w2rZ+ho=";
  };
  poetry2nix = (import poetry2nix-latest-src { inherit pkgs; poetry = pkgs.poetry; });
  boostPython = pkgs.boost.override {
    enablePython = true;
    python = pkgs.python3;
  };
  poetryOverrides = poetry2nix.overrides.withDefaults (self: super: {
    pytango = super.pytango.overrideAttrs (old: {
      src = pkgs.fetchFromGitLab {
        owner = "tango-controls";
        repo = "pytango";
        rev = "develop";
        hash = "sha256-MC/EWwEN1u6+piv6LgkavM1OF773lLt9j/VO3Tg2/9k=";
      };
      
      # python3 because it needs pyconfig.h
      nativeBuildInputs = with pkgs; [ pkg-config boostPython python3 rsync ];
      buildInputs = with pkgs; [ tango boostPython omniorb_4_2 zeromq cppzmq ];
      propagatedBuildInputs = with super; [ six numpy ];
      makeFlags = [ "prefix=${placeholder "out"}" ];
      postPatch = ''
        sed -ie 's#os.environ.get("BOOST_HEADERS")#"${boostPython.dev}/include"#' setup.py
        sed -ie 's#os.environ.get("BOOST_LIBRARIES")#"${boostPython}"/lib#' setup.py
        sed -ie 's#os.environ.get("BOOST_PYTHON_LIB")#"boost_python310"#' setup.py
        sed -ie 's#boost_python-py#boost_python#' Makefile
        sed -ie 's#CFLAGS := #CFLAGS := -std=c++14 #' Makefile
        mv Makefile Makefile-old
      '';
    });
  });
  pythonPackage = poetry2nix.mkPoetryApplication {
    projectDir = ./.;
    overrides = poetryOverrides;
  };
  pythonEnv = poetry2nix.mkPoetryEnv {
    projectDir = ./.;
    overrides = poetryOverrides;
  };
in
{
  inherit tango;
  inherit pythonPackage;
  inherit boostPython;
}

That's the nix file.

10:49:36
@plato:matrix.orgplato The pyproject.toml just has pytango = "9.3.4" in the dependencies. Super simple 10:50:11

Show newer messages


Back to Room ListRoom Version: 6