Hi Guix,

I have a bunch of web services, written in Python using Flask, and I would
love to run them as Guix services, but I cannot figure out how to make that 
work!?
The only example I could put my hands on is `patchwork-service-type`, but it’s
different for it provides its own script to run the web server, 
`patchwork-admin`.

My web services follow the WSGI specification and can be run using different
servers (`uwsgi`, `gunicorn`…) so, to me, it’s up to the person starting
the service, and writing the service definition, to pick one and run it.

I’ve tried several different approaches, but always end up with something 
broken.
With my last attempt (below) the service runs, but cannot find `Flask` which
is a `propagated-inputs` of the `gertrude` package.

```scheme
(define (gertrude-shepherd-service config)
  (match-record config <gertrude-configuration>
    (address port workers data-source-name user group log-file)
    (list
     (shepherd-service
      (documentation "Run a @code{gertrude} instance.")
      (provision '(gertrude))
      (requirement '(networking))
      (start #~(make-forkexec-constructor
                (list
                  (string-append #$gunicorn "/bin/gunicorn")
                  (string-append "--access-logfile=-")
                  (string-append "--workers=" (number->string #$workers))
                  (string-append "--bind=" #$address ":" (number->string 
#$port))
                  "gertrude.configuration:wsgi()")
                #:user #$user
                #:group #$group
                #:log-file #$log-file
                #:environment-variables (list
                  (string-append "PYTHONPATH=" #$(file-append gertrude
                    (string-append
                     "/lib/python"
                     (version-major+minor
                      (package-version python))
                     "/site-packages/")))
                  (string-append "DSN=" #$data-source-name))))
      (stop #~(make-kill-destructor))))))
```

The only way I’ve found to make `gunicorn` "see" `gertrude` is by modifying
the `PYTHONPATH`. This works, but it doesn’t see the package 
`propagated-inputs`.
I don’t feel like adding all the package dependencies to the `PYTHONPATH`
is the proper way to solve the problem, right?

Am I missing something obvious?!

--
Tanguy

Reply via email to