Skip to content
Closed
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
13 changes: 5 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ jobs:
# https://blog.jaraco.com/efficient-use-of-ci-resources/
matrix:
python:
- "3.9"
- ">=3.13.5" # temporary bound until it becomes the default, python/cpython#135151
- "3.10"
- "3.14"
platform:
- ubuntu-latest
- macos-latest
Expand All @@ -54,7 +54,7 @@ jobs:
platform: ubuntu-latest
- python: "3.12"
platform: ubuntu-latest
- python: "3.14"
- python: "3.13"
platform: ubuntu-latest
- python: pypy3.10
platform: ubuntu-latest
Expand All @@ -63,7 +63,7 @@ jobs:
python: "3.10"
distutils: stdlib
runs-on: ${{ matrix.platform }}
continue-on-error: ${{ matrix.python == '3.14' || matrix.python == 'pypy3.10' }}
continue-on-error: ${{ matrix.python == '3.15' || matrix.python == 'pypy3.10' }}
# XXX: pypy seems to be flaky with unrelated tests in #6345
env:
SETUPTOOLS_USE_DISTUTILS: ${{ matrix.distutils || 'local' }}
Expand All @@ -73,7 +73,7 @@ jobs:
- name: Install build dependencies
# Install dependencies for building packages on pre-release Pythons
# jaraco/skeleton#161
if: matrix.python == '3.14' && matrix.platform == 'ubuntu-latest'
if: matrix.python == '3.15' && matrix.platform == 'ubuntu-latest'
run: |
sudo apt update
sudo apt install -y libxml2-dev libxslt-dev
Expand All @@ -83,9 +83,6 @@ jobs:
with:
python-version: ${{ matrix.python }}
allow-prereleases: true
env:
# Workaround for actions/setup-python#981 (env var only modified for this specific step)
SETUPTOOLS_USE_DISTUTILS: ${{ matrix.platform == 'macos-latest' && matrix.python == '3.9' && 'stdlib' || matrix.distutils || 'local' }}
- uses: actions/cache@v4
id: cache
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pyright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ jobs:
# https://blog.jaraco.com/efficient-use-of-ci-resources/
matrix:
python:
- "3.9"
- "3.13"
- "3.10"
- "3.14"
platform:
- ubuntu-latest
runs-on: ${{ matrix.platform }}
Expand Down
14 changes: 3 additions & 11 deletions _distutils_hack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@

# check that submodules load as expected
core = importlib.import_module('distutils.core')
assert '_distutils' in core.__file__, core.__file__

Check warning on line 76 in _distutils_hack/__init__.py

View workflow job for this annotation

GitHub Actions / pyright (3.10, ubuntu-latest)

Operator "in" not supported for types "Literal['_distutils']" and "str | None"   Operator "in" not supported for types "Literal['_distutils']" and "None" (reportOperatorIssue)
assert 'setuptools._distutils.log' not in sys.modules


Expand Down Expand Up @@ -187,17 +187,9 @@
clear_distutils()
self.spec_for_distutils = lambda: None

sensitive_tests = (
[
'test.test_distutils',
'test.test_peg_generator',
'test.test_importlib',
]
if sys.version_info < (3, 10)
else [
'test.test_distutils',
]
)
sensitive_tests = [
'test.test_distutils',
]


for name in DistutilsMetaFinder.sensitive_tests:
Expand All @@ -212,7 +204,7 @@


def add_shim():
DISTUTILS_FINDER in sys.meta_path or insert_shim()

Check warning on line 207 in _distutils_hack/__init__.py

View workflow job for this annotation

GitHub Actions / pyright (3.10, ubuntu-latest)

Expression value is unused (reportUnusedExpression)


class shim:
Expand Down
2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def pytest_configure(config):
]


if sys.version_info < (3, 9) or sys.platform == 'cygwin':
if sys.platform == 'cygwin':
collect_ignore.append('tools/finalize.py')


Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ disable_error_code =

# CI should test for all versions, local development gets hints for oldest supported
# But our testing setup doesn't allow passing CLI arguments, so local devs have to set this manually.
# python_version = 3.9
# python_version = 3.10

exclude = (?x)(
# Avoid scanning Python files in generated folders
Expand Down
10 changes: 2 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ classifiers = [
"Topic :: System :: Systems Administration",
"Topic :: Utilities",
]
requires-python = ">=3.9"
requires-python = ">=3.10"
license = "MIT"
dependencies = [
]
Expand Down Expand Up @@ -56,16 +56,13 @@ test = [
"tomli-w>=1.0.0",
"pytest-timeout",
'pytest-perf; sys_platform != "cygwin"', # workaround for jaraco/inflect#195, pydantic/pydantic-core#773 (see #3986)
'pyobjc<12; sys_platform == "darwin" and python_version <= "3.9"', # workaround for #5105
# for tools/finalize.py
'jaraco.develop >= 7.21; python_version >= "3.9" and sys_platform != "cygwin"',
'jaraco.develop >= 7.21; sys_platform != "cygwin"',
"pytest-home >= 0.5",
"pytest-subprocess",

# workaround for pypa/pyproject-hooks#206
"pyproject-hooks!=1.1",

"jaraco.test>=5.5", # py.typed
]

doc = [
Expand Down Expand Up @@ -99,7 +96,6 @@ core = [
"packaging>=24.2",
"more_itertools>=8.8",
"jaraco.text>=3.7",
"importlib_metadata>=6; python_version < '3.10'",
"tomli>=2.0.1; python_version < '3.11'",
"wheel>=0.43.0",

Expand Down Expand Up @@ -140,8 +136,6 @@ type = [
# until types-setuptools is removed from typeshed.
# For help with static-typing issues, or mypy update, ping @Avasam
"mypy==1.14.*",
# Typing fixes in version newer than we require at runtime
"importlib_metadata>=7.0.2; python_version < '3.10'",
# Imported unconditionally in tools/finalize.py
'jaraco.develop >= 7.21; sys_platform != "cygwin"',
]
Expand Down
2 changes: 1 addition & 1 deletion pyrightconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"setuptools/_distutils",
],
// Our testing setup doesn't allow passing CLI arguments, so local devs have to set this manually.
// "pythonVersion": "3.9",
// "pythonVersion": "3.10",
// For now we don't mind if mypy's `type: ignore` comments accidentally suppresses pyright issues
"enableTypeIgnoreComments": true,
"typeCheckingMode": "basic",
Expand Down
14 changes: 5 additions & 9 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,27 @@ filterwarnings=
# Fail on warnings
error

# Workarounds for pypa/setuptools#3810
# Can't use EncodingWarning as it doesn't exist on Python 3.9.
# These warnings only appear on Python 3.10+

## upstream

# Ensure ResourceWarnings are emitted
default::ResourceWarning

# python/mypy#17057
ignore:'encoding' argument not specified::mypy
ignore:'encoding' argument not specified::configparser
ignore::EncodingWarning:mypy
ignore::EncodingWarning:configparser
# ^-- ConfigParser is called by mypy,
# but ignoring the warning in `mypy` is not enough
# to make it work on PyPy

# realpython/pytest-mypy#152
ignore:'encoding' argument not specified::pytest_mypy
ignore::EncodingWarning:pytest_mypy

# TODO: Set encoding when opening/writing tmpdir files with pytest's LocalPath.open
# see pypa/setuptools#4326
ignore:'encoding' argument not specified::_pytest
ignore::EncodingWarning:_pytest

# Already fixed in pypa/distutils, but present in stdlib
ignore:'encoding' argument not specified::distutils
ignore::EncodingWarning:distutils

## end upstream

Expand Down
3 changes: 2 additions & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ ignore = [
[lint.per-file-ignores]
# Suppress nuisance warnings about module-import-not-at-top-of-file (E402) due to workaround for #4476
"setuptools/__init__.py" = ["E402"]
"pkg_resources/__init__.py" = ["E402", "ANN204"]
# pkg_resources is about to be removed, avoid changes
"pkg_resources/__init__.py" = ["E402", "ANN204", "UP007", "UP035"]
"pkg_resources/tests/test_resources.py" = ["PT031"]

[lint.isort]
Expand Down
2 changes: 1 addition & 1 deletion setuptools/_entry_points.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import functools
import itertools
import operator
from importlib import metadata

from jaraco.functools import pass_none
from jaraco.text import yield_lines
from more_itertools import consume

from ._importlib import metadata
from ._itertools import ensure_unique
from .errors import OptionError

Expand Down
13 changes: 4 additions & 9 deletions setuptools/_importlib.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import sys

if sys.version_info < (3, 10):
import importlib_metadata as metadata # pragma: no cover
else:
import importlib.metadata as metadata # noqa: F401


import importlib.resources as resources # noqa: F401
from importlib import (
metadata, # noqa: F401
resources, # noqa: F401
)
9 changes: 3 additions & 6 deletions setuptools/_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
import contextlib
import os
import sys
from typing import TYPE_CHECKING, TypeVar, Union
from typing import TypeAlias, TypeVar

from more_itertools import unique_everseen

if TYPE_CHECKING:
from typing_extensions import TypeAlias

StrPath: TypeAlias = Union[str, os.PathLike[str]] # Same as _typeshed.StrPath
StrPathT = TypeVar("StrPathT", bound=Union[str, os.PathLike[str]])
StrPath: TypeAlias = str | os.PathLike[str] # Same as _typeshed.StrPath
StrPathT = TypeVar("StrPathT", bound=str | os.PathLike[str])


def ensure_directory(path):
Expand Down
10 changes: 3 additions & 7 deletions setuptools/_reqs.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
from __future__ import annotations

from collections.abc import Iterable, Iterator
from collections.abc import Callable, Iterable, Iterator
from functools import lru_cache
from typing import TYPE_CHECKING, Callable, TypeVar, Union, overload
from typing import TypeAlias, TypeVar, overload

import jaraco.text as text
from packaging.requirements import Requirement

if TYPE_CHECKING:
from typing_extensions import TypeAlias

_T = TypeVar("_T")
_StrOrIter: TypeAlias = Union[str, Iterable[str]]

_StrOrIter: TypeAlias = str | Iterable[str]

parse_req: Callable[[str], Requirement] = lru_cache()(Requirement)
# Setuptools parses the same requirement many times
Expand Down
23 changes: 7 additions & 16 deletions setuptools/_scripts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import importlib.resources as resources
import os
import re
import shlex
Expand All @@ -9,18 +10,17 @@
import sys
import textwrap
from collections.abc import Iterable
from importlib import metadata
from typing import TYPE_CHECKING, TypedDict

from ._importlib import metadata, resources

if TYPE_CHECKING:
from typing_extensions import Self

from .warnings import SetuptoolsWarning

from distutils.command.build_scripts import first_line_re
from distutils.util import get_platform

if TYPE_CHECKING:
from typing_extensions import Self


class _SplitArgs(TypedDict, total=False):
comments: bool
Expand Down Expand Up @@ -131,16 +131,10 @@ class ScriptWriter:
# for compatibility with easy_install; see #2198
__requires__ = %(spec)r

try:
from importlib.metadata import distribution
except ImportError:
try:
from importlib_metadata import distribution
except ImportError:
from pkg_resources import load_entry_point
from importlib.metadata import distribution


def importlib_load_entry_point(spec, group, name):
def load_entry_point(spec, group, name):
dist_name, _, _ = spec.partition('==')
matches = (
entry_point
Expand All @@ -150,9 +144,6 @@ def importlib_load_entry_point(spec, group, name):
return next(matches).load()


globals().setdefault('load_entry_point', importlib_load_entry_point)


if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(load_entry_point(%(spec)r, %(group)r, %(name)r)())
Expand Down
3 changes: 2 additions & 1 deletion setuptools/_shutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import os
import stat
from typing import Callable, TypeVar
from collections.abc import Callable
from typing import TypeVar

from .compat import py311

Expand Down
7 changes: 2 additions & 5 deletions setuptools/build_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import warnings
from collections.abc import Iterable, Iterator, Mapping
from pathlib import Path
from typing import TYPE_CHECKING, NoReturn, Union
from typing import NoReturn, TypeAlias

import setuptools

Expand All @@ -51,9 +51,6 @@
import distutils
from distutils.util import strtobool

if TYPE_CHECKING:
from typing_extensions import TypeAlias

__all__ = [
'get_requires_for_build_sdist',
'get_requires_for_build_wheel',
Expand Down Expand Up @@ -144,7 +141,7 @@ def suppress_known_deprecation():
yield


_ConfigSettings: TypeAlias = Union[Mapping[str, Union[str, list[str], None]], None]
_ConfigSettings: TypeAlias = Mapping[str, str | list[str] | None] | None
"""
Currently the user can run::

Expand Down
3 changes: 1 addition & 2 deletions setuptools/command/bdist_egg.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from collections.abc import Iterator
from sysconfig import get_path, get_platform, get_python_version
from types import CodeType
from typing import TYPE_CHECKING, AnyStr, Literal
from typing import TYPE_CHECKING, AnyStr, Literal, TypeAlias

from setuptools import Command
from setuptools.extension import Library
Expand All @@ -24,7 +24,6 @@

if TYPE_CHECKING:
from _typeshed import GenericPath
from typing_extensions import TypeAlias

# Same as zipfile._ZipFileMode from typeshed
_ZipFileMode: TypeAlias = Literal["r", "w", "x", "a"]
Expand Down
2 changes: 1 addition & 1 deletion setuptools/command/egg_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import sys
import time
from collections.abc import Callable
from importlib import metadata

import packaging
import packaging.requirements
Expand All @@ -23,7 +24,6 @@
from setuptools.glob import glob

from .. import _entry_points, _normalization
from .._importlib import metadata
from ..warnings import SetuptoolsDeprecationWarning
from . import _requirestxt

Expand Down
Loading
Loading