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

Fix infinite recursion for aliases in pkgs/top-level/python-aliases.nix #787

Merged
merged 1 commit into from Dec 7, 2022

Conversation

SemMulder
Copy link
Contributor

This fixes #750.

A better fix for this might be to set e.g. meta.isAlias = true in nixpkgs/blob/master/pkgs/top-level/python-aliases.nix. Let me know if that is a better route :).

@K900
Copy link
Contributor

K900 commented Nov 1, 2022

One thing I thought of doing instead is just using the normalized nixpkgs attrset as a base, without adding normalization as an overlay. That should get things building again and also allow us to find some unnormalized names in overrides.

@SemMulder
Copy link
Contributor Author

normalized nixpkgs attrset as a base

Do you mean using python.pkgs from nixpkgs as is, so without using the existing overlay mechanism offered in nixpkgs (i.e. packageOverrides)? Then normalizing python.pkgs. And then building our own overlay mechanism on top of that?

I think that would be a nicer solution as well. But I'm not sure if we can make it work:

One thing I'm not sure about is that then any package we include directly from the raw python.pkgs in the final "virtualenv" would ship with its own set of dependencies (i.e. with the versions in the raw python.pkgs). But those dependencies might also be specified in poetry.lock, but with a different version. That would result in collisions, I think.

Or can we avoid including any package from python.pkgs in the final virtualenv? Strictly speaking, I think we only need some packages (setuptools, pip etc.) to allow building the Python packages from poetry.lock. But then we would also need to duplicate the work already done in python.pkgs (e.g. specifying runtime dependencies, difficult build processes) I think? Not sure how much of that we are actually currently using or not?

@K900
Copy link
Contributor

K900 commented Nov 1, 2022

No, I mean replacing python.pkgs with a normalized version of itself, so doing the same thing, but removing all the non-normalized names.

@SemMulder
Copy link
Contributor Author

@K900 do you mean something like this?

@cpcloud
Copy link
Collaborator

cpcloud commented Nov 7, 2022

@adisbladis Can you take a look at this? It'd be swell if we could address the infinite recursion issue with aliased packages.

@mrene mrene mentioned this pull request Nov 12, 2022
@NorfairKing
Copy link
Contributor

@adisbladis Gentle ping

@NorfairKing
Copy link
Contributor

@adisbladis Ping. This is blocking an upgrade for us.

@cpcloud
Copy link
Collaborator

cpcloud commented Dec 6, 2022

@adisbladis Any chance you can take a look at this? Otherwise, I'll try this out on a recent version of mkdocs which has this problem and if it successfully builds I'll merge this PR.

@tfmoraes
Copy link
Contributor

tfmoraes commented Dec 6, 2022

I'm using this poetry2nix branch and it was working. But if I update torch to 1.13 I start to have a problem with infinite recursion. This is the output:

warning: Git tree '/home/thiago/Sources/github/invesalius3_nix_develop' is dirty
error: infinite recursion encountered

       at /nix/store/wm2w45lg0dqrcfrn54dijw30ljpx5k8k-source/pkgs/stdenv/generic/make-derivation.nix:311:7:

          310|       depsBuildBuild              = lib.elemAt (lib.elemAt dependencies 0) 0;
          311|       nativeBuildInputs           = lib.elemAt (lib.elemAt dependencies 0) 1;
             |       ^
          312|       depsBuildTarget             = lib.elemAt (lib.elemAt dependencies 0) 2;while evaluating the attribute 'nativeBuildInputs' of the derivation 'python3.10-python3.10-wheel-0.38.4'

       at /nix/store/wm2w45lg0dqrcfrn54dijw30ljpx5k8k-source/pkgs/stdenv/generic/make-derivation.nix:270:7:

          269|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          270|       name =
             |       ^
          271|         letwhile evaluating the attribute 'outPath'

       at /nix/store/wm2w45lg0dqrcfrn54dijw30ljpx5k8k-source/lib/customisation.nix:214:7:

          213|       drvPath = assert condition; drv.drvPath;
          214|       outPath = assert condition; drv.outPath;
             |       ^
          215|     };while evaluating 'optionalString'

       at /nix/store/wm2w45lg0dqrcfrn54dijw30ljpx5k8k-source/lib/strings.nix:213:5:

          212|     # String to return if condition is true
          213|     string: if cond then string else "";
             |     ^
          214|

       … from call site

       at /nix/store/wm2w45lg0dqrcfrn54dijw30ljpx5k8k-source/pkgs/build-support/trivial-builders.nix:575:12:

          574|         cp ${script} $out/nix-support/setup-hook
          575|       '' + lib.optionalString (deps != []) ''
             |            ^
          576|         printWords ${toString deps} > $out/nix-support/propagated-build-inputs

       … while evaluating the attribute 'buildCommand' of the derivation 'wheel-unpack-hook.sh'

       at /nix/store/wm2w45lg0dqrcfrn54dijw30ljpx5k8k-source/pkgs/stdenv/generic/make-derivation.nix:270:7:

          269|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          270|       name =
             |       ^
          271|         letwhile evaluating the attribute 'nativeBuildInputs' of the derivation 'python3.10-parso-0.8.3'

       at /nix/store/wm2w45lg0dqrcfrn54dijw30ljpx5k8k-source/pkgs/stdenv/generic/make-derivation.nix:270:7:

          269|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          270|       name =
             |       ^
          271|         letwhile evaluating the attribute 'out.outPath'

       at /nix/store/wm2w45lg0dqrcfrn54dijw30ljpx5k8k-source/lib/customisation.nix:207:13:

          206|             drvPath = assert condition; drv.${outputName}.drvPath;
          207|             outPath = assert condition; drv.${outputName}.outPath;
             |             ^
          208|           };while evaluating anonymous lambda

       at /nix/store/wm2w45lg0dqrcfrn54dijw30ljpx5k8k-source/lib/lists.nix:646:25:

          645|    */
          646|   unique = foldl' (acc: e: if elem e acc then acc else acc ++ [ e ]) [];
             |                         ^
          647|

       … from call site

       at /nix/store/wm2w45lg0dqrcfrn54dijw30ljpx5k8k-source/pkgs/development/interpreters/python/python-packages-base.nix:52:6:

           51|     modules = lib.filter hasPythonModule drvs;
           52|   in lib.unique ([python] ++ modules ++ lib.concatLists (lib.catAttrs "requiredPythonModules" modules));
             |      ^
           53|

       … while evaluating 'requiredPythonModules'

       at /nix/store/wm2w45lg0dqrcfrn54dijw30ljpx5k8k-source/pkgs/development/interpreters/python/python-packages-base.nix:50:27:

           49|   # Get list of required Python modules given a list of derivations.
           50|   requiredPythonModules = drvs: let
             |                           ^
           51|     modules = lib.filter hasPythonModule drvs;

       … from call site

       at /nix/store/wm2w45lg0dqrcfrn54dijw30ljpx5k8k-source/pkgs/development/interpreters/python/python-packages-base.nix:67:33:

           66|         pythonPath = [ ]; # Deprecated, for compatibility.
           67|         requiredPythonModules = requiredPythonModules drv.propagatedBuildInputs;
             |                                 ^
           68|       };

       … while evaluating 'requiredPythonModules'

       at /nix/store/wm2w45lg0dqrcfrn54dijw30ljpx5k8k-source/pkgs/development/interpreters/python/python-packages-base.nix:50:27:

           49|   # Get list of required Python modules given a list of derivations.
           50|   requiredPythonModules = drvs: let
             |                           ^
           51|     modules = lib.filter hasPythonModule drvs;

       … from call site

       at /nix/store/wm2w45lg0dqrcfrn54dijw30ljpx5k8k-source/pkgs/development/interpreters/python/python-packages-base.nix:67:33:

           66|         pythonPath = [ ]; # Deprecated, for compatibility.
           67|         requiredPythonModules = requiredPythonModules drv.propagatedBuildInputs;
             |                                 ^
           68|       };

       … while evaluating 'requiredPythonModules'

       at /nix/store/wm2w45lg0dqrcfrn54dijw30ljpx5k8k-source/pkgs/development/interpreters/python/python-packages-base.nix:50:27:

           49|   # Get list of required Python modules given a list of derivations.
           50|   requiredPythonModules = drvs: let
             |                           ^
           51|     modules = lib.filter hasPythonModule drvs;

       … from call site

       at /nix/store/qrfavlffxx8a8d3mkb5zp474z0835ryr-source/default.nix:279:23:

          278|       */
          279|       storePackages = requiredPythonModules (builtins.foldl' (acc: v: acc ++ v) [ ] (lib.attrValues inputAttrs));
             |                       ^
          280|     inwhile evaluating the attribute 'poetryPackages'

       at /nix/store/qrfavlffxx8a8d3mkb5zp474z0835ryr-source/default.nix:283:7:

          282|       python = py;
          283|       poetryPackages = storePackages
             |       ^
          284|         ++ lib.optional hasScripts scriptsPackage

       … while evaluating anonymous lambda

       at /nix/store/qrfavlffxx8a8d3mkb5zp474z0835ryr-source/default.nix:351:39:

          350|     in
          351|     poetryPython.python.withPackages (ps: envPkgs ++ (extraPackages ps));
             |                                       ^
          352|

       … from call site

       at /nix/store/wm2w45lg0dqrcfrn54dijw30ljpx5k8k-source/pkgs/development/interpreters/python/with-packages.nix:3:19:

            2|
            3| f: let packages = f pythonPackages; in buildEnv.override { extraLibs = packages; }
             |                   ^

       … while evaluating 'requiredPythonModules'

       at /nix/store/wm2w45lg0dqrcfrn54dijw30ljpx5k8k-source/pkgs/development/interpreters/python/python-packages-base.nix:50:27:

           49|   # Get list of required Python modules given a list of derivations.
           50|   requiredPythonModules = drvs: let
             |                           ^
           51|     modules = lib.filter hasPythonModule drvs;

       … from call site

       at /nix/store/wm2w45lg0dqrcfrn54dijw30ljpx5k8k-source/pkgs/development/interpreters/python/wrapper.nix:20:13:

           19|   env = let
           20|     paths = requiredPythonModules (extraLibs ++ [ python ] ) ;
             |             ^
           21|     pythonPath = "${placeholder "out"}/${python.sitePackages}";while evaluating the attribute 'passAsFile'

       at /nix/store/wm2w45lg0dqrcfrn54dijw30ljpx5k8k-source/pkgs/build-support/buildenv/default.nix:77:5:

           76|     # XXX: The size is somewhat arbitrary
           77|     passAsFile = if builtins.stringLength pkgs >= 128*1024 then [ "pkgs" ] else [ ];
             |     ^
           78|   }

       … while evaluating the attribute 'passAsFile' of the derivation 'python3-3.10.8-env'

       at /nix/store/wm2w45lg0dqrcfrn54dijw30ljpx5k8k-source/pkgs/stdenv/generic/make-derivation.nix:270:7:

          269|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          270|       name =
             |       ^
          271|         letwhile evaluating the attribute 'buildInputs' of the derivation 'nix-shell'

       at /nix/store/wm2w45lg0dqrcfrn54dijw30ljpx5k8k-source/pkgs/stdenv/generic/make-derivation.nix:270:7:

          269|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          270|       name =
             |       ^
          271|         let

@adisbladis
Copy link
Member

@tfmoraes Just eyeballing that stack trace it looks to me like a different recursion issue than this one. Could you open a new issue?

@adisbladis
Copy link
Member

This achieves the same thing I wanted to with normalisation, so I'm happy with this.

@adisbladis adisbladis merged commit ce618e3 into nix-community:master Dec 7, 2022
@tfmoraes
Copy link
Contributor

tfmoraes commented Dec 7, 2022

Done @adisbladis! I opened this issue #850

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

Successfully merging this pull request may close these issues.

infinite recursion encountered
6 participants