labscript-suite-oldfinal1 / installer

The installer for the labscript suite. This repository is used used to build zip files containing an install script and all the labscript suite python packages.
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Change sudo behaviour on unix #30

Open philipstarkey opened 5 years ago

philipstarkey commented 5 years ago

Original report (archived issue) by Chris Billington (Bitbucket: cbillington, GitHub: chrisjbillington).


So far, if you want to install the labscript suite with system Python on unix, you need to run the installer with sudo, so that it has permission to write the .pth file to the site-packages dir.

However, I just ran the installer with sudo, and it had the side effect of picking /root/labscript_suite as the default install directory. Other settings based on the home directory are presumably wrong too.

I'm not sure if this is distro-specific (don't remember it being a problem on Ubuntu), or whether sudo itself has changed, but in either case we should probably not be inspecting the $HOMEenvironment variable while running under sudo, in case it is wrong.

The fix, which is probably a good idea anyway, would be to create the .pth file as a temporary file, then run a 'sudo mv' command that will prompt for the user's password just for that command. Then the rest of the script won't be running as root, which is safer. The user also won't accidentally run the script without root only to find they have to run it again after getting a permissions error.

The code should probably try to run mv without sudo first, running it again with sudo only if it gets a permission error.