Python: Difference between revisions

imported>Samuela
No edit summary
imported>Lionello
Added example for alternative packages
Line 24: Line 24:
== Using alternative packages ==
== Using alternative packages ==


We saw above how to install Python packages using nixpkgs. Since these are written by hand by nixpkgs maintainers, it isn't uncommon for packages you want to be missing or out of date.
We saw above how to install Python packages using nixpkgs. Since these are written by hand by nixpkgs maintainers, it isn't uncommon for packages you want to be missing or out of date. To create a custom Python environment with your own package(s), first create a derivation for each python package (look at examples in the <code>python-modules</code> subfolder in Nixpkgs). Then, use those derivations with <code>callPackage</code> as follows:
 
<syntaxhighlight lang="nix">
with pkgs;
let
  my-python-package = ps: ps.callPackage ./my-package.nix {};
  python-with-my-packages = python3.withPackages(ps: with ps; [
    (my-python-package ps)
  ]);
in ...
</syntaxhighlight>


=== Python virtual environment ===
=== Python virtual environment ===