Discovery of python modules and patchPythonScript

Hi all,
I’m currently trying to package the django-based python application SeaHub that relies on the python modules shipped as part of the autotools-based C programs seafile-server-core and ccnet-server.

The problem here is that the python modules seafile, seaserv (provided by the seafile-server-core package) and ccnet (provided by the ccnet-server package) cannot be found by the script of seahub.

The relevant code can be found here:
As seahub is not a project, I just have to extract the sources and copy them to $out. Currently I try to adjust the python module path of using patchPythonScript from pkgs.python27Programs.wrapPython. But although the required modules are present in $out/lib/python2.7/site-packages/ of ccnet-server and seafile-server-core (specified in the propagatedBuildInputs) they are not found by

The *-bindings build inputs of seahub are just my (likely unnecessary) attempts of applying toPythonPackage to the seafile-server-core and ccnet-server package.

how to reproduce:

  • nix-build '<nixpkgs>' -A seafile-server
  • ./result/seahub/

error message:

ImportError: No module named seaserv

What do I need to do for making the missing modules available to seahub?

PS: I honestly do not fully understand the wrapPython shell functions, although their source contains comments. They should be documented properly in the nixpkgs manual, first of all to make them discoverable.

you’re using buildPythonApplication for seahub, try buildPythonPackage.

buildPythonApplication should only be used when you’re certain you’re not going to be importing it from another package.

1 Like

@jonringer I’ll try that, thx. But shouldn’t patchPythonScript fix that mistake? Apparently it doesn’t as the required site-package paths are not part of the inserted patch :\

Update: using buildPythonPackage did not fix the issue

Also, I am quite certain that seahub is never going to be imported somewhere else.
What does have to be imported by seahub are the modules from ccnet-server and seafile-server-core.

I’m not entire sure what patchPythonScript does. Another thing you will want to verify is that the seahub package is installing to a site-packages directory, look at another python package to see if it’s putting things into the right directory

Another thing which could be going on, is that the package might not be PEP420 compliant, and they have’s at the namespaces. Which breaks how python3 searches for modules

I suggest creating packages with buildPythonPackage so that the modules live in $out/${python.sitePackages}. Do the same for See e.g. the Mailman module in Nixpkgs which is also Django-based

As I already wrote above, it’s not the seahub modules that are not discovered but the seafile/seaserv and ccnet modules, and those are shipped with an Autotools C project.
But I tried building Seahub with buildPythonPackage and that did not resolve the issue.

As you’re the second person confusing which modules are not found, I should probably rephrase the issue description :thinking: