Skip to content

Commit

Permalink
Remove py38 compat modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Dec 27, 2024
1 parent a9f832b commit ac54856
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 111 deletions.
2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _save_cwd():

@pytest.fixture
def distutils_managed_tempdir(request):
from distutils.tests.compat import py38 as os_helper
from distutils.tests.compat import py39 as os_helper

self = request.instance
self.tempdirs = []
Expand Down
4 changes: 1 addition & 3 deletions distutils/compat/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import annotations

from .py38 import removeprefix


def consolidate_linker_args(args: list[str]) -> list[str] | str:
"""
Expand All @@ -12,4 +10,4 @@ def consolidate_linker_args(args: list[str]) -> list[str] | str:

if not all(arg.startswith('-Wl,') for arg in args):
return args
return '-Wl,' + ','.join(removeprefix(arg, '-Wl,') for arg in args)
return '-Wl,' + ','.join(arg.removeprefix('-Wl,') for arg in args)
34 changes: 0 additions & 34 deletions distutils/compat/py38.py

This file was deleted.

50 changes: 0 additions & 50 deletions distutils/tests/compat/py38.py

This file was deleted.

22 changes: 22 additions & 0 deletions distutils/tests/compat/py39.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import sys

if sys.version_info >= (3, 10):
from test.support.import_helper import (
CleanImport as CleanImport,
DirsOnSysPath as DirsOnSysPath,
)
from test.support.os_helper import (
EnvironmentVarGuard as EnvironmentVarGuard,
rmtree as rmtree,
skip_unless_symlink as skip_unless_symlink,
unlink as unlink,
)
else:
from test.support import (
CleanImport as CleanImport,
DirsOnSysPath as DirsOnSysPath,
EnvironmentVarGuard as EnvironmentVarGuard,
rmtree as rmtree,
skip_unless_symlink as skip_unless_symlink,
unlink as unlink,
)
3 changes: 1 addition & 2 deletions distutils/tests/test_bdist_rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
from distutils.tests import support

import pytest

from .compat.py38 import requires_zlib
from test.support import requires_zlib

SETUP_PY = """\
from distutils.core import setup
Expand Down
8 changes: 2 additions & 6 deletions distutils/tests/test_build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,15 @@
)
from distutils.extension import Extension
from distutils.tests import missing_compiler_executable
from distutils.tests.support import (
TempdirManager,
copy_xxmodule_c,
fixup_build_ext,
)
from distutils.tests.support import TempdirManager, copy_xxmodule_c, fixup_build_ext
from io import StringIO

import jaraco.path
import path
import pytest
from test import support

from .compat import py38 as import_helper
from .compat import py39 as import_helper


@pytest.fixture()
Expand Down
3 changes: 1 addition & 2 deletions distutils/tests/test_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
from distutils.extension import Extension, read_setup_file

import pytest

from .compat.py38 import check_warnings
from test.support.warnings_helper import check_warnings


class TestExtension:
Expand Down
2 changes: 1 addition & 1 deletion distutils/tests/test_filelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import jaraco.path
import pytest

from .compat import py38 as os_helper
from .compat import py39 as os_helper

MANIFEST_IN = """\
include ok
Expand Down
2 changes: 1 addition & 1 deletion distutils/tests/test_spawn.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import pytest
from test.support import unix_shell

from .compat import py38 as os_helper
from .compat import py39 as os_helper


class TestSpawn(support.TempdirManager):
Expand Down
2 changes: 1 addition & 1 deletion distutils/tests/test_unixccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import pytest

from . import support
from .compat.py38 import EnvironmentVarGuard
from .compat.py39 import EnvironmentVarGuard


@pytest.fixture(autouse=True)
Expand Down
12 changes: 2 additions & 10 deletions distutils/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from .spawn import spawn


def get_host_platform():
def get_host_platform() -> str:
"""
Return a string that identifies the current platform. Use this
function to distinguish platform-specific build directories and
Expand All @@ -34,15 +34,7 @@ def get_host_platform():

# This function initially exposed platforms as defined in Python 3.9
# even with older Python versions when distutils was split out.
# Now it delegates to stdlib sysconfig, but maintains compatibility.

if sys.version_info < (3, 9):
if os.name == "posix" and hasattr(os, 'uname'):
osname, host, release, version, machine = os.uname()
if osname[:3] == "aix":
from .compat.py38 import aix_platform

return aix_platform(osname, version, release)
# Now it delegates to stdlib sysconfig.

return sysconfig.get_platform()

Expand Down
4 changes: 4 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ ignore = [
"TRY400",
]

[lint.isort]
combine-as-imports = true
split-on-trailing-comma = false

[format]
# Enable preview to get hugged parenthesis unwrapping and other nice surprises
# See https://github.com/jaraco/skeleton/pull/133#issuecomment-2239538373
Expand Down

0 comments on commit ac54856

Please sign in to comment.