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
pythonPackages: Add aliases 🎉 #116367
pythonPackages: Add aliases 🎉 #116367
Conversation
Result of 2 packages built successfully:1 suggestion:
Result of 2 packages built successfully:1 suggestion:
|
d1a4de3
to
f8a8e3f
Compare
f36c8bc
to
3b69b40
Compare
NIce work! diff --git a/pkgs/development/interpreters/python/default.nix b/pkgs/development/interpreters/python/default.nix
index 1925089921c..0e5ebfaa4ff 100644
--- a/pkgs/development/interpreters/python/default.nix
+++ b/pkgs/development/interpreters/python/default.nix
@@ -69,7 +69,7 @@ with pkgs;
recursivePthLoader
;
};
- aliases = self: super: lib.optionalAttrs (config.allowAliases or true) (import ../../../top-level/python-aliases.nix lib super);
+ aliases = lib.optionalAttrs (config.allowAliases or true) (import ../../../top-level/python-aliases.nix lib);
in lib.makeScopeWithSplicing
pkgs.splicePackages
pkgs.newScope
diff --git a/pkgs/top-level/python-aliases.nix b/pkgs/top-level/python-aliases.nix
index 10db7748fe9..76338061ff2 100644
--- a/pkgs/top-level/python-aliases.nix
+++ b/pkgs/top-level/python-aliases.nix
@@ -16,7 +16,7 @@ let
# Make sure that we are not shadowing something from
# python-packages.nix.
- checkInPkgs = n: alias: if builtins.hasAttr n self
+ checkInPkgs = n: alias: if builtins.hasAttr n super
then throw "Alias ${n} is still in python-packages.nix"
else alias; |
This won't work, since |
What would be the correct syntax or does it not require any change at all? |
e271e3b
to
97e003c
Compare
I don't fully understand why and how ofborg fails and I can't locally run the ofborg checks because I only have ~16 GB available. |
pkgs/top-level/python-aliases.nix
Outdated
let | ||
# Removing recurseForDerivation prevents derivations of aliased attribute | ||
# set to appear while listing all the packages available. | ||
removeRecurseForDerivations = alias: removeAttrs alias [ "recurseForDerivations" ]; |
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.
The eval error was caused by this, sorry about that. Somehow blacked out and forgot that pythonPackages also contains functions and such.
removeRecurseForDerivations = alias: removeAttrs alias [ "recurseForDerivations" ]; | |
removeRecurseForDerivations = alias: | |
if lib.isAttrs alias # removeAttrs throws in all other cases | |
then builtins.removeAttrs alias [ "recurseForDerivations" ] | |
else alias; |
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 used the variant that is used in aliases.nix because I don't fully understand this part to be honest.
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.
The code from top level removes the attribute recurseForDerivations
from an attribute set if it exists and is true. My code tries to always remove the recurseForDerivations
attribute if it encounters an attribute set.
Shouldn't make a derifference in the grand scheme of things and only matters if we have sub attribute sets in pythonPackages anyways.
97e003c
to
0aaa07f
Compare
…_common_protos Co-authored-by: sterni <sternenseemann@systemli.org>
0aaa07f
to
b92a2bc
Compare
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.
diff LGTM
seems to work as expected:
[nix-shell:~/.cache/nixpkgs-review/pr-116367]$ nix-build ./nixpkgs/ -A python3Packages.smart_open
/nix/store/yrnw7sl5iaqb1xvyjbj0fmjny6lph37l-python3.8-smart-open-4.2.0
[nix-shell:~/.cache/nixpkgs-review/pr-116367]$ nix-build ./nixpkgs/ -A python3Packages.smart-open
/nix/store/yrnw7sl5iaqb1xvyjbj0fmjny6lph37l-python3.8-smart-open-4.2.0
[nix-shell:~/.cache/nixpkgs-review/pr-116367]$ nix-build -E 'with import ./nixpkgs { config.allowAliases = false; }; python3Packages.smart_open'
error: attribute 'smart_open' missing
at «string»:1:58:
1| with import ./nixpkgs { config.allowAliases = false; }; python3Packages.smart_open
|
[nix-shell:~/.cache/nixpkgs-review/pr-116367]$ nix-build -E 'with import ./nixpkgs { config.allowAliases = true; }; python3Packages.smart_open'
/nix/store/yrnw7sl5iaqb1xvyjbj0fmjny6lph37l-python3.8-smart-open-4.2.0
Motivation for this change
Just removing or renaming packages is not nice so I thought we want aliases for python packages. With this PR I included one package I used for testing. Most of the python-aliases.nix is copied from aliases.nix. If this PR is merged I am going to move some aliases which are currently in python-packages. I am probably not renaming all the packages though.
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)