-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
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
Python: Fixed-point combinator #17428
Conversation
@FRidh, thanks for your PR! By analyzing the annotation information on this pull request, we identified @bennofs, @domenkozar and @vcunat to be potential reviewers |
I have a strange problem. The following works
but when I call with any Python 3.x interpreter I get
It does work correctly with |
if isPy34 then "python34" else | ||
if isPy35 then "python35" else | ||
if isPy36 then "python36" else | ||
if isPyPy then "pypy" else ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something like
else (assert false; "");
I do not see a situation where none of the previous cases evaluates to true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw "<some descriptive error message>"
would be better in this case. But could we perhaps just use python.name
(which should be something like "python-2.6" etc)? The problem with hardcoding pythonName
here is that it is difficult for people to add a new interpreter locally (say they have packaged python3.7
and want to test this out), because they have to edit nixpkgs to add a new interpreter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this is what we have currently in python-packages.nix
.
A git grep showed we actually don't use pythonName
anywhere so I will remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and its gone 2988112
|
pythonPackages = self: | ||
let | ||
python = interpreter; | ||
in import ./support.nix { inherit pkgs python; } self; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the following would be a better way to write this:
let
...
pythonPackages = import ./support.nix {
inherit pkgs;
python = interpreter;
};
Avoids the let, so it is more clear that the python
is only used to pass to support.nix
.
Thanks for the feedback. What do you think about the splitting up of the packages ( |
I don't have a strong opinion either way. |
@bennofs do you have any idea what is causing #17428 (comment)? |
@@ -5878,44 +5878,25 @@ in | |||
}; | |||
purePackages = recurseIntoAttrs (callPackage ./pure-packages.nix {}); | |||
|
|||
pythonNew = callPackage ./python-new-packages.nix {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unless python
wouldn't point to the interpreter anymore, I think a better name is needed here. Any suggestions? Another possibility is to directly include the contents of python-new-packages.nix
into all-packages.nix
. That way you have pkgs.cpython27.pkgs
, pkgs.pypy27.buildEnv
, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One advantage of this name is that it is consistent with haskell: for Haskell, haskell
also does not point to the compiler but there is haskell.compiler.ghc7103
for example. Of course, with Haskell, it is more clear since the compiler and the language have different names.
07bcd2f
to
9e98d32
Compare
Both python3 and setuptools come with easy-install. For some magic reason this hasn't caused any collisions yet, but it does with #17428. We hereby prioritize the version that comes with setuptools.
#17428 (comment) is solved with 8fad3e8 |
f2c74eb
to
7be184f
Compare
I've introduced an extra function for building Python packages that do not come with |
I have tried this PR, and I am hitting some chicken and egg problem. Documenting pythonNew may seem useless because test results may trigger changes, but testing without documentation is... hard :-). Anyway, this PR breaks pythonPackages.lti. This package is interesting because it needs to be built in a different scope, where pytest is pytest_27 instead of the default pytest_29. |
@layus thanks for checking it out. Calling I will add to the set which has no name yet a small function that allows you to easily build a new set for that interpreter. I think that would be very convenient. I'm a bit short in time atm but will get back to you! |
I had a simple hack implemented in https://gist.github.com/layus/311fb6cb9d6c83dadb1e1522c6caa9ee. I know it only allows to override |
Well, right now we have
It should definitely still be possible to do such overrides within the package set, not being able to is a bug! (There are still plenty issues with this.) If you do need to override the interpreter you will inevitably get a new package set in which case you can use what I wrote. |
I would go with the following attributes hierarchy (inspired by haskell):
For completeness, you could even add cross-references:
Of course, this means that python.pkgs.interpreter.pkgs.interpreter is valid, but not necessarily a problem. Finally, pythonNew.interpreters.cpython27 could be both an interpreter set (buildPythonPackage, mkDerivation, wrapPython, etc.) and a derivation. This is possible in nix, and would avoid the extra @FRidh: Is there any way I can help you with this PR ? |
Thanks for the offer! The biggest issue at the moment is deciding on exactly how this should look like, before moving on.
I considered that first (I just copied it as a starting point) but whereas Haskell has multiple compilers and multiple package sets, with Python we have multiple interpreters and only one package set. Therefore I dropped
and went with
instead.
Indeed, and that is basically what we do currently with the interpreters and
Also, what do you think of actually putting the interpreters directly in top-level, that is, merging the two sets so we get |
Who cares? Nix is lazy enough avoid building the package set if you don't need it. It is only a potential package set.
Okay
Huh ? Do you mean a string like "pypy27" ? In that case we already have
Not sure what you mean here. I have considered putting packages directly under As for removing the |
Let's denote If you want something more flat, we could even go with How badly would we break nixpkgs with this scheme ? |
Its more that if you want to build just the interpreter you have to pass in something looking like a package set. Or, actually, we build the package set inside the derivation of the interpreter. That way you can easily override the interpreter without fighting to get the package set to use the updated interpreter.
I was referring to one of the attributes that is currently passed through.
No, we won't, since we don't use the
Nothing really, if you pass |
83dd12d
to
ebf0b8a
Compare
I've simplified the changes somewhat. It doesn't work entirely yet, but I think it is an improvement nevertheless. The following example shows how to build scipy with an older version of numpy
and this derivation can be build with
Furthermore, @layus , lti doesn't work yet work. I guess I have to find the right spot to apply makeOverridable. |
@layus in order to find a solution to I had a look at the Haskell package set for a solution. Like in This we should be able to get working with |
Use a fixed-point combinator for the Python package set to allow easier overriding of its contents. Earlier implementations were proposed in NixOS#16784 and NixOS#17428. This commit is by comparison much smaller and changes only what is needed.
Motivation for this change
Use fixed-point combinator for
python-packages.nix
.Follow-up of #16784.
pythonFull