Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Remove py38 compat modules #315

Merged
merged 4 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

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

if sys.version_info >= (3, 10):
from test.support.import_helper import (
CleanImport as CleanImport,
)
from test.support.import_helper import (
DirsOnSysPath as DirsOnSysPath,
)
from test.support.os_helper import (
EnvironmentVarGuard as EnvironmentVarGuard,
)
from test.support.os_helper import (
rmtree as rmtree,
)
from test.support.os_helper import (
skip_unless_symlink as skip_unless_symlink,
)
from test.support.os_helper import (
unlink as unlink,
)
else:
from test.support import (
CleanImport as CleanImport,
)
from test.support import (
DirsOnSysPath as DirsOnSysPath,
)
from test.support import (
EnvironmentVarGuard as EnvironmentVarGuard,
)
from test.support import (
rmtree as rmtree,
)
from test.support import (
skip_unless_symlink as skip_unless_symlink,
)
from test.support import (
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
1 change: 0 additions & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ extend-select = [
ignore = [
# TODO: Fix these new violations in Ruff 0.8.0
"UP031",
"UP036",

# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
"W191",
Expand Down
Loading