Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

setup.py should not select install directory based on uid #389

Closed
degremont opened this issue Jul 20, 2018 · 2 comments · Fixed by #510
Closed

setup.py should not select install directory based on uid #389

degremont opened this issue Jul 20, 2018 · 2 comments · Fixed by #510

Comments

@degremont
Copy link
Collaborator

degremont commented Jul 20, 2018

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.

@thiell
Copy link
Collaborator

thiell commented Jul 20, 2018

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/

@ltaulell
Copy link

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.

@thiell thiell added this to the 1.9 milestone Dec 7, 2019
@thiell thiell modified the milestones: 1.9, 1.10 Nov 23, 2022
thiell added a commit to thiell/clustershell that referenced this issue Dec 7, 2022
- remove root exception handling
- include man pages as data_files
- check for config files in sys.prefix/etc/clustershell
- if $CLUSTERSHELL_CFGDIR is defined, always try it first

This allows clustershell to be installed as user in a venv using pip
install or using pip install --user with man pages.

Root installation using pip is now discouraged. If done, /usr/local is
likely to be used as the install prefix.

Fixes cea-hpc#389.
thiell added a commit that referenced this issue Dec 7, 2022
- remove root exception handling
- include man pages as data_files
- check for config files in sys.prefix/etc/clustershell
- if $CLUSTERSHELL_CFGDIR is defined, always try it first

This allows clustershell to be installed as user in a venv using pip
install or using pip install --user with man pages.

Root installation using pip is now discouraged. If done, /usr/local is
likely to be used as the install prefix.

Fixes #389.
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants