-
-
Save Technicus/145c94d0376b129b297b3c589d551657 to your computer and use it in GitHub Desktop.
| # shell-build123d.nix | |
| # Shell environment for build123d | |
| # https://build123d.readthedocs.io/en/latest/index.html | |
| # https://wiki.nixos.org/wiki/Python#Using_nix-shell_alongside_pip | |
| { pkgs ? import <nixpkgs> {} }: | |
| let | |
| myPython = pkgs.python311; | |
| pythonPackages = pkgs.python311Packages; | |
| pythonWithPkgs = myPython.withPackages (pythonPkgs: with pythonPkgs; [ | |
| # This list contains tools for Python development. | |
| # You can also add other tools, like black. | |
| # | |
| # Note that even if you add Python packages here like PyTorch or Tensorflow, | |
| # they will be reinstalled when running `pip -r requirements.txt` because | |
| # virtualenv is used below in the shellHook. | |
| ipython | |
| pip | |
| setuptools | |
| virtualenvwrapper | |
| wheel | |
| black | |
| # https://discourse.nixos.org/t/what-package-provides-libstdc-so-6/18707/3 | |
| stdenv | |
| ]); | |
| 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 | |
| pythonPackages.pandas | |
| pythonPackages.stdenv | |
| pythonPackages.requests | |
| stdenv.cc.cc.lib | |
| gcc | |
| expat | |
| libGL | |
| xorg.libX11 | |
| zlib | |
| ]; | |
| in | |
| import ./shell-python.nix { | |
| extraBuildInputs=extraBuildInputs; | |
| # extraLibPackages=extraLibPackages; | |
| myPython=myPython; | |
| pythonWithPkgs=pythonWithPkgs; | |
| } |
| # python-shell.nix | |
| { pkgs ? import <nixpkgs> {}, extraBuildInputs ? [], myPython ? pkgs.python3, extraLibPackages ? [], pythonWithPkgs? myPython }: | |
| let | |
| buildInputs = with pkgs; [ | |
| clang | |
| llvmPackages_16.bintools | |
| rustup | |
| # stdenvNoCC | |
| # stdenvNoLibs | |
| # stdenv_32bit | |
| # gccStdenv | |
| # gccStdenvNoLibs | |
| # libcxxStdenv | |
| # gccMultiStdenv | |
| # gcc49Stdenv | |
| ] ++ extraBuildInputs; | |
| lib-path = with pkgs; lib.makeLibraryPath buildInputs; | |
| shell = pkgs.mkShell { | |
| buildInputs = [ | |
| # my python and packages | |
| pythonWithPkgs | |
| # other packages needed for compiling python libs | |
| pkgs.readline | |
| pkgs.libffi | |
| pkgs.openssl | |
| pkgs.git | |
| pkgs.openssh | |
| pkgs.rsync | |
| pkgs.cowsay | |
| pkgs.lolcat | |
| pkgs.nix-index | |
| # unfortunately needed because of messing with LD_LIBRARY_PATH below | |
| pkgs.gcc | |
| pkgs.stdenv | |
| # pkgs.stdenv-linux | |
| pkgs.stdenvNoCC | |
| pkgs.stdenvNoLibs | |
| pkgs.stdenv_32bit | |
| pkgs.gccStdenv | |
| pkgs.gccStdenvNoLibs | |
| pkgs.libcxxStdenv | |
| pkgs.gccMultiStdenv | |
| pkgs.gcc49Stdenv | |
| ] ++ extraBuildInputs; | |
| GREETING = "Entering build123d development shell!"; | |
| shellHook = '' | |
| # Allow the use of wheels. | |
| SOURCE_DATE_EPOCH=$(date +%s) | |
| # Augment the dynamic linker path | |
| export "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${lib-path}" | |
| # https://discourse.nixos.org/t/what-package-provides-libstdc-so-6/18707/4 | |
| # fixes libstdc++ issues and libgl.so issues | |
| LD_LIBRARY_PATH=lib.makeLibraryPath [ pkgs.stdenv.cc.cc ]; | |
| # Setup the virtual environment if it doesn't already exist. | |
| VENV=shell-build123d | |
| if test ! -d $VENV; then | |
| virtualenv $VENV | |
| fi | |
| source ./$VENV/bin/activate | |
| export PYTHONPATH=$PYTHONPATH:`pwd`/$VENV/${myPython.sitePackages}/ | |
| pip install --upgrade pip | |
| pip install build123d | |
| echo $GREETING | cowsay | lolcat | |
| ''; | |
| }; | |
| in | |
| shell |
| # test-build123d.py | |
| # Installation test | |
| # https://build123d.readthedocs.io/en/latest/installation.html#test-your-build123d-installation | |
| from build123d import * | |
| print(Solid.make_box(1,2,3).show_topology(limit_class="Face")) |
| # test-shell.sh | |
| # https://discourse.nixos.org/t/how-to-create-a-development-environment-for-build123d/45146/2?u=technicus | |
| nix-shell shell-build123d.nix --command "python ./test-build123d.py" |
This was solved by rgoulter in How to create a development environment for build123d.
I have since updated the gist and added two test scripts as recommended.
As of now the install is successful for me . . . it remains to be seen if I can do anything with it now.
I created a thread on the NixOS Discourse forum and it was solved by rgoulter with the reply How to create a development environment for build123d.
I also added two test test scripts as recommended.
The install test is working for me as of now.
It is yet to be seen if I can actually do any thing with it.
Hey, I made a flake to do this, except instead of installing shared libraries so the binary python packages work, I used poetry2nix to build NixOS-native packages in this repo:
https://github.com/eraserhd/gridfinity-ezcal
I might break it out to somewhere else.
Please do!
$ nix-locate --top-level libstdc++.so.6 | grep gcc