setup.py should not select install directory based on uid
Trying to solve #384, I realized that config file directory path was selected based on effective uid. This is done, on purpose, to work around an issue with pip. As the comment said, it also apply to rpmbuild. This is wrong.
RPM should be build without root permissions, for a lot of reason, this is really good practices when building RPMs. mock (Fedora, EPEL, ...) does this by example.
With this kind of trick, building RPMS ends with config file being put in /usr/etc/clustershell when run by user.
$ ./setup.py bdist_rpm
...
$ rpm -qlp dist/ClusterShell-1.8-1.noarch.rpm | grep conf
/usr/etc/clustershell/clush.conf
/usr/etc/clustershell/groups.conf
/usr/etc/clustershell/groups.conf.d/README
/usr/etc/clustershell/groups.conf.d/genders.conf.example
/usr/etc/clustershell/groups.conf.d/slurm.conf.example
/usr/etc/clustershell/topology.conf.example
I do not remember the original Pip issue. But this fix now impacts normal rpmbuild and pip with Windows (#384). We need to fix (#170) differently.
Yeah, good point, bdist_rpm is currently broken and never used to build clustershell RPMs (they are always built as user from the provided specfile). Would be great to fix this though... some of the reasons of the current state are:
- I wanted to install the config files in /etc when pip is run as root
- but we can't always install config files in /etc as this breaks pip install --user We probably need to make the CFGDIR selection based on a different criteria... perhaps pip install --user passes a flag somehow... perhaps it's mentioned in https://www.python.org/dev/peps/pep-0370/
Adding a different use case, but same result:
One may want to use EasyInstall (for --prefix= and --install-dir= purposes). It's not possible with the current setup.
python3 -m easy_install --prefix=$PREFIX --install-dir=$SITE ClusterShell
Searching for ClusterShell
Reading https://pypi.python.org/simple/ClusterShell/
Downloading https://files.pythonhosted.org/packages/7f/63/d8c86ebdfd64195e2de73447a8729e7735d7654db14c9da0c52cda6b3ebc/ClusterShell-1.8.1.tar.gz#sha256=e913efb4fe017eed9731d5ad8be397509e7f1966e6cb6441ee2bce074b16b310
Best match: ClusterShell 1.8.1
Processing ClusterShell-1.8.1.tar.gz
Writing /tmp/easy_install-9d870l8p/ClusterShell-1.8.1/setup.cfg
Running ClusterShell-1.8.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-9d870l8p/ClusterShell-1.8.1/egg-dist-tmp-yaprjmra
error: Setup script exited with error: SandboxViolation: mkdir('/etc/clustershell', 511) {}
The package setup script has attempted to modify files on your system
that are not within the EasyInstall build area, and has been aborted.
This package cannot be safely installed by EasyInstall, and may not
support alternate installation locations even if you run its setup
script by hand. Please inform the package's author and the EasyInstall
maintainers to find out if a fix or workaround is available.