but then I couldn't run export /root/.cargo/etc. I read the following posts:
but haven't been able to find an answer on how to install rust with sudo in order to install cyptography with sudo pip. Please understand that cryptography must be installed with sudo and there is simply no way around it.
Sudo is a mess, since it doesn't change the HOME environment variable by default. Most likely all you ended up doing was messing up the permissions in your user directory.
You could install rust in full root shell, but I would suggest the better option is to build a package as a normal user and install that system wide. Best option is to build a package for your Linux distro package manger (whatever format that is). That is the proper way of doing this.
Besides, shouldn't all containers and so on be buildable by a recipe these days (part of that whole "cattle not pets" thing cloud people talk about)?
Well, if you installed it for root, it won’t exist for the normal user, too, I guess? (Unless perhaps if you install it for both… i.e. multiple installations) I heard your goal is to install a python package, not to use rust? If you want to use rust with the normal user, then you should install it for the normal user (without sudo).
For the record, looking at the docs I don’t think that the installation process / instructions for the cryptography package are really designed for not global, but local installation for a single user. (And honestly, for a raspberry pi, shouldn’t that be sufficient?) I’m not a python user myself; looking at online docs it seems like either the global or the local installation might be default, perhaps depending on your distribution, and switching is done via --user or --system flags.
Have you tried if (no sudo) the command pip install --user cryptography works for you? (After rust is installed, normally i.e. also without using sudo, for the current user.)