[Nix-dev] pypi2nix: generate full PYTHONPATH from requirements?

Freddy Rietdijk freddyrietdijk at fridh.nl
Sat Nov 5 21:59:36 CET 2016


I am not familiar with the details of pypi2nix, but try and use
`python.withPackages` to create an environment where all packages can be
found by the interpreter. PYTHONPATH is still used a lot, especially with
modules, but we shouldn't be using it.

http://nixos.org/nixpkgs/manual/#python

On Sat, Nov 5, 2016 at 9:50 PM, Daniel Hlynskyi <abcz2.uprola at gmail.com>
wrote:

> I'm trying to use pypi2nix-generated expression to create Kallithea
> service.
>
>      systemd.services.kalithea = {
>       after = [ "network.target" ];
>       wantedBy = [ "multi-user.target" ];
>       script =
>       let ppath =
>         concatMapStringsSep ":" (x: "${x}/${python.interpreter.python.sitePackages}")
> (let self = python.packages; in [
>           # package
>           self."Kallithea"
>           # deps
>           self."Babel"
>           self."Beaker"
>           self."FormEncode"
>           self."Mako"
>           self."Markdown"
>           self."Pygments"
>           self."Pylons"
>           self."Routes"
>           self."SQLAlchemy"
>           self."URLObject"
>           self."WebHelpers"
>           self."WebOb"
>           self."WebTest"
>           self."Whoosh"
>           self."celery"
>           self."docutils"
>           self."dulwich"
>           self."mercurial"
>           self."mock"
>           self."py-bcrypt"
>           self."python-dateutil"
>           self."waitress"
>           # second level deps
>           self."MarkupSafe"
>           self."funcsigs"
>           self."pbr"
>           self."six"
>           # TODO: add all the others
>         ]);
>       in ''
>         export PYTHONPATH=${ppath}
>         ${pythonPackages.pasteScript}/bin/paster serve
> ${kallithea1}/etc/development.ini;
>       '';
>     };
>
> So I need to feed PYTHONPATH into service, but I don't know a nice way to
> recursively aggregate all the propagatedBuildInputs from Kallithea into
> full PYTHONPATH
> (and service wants all of them, as far as I understand)
>
> So, is there a way to do this? I'm pretty new to Python infrastructure and
> perhaps miss some obvious thing.
>
> PS. Pinging my previous ask about PERL5LIB, which is an example of exact
> this problem, but with Perl.
>
> https://www.mail-archive.com/nix-dev@lists.science.uu.nl/msg22577.html
>
> The solution I found breaks on Travis (I guess, it is of kind "import from
> derivation", so it won't work generally)
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.science.uu.nl/pipermail/nix-dev/attachments/20161105/1b61acca/attachment.html>


More information about the nix-dev mailing list