Why is `buildPythonPackage.passthru` not in my `result` folder?

I’ve tried to make a Python package which can be released to PyPI, but somehow the passthru property I specified isn’t included in the derivation result.

The relevant code from the merge request:

{pkgs}: let
  pname = "vcard";
  version = "0.15.0";
  python = pkgs.callPackage ./python.nix {};
  sdist = pkgs.stdenv.mkDerivation {
    name = "${pname}-sdist";
    src = builtins.path {
      name = pname;
      path = ./.;
    };
    installPhase = ''
      python setup.py sdist --dist-dir="$out"
    '';
    strictDeps = true;
  };
in
  python.pkgs.buildPythonPackage {
    inherit pname version;
    src = "${sdist}/${pname}-${version}.tar.gz";
    postCheck = ''
      gunzip --test dist/${pname}-${version}.tar.gz
    '';
    passthru.sdist = sdist;
  }

passthru only passes thru the variable and does not add it to $out so it can’t appear in the result symlink.

OK, I probably misunderstood https://github.com/python-acoustics/python-acoustics/blob/3147c6f579e4de5dbf60ba15ae7381cf1a84e0b1/default.nix in that case. Is any part of that code supposed to result in the package tarball being available for release after nix-build? If not, what do I need to do to achieve that?

If you just wait a little longer until staging-next merged then the sdist will be available in the sdist output by default. That was introduced in buildPython*: store dist (wheel/sdist) in dist output by FRidh · Pull Request #190487 · NixOS/nixpkgs · GitHub

2 Likes

Update: I’ll just wait for pythonOutputDistHook to reach a release; it seems there are too many broken packages and other weirdness going on.

I tried updating nixpgks to the latest staging commit, 8d941befdba9eada10fa3abb845ae41ca1121525, which has pythonOutputDistHook, but there’s no change in the result folder. If I comment out the gzip test in https://gitlab.com/victor-engmark/vcard/-/merge_requests/196/diffs and nix-build it succeeds, but based on a quick ls -R result/ nothing’s changed. Do I need to enable some special setting?

On staging-next the following works.

nix-build -A python310Packages.pytest.dist

and you should get the result-dist link in your current directory

I’m not sure what to do with this information. I can reproduce in nixpkgs, but it doesn’t work the same in my own project - I just get a result link. Relevant code.

Moved to nix - How to use the new `pythonOutputDistHook` in nixpkgs? - Unix & Linux Stack Exchange.