How to create a development environment for build123d

Yeah, you did get pretty close. :o)

The most immediate problem is in the shellHook of the shell-python.nix.

    # Augment the dynamic linker path
    export "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${lib-path}"

    # fixes libstdc++ issues and libgl.so issues
    LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.stdenv.cc.cc ];

In bash, A = abc and A=abc don’t mean the same thing. (And so this trips up when bash runs the shellHook).

The shellHook is a string that gets run by bash. – However, the ${...} values within the string get interpolated before being passed to bash. So, any “nix code” (like the lib.makeLibraryPath application) should be in a ${...}.

– I see these shells include e.g. lolcat and cowsay. That’s good troubleshooting instinct. The smaller problem to focus on could’ve been “why isn’t lolcat showing up?”. Perhaps adding a few echos into the shellHook (at the start, in the middle) would’ve helped you.

The next steps involve figuring out where to pass those native dependencies that Python wants. – Reading through the code, LD_LIBRARY_PATH uses lib-path, which is defined in terms of buildInputs, which also looks at the extraBuildInputs attribute that the shell-build123d.nix calls shell-python.nix with.

Should be:

  extraBuildInputs = with pkgs; [
    # this list contains packages that you want to be available at runtime and might not be able to be installed properly via pip
    stdenv.cc.cc.lib
  ];

I’d suggest putting those example Python commands in a script like demo.py

from build123d import *
print(Solid.make_box(1,2,3).show_topology(limit_class="Face"))

That way, you can see if this runs by running the command:

nix-shell shell-build123d.nix --command "python demo.py"

There are a few more shared libs you need, so extraBuildInputs needs a few more things. This’d best be left as an exercise, but you’re impatient:

  extraBuildInputs = with pkgs; [
    # this list contains packages that you want to be available at runtime and might not be able to be installed properly via pip
    stdenv.cc.cc.lib
    expat
    libGL
    xorg.libX11
    zlib
  ];
2 Likes