[Nix-dev] pypi2nix: generate full PYTHONPATH from requirements?
Daniel Hlynskyi
abcz2.uprola at gmail.com
Sat Nov 5 22:44:42 CET 2016
that did the trick, thanks!
systemd.services.kalithea = {
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
script =
let env = pythonPackages.python.buildEnv.override {
extraLibs = [ python.packages.Paste python.packages.Kallithea
pythonPackages.pysqlite ];
ignoreCollisions = true;
};
in ''
${env}/bin/paster serve ${config};
'';
};
2016-11-05 23:15 GMT+02:00 Freddy Rietdijk <freddyrietdijk at fridh.nl>:
> 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
>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.science.uu.nl/pipermail/nix-dev/attachments/20161105/367769a3/attachment.html>
More information about the nix-dev
mailing list