Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Apr 12, 2024
2 parents ed56ff4 + 5598256 commit 7da5919
Show file tree
Hide file tree
Showing 100 changed files with 1,445 additions and 1,258 deletions.
2 changes: 1 addition & 1 deletion docs/deprecated/distutils/apiref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ directories.

Files in *src* that begin with :file:`.nfs` are skipped (more information on
these files is available in answer D2 of the `NFS FAQ page
<http://nfs.sourceforge.net/#section_d>`_).
<https://nfs.sourceforge.net/#section_d>`_).

.. versionchanged:: 3.3.1
NFS files are ignored.
Expand Down
2 changes: 1 addition & 1 deletion docs/deprecated/distutils/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -335,4 +335,4 @@ loads its values::
.. % \section{Putting it all together}
.. _docutils: http://docutils.sourceforge.net
.. _docutils: https://docutils.sourceforge.io
2 changes: 1 addition & 1 deletion docs/deprecated/distutils/setupscript.rst
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ Notes:

'long string'
Multiple lines of plain text in reStructuredText format (see
http://docutils.sourceforge.net/).
https://docutils.sourceforge.io/).

'list of strings'
See below.
Expand Down
2 changes: 1 addition & 1 deletion setuptools/_distutils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
import importlib
import sys

__version__, _, _ = sys.version.partition(' ')

Expand Down
17 changes: 13 additions & 4 deletions setuptools/_distutils/_collections.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from __future__ import annotations

import collections
import functools
import itertools
import operator
from collections.abc import Mapping
from typing import Any


# from jaraco.collections 3.5.1
Expand Down Expand Up @@ -58,7 +62,7 @@ def __len__(self):
return len(list(iter(self)))


# from jaraco.collections 3.7
# from jaraco.collections 5.0.1
class RangeMap(dict):
"""
A dictionary-like object that uses the keys as bounds for a range.
Expand All @@ -70,7 +74,7 @@ class RangeMap(dict):
One may supply keyword parameters to be passed to the sort function used
to sort keys (i.e. key, reverse) as sort_params.
Let's create a map that maps 1-3 -> 'a', 4-6 -> 'b'
Create a map that maps 1-3 -> 'a', 4-6 -> 'b'
>>> r = RangeMap({3: 'a', 6: 'b'}) # boy, that was easy
>>> r[1], r[2], r[3], r[4], r[5], r[6]
Expand All @@ -82,7 +86,7 @@ class RangeMap(dict):
>>> r[4.5]
'b'
But you'll notice that the way rangemap is defined, it must be open-ended
Notice that the way rangemap is defined, it must be open-ended
on one side.
>>> r[0]
Expand Down Expand Up @@ -140,7 +144,12 @@ class RangeMap(dict):
"""

def __init__(self, source, sort_params={}, key_match_comparator=operator.le):
def __init__(
self,
source,
sort_params: Mapping[str, Any] = {},
key_match_comparator=operator.le,
):
dict.__init__(self, source)
self.sort_params = sort_params
self.match = key_match_comparator
Expand Down
52 changes: 52 additions & 0 deletions setuptools/_distutils/_itertools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# from more_itertools 10.2
def always_iterable(obj, base_type=(str, bytes)):
"""If *obj* is iterable, return an iterator over its items::
>>> obj = (1, 2, 3)
>>> list(always_iterable(obj))
[1, 2, 3]
If *obj* is not iterable, return a one-item iterable containing *obj*::
>>> obj = 1
>>> list(always_iterable(obj))
[1]
If *obj* is ``None``, return an empty iterable:
>>> obj = None
>>> list(always_iterable(None))
[]
By default, binary and text strings are not considered iterable::
>>> obj = 'foo'
>>> list(always_iterable(obj))
['foo']
If *base_type* is set, objects for which ``isinstance(obj, base_type)``
returns ``True`` won't be considered iterable.
>>> obj = {'a': 1}
>>> list(always_iterable(obj)) # Iterate over the dict's keys
['a']
>>> list(always_iterable(obj, base_type=dict)) # Treat dicts as a unit
[{'a': 1}]
Set *base_type* to ``None`` to avoid any special handling and treat objects
Python considers iterable as iterable:
>>> obj = 'foo'
>>> list(always_iterable(obj, base_type=None))
['f', 'o', 'o']
"""
if obj is None:
return iter(())

if (base_type is not None) and isinstance(obj, base_type):
return iter((obj,))

try:
return iter(obj)
except TypeError:
return iter((obj,))
1 change: 0 additions & 1 deletion setuptools/_distutils/_log.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import logging


log = logging.getLogger()
2 changes: 1 addition & 1 deletion setuptools/_distutils/_macos_compat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
import importlib
import sys


def bypass_compiler_fixup(cmd, args):
Expand Down
2 changes: 1 addition & 1 deletion setuptools/_distutils/_modified.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import functools
import os.path

from ._functools import splat
from .errors import DistutilsFileError
from .py39compat import zip_strict
from ._functools import splat


def _newer(source, target):
Expand Down
16 changes: 8 additions & 8 deletions setuptools/_distutils/_msvccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@
# ported to VS 2005 and VS 2008 by Christian Heimes
# ported to VS 2015 by Steve Dower

import contextlib
import os
import subprocess
import contextlib
import warnings
import unittest.mock as mock
import warnings

with contextlib.suppress(ImportError):
import winreg

from itertools import count

from ._log import log
from .ccompiler import CCompiler, gen_lib_options
from .errors import (
CompileError,
DistutilsExecError,
DistutilsPlatformError,
CompileError,
LibError,
LinkError,
)
from .ccompiler import CCompiler, gen_lib_options
from ._log import log
from .util import get_platform

from itertools import count


def _find_vc2015():
try:
Expand Down Expand Up @@ -253,7 +253,7 @@ def initialize(self, plat_name=None):
vc_env = _get_vc_env(plat_spec)
if not vc_env:
raise DistutilsPlatformError(
"Unable to find a compatible " "Visual Studio installation."
"Unable to find a compatible Visual Studio installation."
)
self._configure(vc_env)

Expand Down
6 changes: 3 additions & 3 deletions setuptools/_distutils/archive_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
that sort of thing)."""

import os
from warnings import warn
import sys
from warnings import warn

try:
import zipfile
except ImportError:
zipfile = None


from ._log import log
from .dir_util import mkpath
from .errors import DistutilsExecError
from .spawn import spawn
from .dir_util import mkpath
from ._log import log

try:
from pwd import getpwnam
Expand Down
16 changes: 6 additions & 10 deletions setuptools/_distutils/bcppcompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,20 @@
# someone should sit down and factor out the common code as
# WindowsCCompiler! --GPW


import os
import warnings

from ._log import log
from ._modified import newer
from .ccompiler import CCompiler, gen_preprocess_options
from .errors import (
DistutilsExecError,
CompileError,
DistutilsExecError,
LibError,
LinkError,
UnknownFileError,
)
from .ccompiler import CCompiler, gen_preprocess_options
from .file_util import write_file
from ._modified import newer
from ._log import log


warnings.warn(
"bcppcompiler is deprecated and slated to be removed "
Expand Down Expand Up @@ -239,7 +237,7 @@ def link( # noqa: C901
def_file = os.path.join(temp_dir, '%s.def' % modname)
contents = ['EXPORTS']
for sym in export_symbols or []:
contents.append(' {}=_{}'.format(sym, sym))
contents.append(f' {sym}=_{sym}')
self.execute(write_file, (def_file, contents), "writing %s" % def_file)

# Borland C++ has problems with '/' in paths
Expand Down Expand Up @@ -349,9 +347,7 @@ def object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
# use normcase to make sure '.rc' is really '.rc' and not '.RC'
(base, ext) = os.path.splitext(os.path.normcase(src_name))
if ext not in (self.src_extensions + ['.rc', '.res']):
raise UnknownFileError(
"unknown file type '{}' (from '{}')".format(ext, src_name)
)
raise UnknownFileError(f"unknown file type '{ext}' (from '{src_name}')")
if strip_dir:
base = os.path.basename(base)
if ext == '.res':
Expand Down

0 comments on commit 7da5919

Please sign in to comment.