Stop installing config files via data_files (drop /usr/etc) — when we drop Python 2 · Issue #636 · clustershell/clustershell · GitHub
Skip to content

Stop installing config files via data_files (drop /usr/etc) — when we drop Python 2 #636

Description

@thiell

Background

setup.py installs the config tree (clush.conf, groups.conf, the *.d/
dirs and *.example files) through setuptools data_files at the relative path
etc/clustershell/. In a wheel / PEP 517 install that path is placed relative
to the install location, so:

  • venv → <venv>/etc/clustershell/ ✅ (found via config_paths()'s
    sys.prefix/etc/clustershell entry)
  • pip install --user~/.local/etc/clustershell/
  • system /usr prefix → /usr/etc/clustershell/ ❌ (not /etc)

The last one is the awkward case: Python packaging has no notion of a system
/etc, and data_files ties everything to the install location. Today we work
around it with (a) the multi-path search in Defaults.config_paths() and (b) the
RPM spec moving /usr/etc%{_sysconfdir}. It works, but it surprises people.

(Man pages are not affected: share/man lands at /usr/share/man under a /usr
prefix, which is correct. This is specific to the etc/ config dir.)

Proposal (do this at the Python 2 drop)

Dropping py2 is the natural time — we move to a pyproject.toml build (started in
#606) and can stop using data_files for config. Let each install channel place
config itself instead of forcing it through the package:

  • Distro packages own /etc: the spec installs conf/* to
    %{_sysconfdir}/clustershell directly (the same way it already installs man
    pages and vim files), so the data_files route and the /usr/etc/etc
    move both go away.

  • pip/venv ships the library only (it already runs on built-in defaults).
    Two options for the example configs:

    • (a) keep them in the sdist conf/ for packagers and docs, and don't install
      them into the environment at all; or
    • (b) carry them as package_data inside the package, readable via
      importlib.resources, so pip/venv users can still find reference copies.

    Leaning (b); (a) is simpler.

Note: the pyproject.toml in #606 doesn't yet install config files or man pages,
so handling those is part of finishing that migration — this issue covers config.

Behavior change / things to watch

  • venv & pip users currently get example configs dropped at
    <prefix>/etc/clustershell; after this they won't. Document
    CLUSTERSHELL_CFGDIR and copying the examples in the migration notes.
  • config_paths()'s sys.prefix/etc/clustershell entry would no longer be
    filled by an install — keep it for backward compatibility, or remove it on
    purpose.
  • importlib.resources.files() needs Python 3.9+; if the minimum Python version
    is lower then, use the importlib_resources backport or the older API.

Acceptance criteria

  • once on pyproject.toml (From setup.py to pyproject #606), config files are no longer installed via data_files
  • example configs handled per chosen option (sdist-only or package_data)
  • Fedora + EL spec(s) install /etc/clustershell directly; /usr/etc/etc move removed
  • venv install no longer creates <prefix>/etc/clustershell; library still runs on defaults
  • docs note where config lives per install channel

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions