Skip to content

Instantly share code, notes, and snippets.

@FRidh
Forked from olejorgenb/propagatedPython.nix
Last active September 3, 2016 11:58
Show Gist options
  • Save FRidh/84dd06b8af60bdb405aa89121c8f928c to your computer and use it in GitHub Desktop.
Save FRidh/84dd06b8af60bdb405aa89121c8f928c to your computer and use it in GitHub Desktop.
Find python packages that are likely to fail when used through "nix-shell -p"
# Produce a list of derivations that should likely have pythonPath set
with import <nixpkgs> {};
with builtins;
let
# Package set to check
pythonPackages = pkgs.python2Packages;
# evaluate expr, returning default on error
tryDefault = expr: default:
let
res = (tryEval expr);
in if res.success then res.value else default;
isPython = pkg: pkg?name && (parseDrvName pkg.name).name == "python";
hasPropagatedPython = pkg: (pkg?propagatedNativeBuildInputs && (length (filter isPython pkg.propagatedNativeBuildInputs)) > 0);
# Skip broken packages and packages that don't support the given python version
validPythonPackage = pkg: tryDefault (pkg?disabled -> !pkg.disabled) false;
validPythonPackages = pkgs: (filter validPythonPackage (attrValues pkgs));
withoutPropagatedPython = pkgs: filter (pkg: tryDefault (pkg?name && !(hasPropagatedPython pkg)) false) (validPythonPackages pkgs);
pkgsWithoutPropagatedPython = builtins.map (pkg: pkg.name) (withoutPropagatedPython pythonPackages);
in pkgs.writeTextFile {
name = "python-packages-without-pythonpath.json";
text = toJSON pkgsWithoutPropagatedPython;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment