Skip to content

python: replace deprecated 'setup.py install' with PEP 517 wheel install#493

Open
rawrmonster17 wants to merge 1 commit into
seccomp:mainfrom
rawrmonster17:python-fix-deprecated-setup-install
Open

python: replace deprecated 'setup.py install' with PEP 517 wheel install#493
rawrmonster17 wants to merge 1 commit into
seccomp:mainfrom
rawrmonster17:python-fix-deprecated-setup-install

Conversation

@rawrmonster17

Copy link
Copy Markdown

Problem

Running make install with --enable-python prints a deprecation warning on
every invocation:

SetuptoolsDeprecationWarning: setup.py install is deprecated.
Please avoid running ``setup.py`` directly.
Instead, use pypa/build, pypa/installer or other standards-based tools.

The root cause is src/python/Makefile.am invoking setup.py install in
install-exec-local via PY_INSTALL = ${PY_DISTUTILS} install. This was
not fixed by the earlier distutils→setuptools migration (PR #374) which
addressed the import deprecation but not the command deprecation.

Fixes: Github Issue #444

Fix

Replace the install-exec-local target with a two-step PEP 517 workflow:

  1. Build a wheel using python -m build --wheel --no-isolation.
    The --no-isolation flag reuses the in-tree build environment (same
    compiler flags, same libseccomp.a) rather than creating an isolated venv.
    This does not invoke the deprecated setup.py install command path.

  2. Install the wheel using python -m installer --destdir --prefix.
    pypa/installer is a minimal, standards-based wheel installer that writes
    the dist-info/RECORD used by pip uninstall for clean removal.

The uninstall-local target is updated to use pip uninstall --yes seccomp,
which reads the dist-info/RECORD written by installer — the modern replacement
for the old install_files.txt record mechanism.

The build / PY_BUILD target (used by make check-build and make check)
is unchanged — it still calls setup.py build which is not deprecated.

.github/actions/setup/action.yml is updated to install the additional
Python build-time dependencies (wheel, build, installer) alongside the
existing cython.

Testing

  • make install DESTDIR=/tmp/test prefix=/usr: zero deprecation warnings,
    seccomp.cpython-*.so and seccomp-*.dist-info correctly installed under
    ${DESTDIR}/usr/lib/python*/site-packages/.
  • make check-build, make check: both pass; the build target is
    unaffected by this change.
  • bash src/arch-syscall-check: PASS.

Running 'setup.py install' directly is deprecated by setuptools and
triggers a SetuptoolsDeprecationWarning on every 'make install'.  The
warning text recommends using standards-based build tools instead.

Replace the install path in src/python/Makefile.am:

  Before:
    PY_INSTALL = ${PY_DISTUTILS} install
    install-exec-local runs ${PY_INSTALL} --install-lib=... --record=...

  After:
    Build the wheel with 'python -m build --wheel --no-isolation' (PEP 517,
    does not invoke the deprecated install command), then install it with
    'python -m installer --destdir=... --prefix=...' (PEP 427 / pypa/installer).

The 'make check' / 'make check-build' paths are unaffected: they use the
PY_BUILD target (setup.py build) which is not deprecated.

The uninstall-local target switches from a manual install_files.txt record to
'pip uninstall --yes seccomp', which uses the dist-info/RECORD written by
installer and is the recommended uninstall mechanism for wheel-installed
packages.

Update .github/actions/setup/action.yml to install the additional
build-time Python dependencies (wheel, build, installer) that the new
install path requires alongside the existing cython dependency.

Fixes: Github Issue seccomp#444
Signed-off-by: rawrmonster17 <rawrmonster17@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant