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

Rok Garbas rok at garbas.si
Sat Nov 5 22:45:56 CET 2016


Hi Daniel,

which pypi2nix version are you using?

you should create a kalitea python package and wrap paste script. here
is how i do it for gunicorn.
https://github.com/mozilla-releng/services/blob/master/nix/lib/default.nix#L329

also i suggest you report issues / questions to pypi2nix issue
tracker. i'm not always looking at nix-dev mailing list.

lp rok

On Sat, Nov 5, 2016 at 10:15 PM, Freddy Rietdijk
<freddyrietdijk at fridh.nl> wrote:
> Check e.g. the mopidy service
> https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/audio/mopidy.nix
>
> Instead of `python.withPackages` `python.buildEnv.override{extralibs=...;}`
> is used. `withPackages` is just a wrapper around `buildEnv`.
>
> On Sat, Nov 5, 2016 at 10:09 PM, Daniel Hlynskyi <abcz2.uprola at gmail.com>
> wrote:
>>
>> pypi2nix supports `python.withPackages`. But how should I use the created
>> "environment" in NixOS service?
>>
>> path = [ python-env ];
>>
>> doesn't work
>>
>> 2016-11-05 22:59 GMT+02:00 Freddy Rietdijk <freddyrietdijk at fridh.nl>:
>>>
>>> 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
>>>>
>>>
>>
>
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>



-- 
Rok Garbas
https://garbas.si


More information about the nix-dev mailing list