Packaging/Python: Difference between revisions

reintroduce comment that tells ppl to replace ./derivation.nix with the appropriate path
Testing out a module in a Python shell: Use python3.withPackages instead of a devshell
Line 37: Line 37:
         };
         };
       in {
       in {
         devShells.default = pkgs.mkShell {
         packages.default = pkgs.python3.withPackages(_: [ xacro ]);
          buildInputs = [ pkgs.python3 xacro ];
        };
       });
       });
}
}
</syntaxhighlight>Replace "mypackage" with your package name. Then, enter the devShell and launch a Python REPL:<syntaxhighlight lang="shell-session">
</syntaxhighlight>Replace "mypackage" with your package name. Then, run the flake to get into a python REPL with your package, ready to be imported:<syntaxhighlight lang="shell-session">
$ nix develop
$ nix run
$ python
Python 3.11.10 (main, Sep  7 2024, 01:03:31) [GCC 13.2.0] on linux
Python 3.11.10 (main, Sep  7 2024, 01:03:31) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
Type "help", "copyright", "credits" or "license" for more information.