Building python bindings of Go library


I would like to build the Python bindings included in the go-jsonnet project. I tried with this nix definition:

{ pkgs ? import <nixpkgs> { } }:

  py = let
    packageOverrides = self: super: {
      go-jsonnet = super.buildPythonPackage { inherit (pkgs.go-jsonnet) name src nativeBuildInputs ; };
  in (pkgs.python37.override { inherit packageOverrides; }).pkgs;
in py.go-jsonnet

But all I manage to obtain is

failed to initialize build cache at /homeless-shelter/.cache/go-build: mkdir /homeless-shelter: permission denied

which just tells me that pythonBuildPackages does not activate a correct golang build environment.

How can I pursue ?

  preBuild = ''

would be the quick and fast solution for this.

However, it looks like it’s trying to a go build from the python package… which is odd.

The way the Python packaging of this Go library is done imply compilation of the Go library itself. This is my main problem.

I see two possible ways but I have not the knowledge necessary to do any if them. Either we must add all Go components necessary to the python build. Or perhaps we could use the output of the go-module build and only build python-specific code in the python build.

I am still stuck.

Envoyé depuis un ordiphone. Veuillez excuser la brièveté.

-------- Message d’origine --------

I would personally try to extend the go build with an option to also build a python package, but any way you do it, this is still take some knowledge about nix’s python and go tooling