You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when we build taiga-back with buildPythonApplication we can run the django application using ./manage.py but not using WSGI mode as the propagatedBuildInputs aren't inherited into the penv used by systemd. when we use buildPythonPackage they are inherited and it works.
FIX: our fix was to use buildPythonPackage in the end but we lost 2 days on debugging this!
REQUEST: could we add a assert or WARNING somewhere in the python abstraction to inform users of that fact? OR could we also inherit the propagatedBuildInputs from the buildPythonApplication?
i'm not very familiar with the python implementation in nixpkgs but this should probably be addressed as others will also run into this making nix look bad.
Issue description
for our WSGI application taiga.wsgi we need to create a proper environment with the PYTHONPATH set since we can't use the usual wrapper.
so our code looks like this:
python = pkgs.python3;
penv = with pkgs.python3Packages; with myPythonPackages; python.buildEnv.override {
extraLibs = [
taiga-back
pkgs.python3Packages.gunicorn
pkgs.python3Packages.gevent
];
};
...
systemd.services.taiga-back = rec {
description = "${config.uniqueName} main service (taigaio, django)";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
environment = {
PYTHONPATH = "${taigaBackConfigPkg}:${penv}/${python.sitePackages}/";
};
serviceConfig = {
User = mkUniqueUser "taigaio";
Group = mkUniqueGroup "taigaio";
WorkingDirectory = "${config.stateDir}/www";
#FIXME check if we can use that
PrivateTmp = false;
ExecStart = ''
${pkgs.python3Packages.gunicorn}/bin/gunicorn taiga.wsgi \
-k gevent \
-u ${mkUniqueUser "taigaio"} \
-g ${mkUniqueGroup "taigaio"} \
--name gunicorn-taiga \
--pythonpath=${environment.PYTHONPATH} \
--log-level ${if config.enableDebug then "debug" else "info"} \
--workers ${toString config.wsgiWorkers} \
--pid ${config.stateDir}/www/gunicorn-taiga.pid \
--bind unix:${config.runtimeDir}/socket
'';
Restart = "always";
PermissionsStartOnly = true;
#PrivateDevices = true;
TimeoutSec = 300; # initial ./manage.py migrate can take a while
};
};
taiga-back.nix
here is the buildPythonPackage vs. buildPythonApplication issue:
REQUEST: could we add a assert or WARNING somewhere in the python abstraction to inform users of that fact? OR could we also inherit the propagatedBuildInputs from the buildPythonApplication?
It's a pity time is wasted on this, but the answer is no, and no.
This difference with it's behavior in python.buildEnv is actually the only functional difference between the two functions, and it exists for a clear reason: a Python env should not get the site-packages from an application that just happens to be written in Python. In case of an application the fact it is written in Python is an implementation detail.
This is important so we can have e.g. a Python 3 environment that calls a Python 2 application. Note some additional issues may exist with PYTHONPATH, but that needs to be solved elsewhere.
What is needed is a line in the manual explaining this behavior.
Then, we could invoke ${issoEnv}/bin/gunicorn isso.run to run Isso through Gunicorn. Is there a better way for that? If not, would it makes sense to makes Isso a module instead of an application (and I suppose this could impact other WSGI applications).
Issue description (short)
when we build taiga-back with
buildPythonApplication
we can run the django application using./manage.py
but not using WSGI mode as the propagatedBuildInputs aren't inherited into thepenv
used by systemd. when we usebuildPythonPackage
they are inherited and it works.FIX: our fix was to use
buildPythonPackage
in the end but we lost 2 days on debugging this!REQUEST: could we add a
assert
or WARNING somewhere in the python abstraction to inform users of that fact? OR could we also inherit thepropagatedBuildInputs
from thebuildPythonApplication
?i'm not very familiar with the python implementation in nixpkgs but this should probably be addressed as others will also run into this making nix look bad.
Issue description
for our WSGI application taiga.wsgi we need to create a proper environment with the PYTHONPATH set since we can't use the usual wrapper.
so our code looks like this:
taiga-back.nix
here is the
buildPythonPackage
vs.buildPythonApplication
issue:Technical
The text was updated successfully, but these errors were encountered: