Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic extraction/requirements detection fails for dymoprint #560

Open
spease opened this issue Jun 17, 2023 · 4 comments
Open

Automatic extraction/requirements detection fails for dymoprint #560

spease opened this issue Jun 17, 2023 · 4 comments

Comments

@spease
Copy link

spease commented Jun 17, 2023

For some reason, even with the latest rev (8d90307), automatic everything fails with https://github.com/computerlyrik/dymoprint.

default.nix:

with (import <nixpkgs> {});

let
  mach-nix = import (builtins.fetchGit {
    url = "https://github.com/DavHau/mach-nix";
    # ref = "refs/tags/3.5.0";
    rev = "8d903072c7b5426d90bc42a008242c76590af916";
  }) {
    inherit pkgs;
    pypiDataRev = "ba35683c35218acb5258b69a9916994979dc73a9";
    pypiDataSha256 = "019m7vnykryf0lkqdfd7sgchmfffxij1vw2gvi5l15an8z3rfi2p";
  };
in
  mach-nix.buildPythonPackage {
    pname = "dymoprint";
    version = "1.4.1";
    requirements = ''
      importlib-metadata; python_version<"3.8"
      appdirs
      Pillow>=8.1.2,<10
      PyQRCode>=1.2.1,<2
      python-barcode>=0.13.1,<1
      pyusb
      PyQt6
      PyQt6-tools
    '';
    src = ./.;
  }

Note that PyQt6 and PyQt6-tools do not seem to exist, but it does not say this is the problem.

Unfortunately as part of the troubleshooting process I tried updating nix, so now I'm getting #549.

If I comment the pname,version,requirements out I get:

building '/nix/store/429nnr22lkkrs3rvwd1k158w1nsgrmag-package-requirements.drv'...
unpacking sources
unpacking source archive /nix/store/2k5xpkm5w7v71wxzs4znq29aaydvirm3-dymoprint
source root is dymoprint
installing
extracting dependencies
/nix/store/74l4x6m97bvry7ccxv51h952ayvg2j46-stdenv-linux/setup: line 1604:    18 Segmentation fault      (core dumped) out_file=$out/python.json /nix/store/xd70yp7yd8zy6c66dzbpyknvdi8fpxqx-python3-3.10.11-env-patched/bin/python -c "import sys, setuptools, tokenize, os; sys.argv[0] = 'setup.py'; __file__='setup.py';
f=getattr(tokenize, 'open', open)(__file__);
code=f.read().replace('\r\n', '\n');
f.close();
exec(compile(code, __file__, 'exec'))
" install &> $out/python.log
error:
     … while evaluating the attribute 'pkgs.buildPythonPackage'

       at /nix/store/xbvbgjphv6n2s8ggajq069cr3w23malb-nixpkgs/nixpkgs/pkgs/development/interpreters/python/passthrufun.nix:87:5:

         86|     withPackages = import ./with-packages.nix { inherit buildEnv pythonPackages;};
         87|     pkgs = pythonPackages;
           |     ^
         88|     interpreter = "${self}/bin/${executable}";

     … while calling the 'mapAttrs' builtin

       at /nix/store/xbvbgjphv6n2s8ggajq069cr3w23malb-nixpkgs/nixpkgs/pkgs/development/interpreters/python/passthrufun.nix:31:8:

         30|           value;
         31|     in lib.mapAttrs func items;
           |        ^
         32|   in ensurePythonModules (callPackage

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

     error: Automatic extraction of 'pname' from python package source /nix/store/2k5xpkm5w7v71wxzs4znq29aaydvirm3-dymoprint failed.
     Please manually specify 'pname'
@TyberiusPrime
Copy link
Collaborator

So the pname extraction seems to be fixed in master - at least the #563 PR fails with 'pip couldn't find setuptools_scm' for me now. But adding that get's you a nice infinite recursion in pip & setuptools (see #524 I presume).

@TyberiusPrime
Copy link
Collaborator

Digging deeper, after adding a workaround for #529 (PR incoming, I'm not certain about it though):

  • this is a pyproject.toml project, and mach-nix currently can't read the requirements, you have to copy/paste/adjust them.

pyqt6 isn't in the source distribution part of pypi-deps-db ('"FileNotFoundError: [Errno 2] No such file or directory: 'setup.py'",).

The binaries apparently only go up to python 3.9, but mach-nix isn't seeing any of them from pypi-deps-db.

The nixpkgs PyQt6 in 23.05 is 6.5.0 which is too new for the last pypi-debs-db (it's currently not updating...). so you have to go to 22.11, but that's got 6.4.0 and the pyqt6-tools release on pypi needs 6.4.2. And 22.05 didn't have pyqt6 at all. So you need nixpkgs rev f519c1e43c38d6e27cc84c57709a309804d4fada.

And then you're missing pyqt6-qt6 which has no source distribution on pypi.

Sorry, gotta go do something else at this point.

Here's' the flake I got so far

{
  description = "Anysnake2 generated flake";
  inputs = rec {
    nixpkgs = {
      url = "github:NixOS/nixpkgs/f519c1e43c38d6e27cc84c57709a309804d4fada";
    };
    flake-utils = {
      url = "github:numtide/flake-utils?rev=7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19";
    };
    mach-nix = {
      url = "/home/finkernagel/upstream/mach-nix-pip-infinite-recursion/";
      #url = "github:DavHau/mach-nix?rev=8d903072c7b5426d90bc42a008242c76590af916";
      inputs.pypi-deps-db.follows = "pypi-deps-db";
    };
    pypi-deps-db = {
      url = "github:DavHau/pypi-deps-db?rev=ba35683c35218acb5258b69a9916994979dc73a9";
      inputs.mach-nix.follows = "mach-nix";
    };
  };

  outputs = {
    self,
    nixpkgs,
    flake-utils,
    mach-nix,
    pypi-deps-db,
  }:
    flake-utils.lib.eachDefaultSystem (system: let
      pkgs = import nixpkgs {
        inherit system;
      };
      mach-nix_ = (import mach-nix) {
        inherit pkgs;
        pypiDataRev = pypi-deps-db.rev;
        pypiDataSha256 = pypi-deps-db.narHash;
        python = "python39";
      };

      dymoprint = mach-nix_.buildPythonPackage rec {
        pname = "dymoprint";
        version = "1.4.1";
        requirements = ''
          importlib-metadata; python_version<"3.8"
          appdirs
          Pillow>=8.1.2,<10
          PyQRCode>=1.2.1,<2
          python-barcode>=0.13.1,<1
          pyusb
          setuptools_scm
          PyQt6
          pyqt6-tools
        '';
        src = pkgs.python3Packages.fetchPypi {
          inherit pname version;
          sha256 = "sha256-XJ+z1zzrcsDJcyMaVZcIkswRakba19PHTIHSVxsmeuI=";
        };
      };
    in {
      defaultPackage = dymoprint;
    });
}

@spease
Copy link
Author

spease commented Jul 7, 2023

That's pretty involved but it looks like you put a lot of effort into it. Will this be stable enough to submit to nixpkgs?

EDIT: And thanks

@TyberiusPrime
Copy link
Collaborator

Unfortunately, mach-nix is all about 'import from derivation' - derivations computing what derivations are actually needed. That's a no-go in nixpkgs.

But of course, at the point where you have a working mach-nix setup, it's just mechanical to get it to something nixpkgs can accept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants