[Nix-dev] Python: Provide your own buildPhase and installPhase.

Freddy Rietdijk freddyrietdijk at fridh.nl
Fri May 26 22:36:00 CEST 2017


Hi,

What are you trying to achieve? You want to package panda3d?

The `buildPythonPackage` function builds by default setuptools/distutils
Python packages. When passed `format="flit"` it builds from Flit source,
and when passed `format="wheel'` it takes the wheel and installs it. The
fourth option is, as you mentioned, `format="other"`. In this case, it uses
the `buildPhase` and `installPhase` from `stdenv.mkDerivation` and is
therefore useful for when a Makefile is provided and the package has
scripts that need to be wrapped or provides Python modules.

An example of `format="other"` is how we provide the `tkinter` module from
the standard library.
You don't have to copy the code of the `buildPythonPackage` function, just
call it and pass in the arguments.

Freddy



On Fri, May 26, 2017 at 10:03 PM, Nawal Husnoo <nawal at husnoo.com> wrote:

> Hi,
>
> Could anyone point me to an example where I can see this in action please?
>
> https://github.com/NixOS/nixpkgs/blob/master/pkgs/
> development/interpreters/python/build-python-package.nix
> # "other" : Provide your own buildPhase and installPhase.
>
> Say I copy the build-python-package-flit.nix file as
> build-python-package-panda3d.nix - how do I get my default.nix to use
> this?
>
> My current attempt:
>
> with import <nixpkgs> {};
>
> # nix-shell
>
> # python2.7 makepanda/makepanda.py --everything --wheel --no-egl --no-gles
> --no-gles2 --no-opencv  --use-x11 --use-python --use-gl --use-fftw
> --use-gtk2 --python-incdir /nix/store/3n3r10921c0mzfrq64hc4m2jzjk13qpr-python-2.7.13/include
> --python-libdir /nix/store/3n3r10921c0mzfrq64hc4m2jzjk13qpr-python-2.7.13/lib
>
> # pip install --prefix /home/nawal/usr panda3d-1.10.0-cp27-cp27mu-linux_x86_64.whl
>
> # export PYTHONPATH=/home/nawal/usr/lib/python2.7/site-packages/:$
> PYTHONPATH
>
> (let
>
> panda3d = pkgs.pythonPackages.buildPythonPackage rec{
>     name = "panda3d-${version}";
>     version = "";
>     src = ./panda3d;
>
>
>     propagatedBuildInputs =  [
>         xorg.libX11
>         xorg.xproto
>         pkgconfig
>         python
>         ffmpeg-full
>         assimp
>         freetype
>         harfbuzz
>         glfw
>         ode
>         openal
>         libtiff
>         openexr
>         vrpn
>         bullet
>         libvorbis
>         libjpeg
>         openjpeg
>         libpng
>         openssl
>         zlib
>         gtk2-x11
>         opusTools
>         x11
>         xorg.libX11
>         xorg.xproto
>         pythonPackages.pip
>     ];
> };
>
> in python.buildEnv.override {
>     extraLibs = [
>         panda3d
>         pkgs.pythonPackages.gnureadline
>     ];
>     ignoreCollisions = true;
> }).env
>
>
>
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> https://mailman.science.uu.nl/mailman/listinfo/nix-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.science.uu.nl/pipermail/nix-dev/attachments/20170526/8b9a6f22/attachment.html>


More information about the nix-dev mailing list