Skip to content

Commit 66cbd98

Browse files
committed
Remove some deprecated code (#3948)
2 parents 718493c + 6ef81fe commit 66cbd98

20 files changed

+35
-286
lines changed

changelog.d/3948.breaking.1.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Removed verification for existing ``depends.txt`` file (deprecated since v0.5a4).

changelog.d/3948.breaking.2.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Remove autofixing of broken ``.egg-info`` directories containing the ``-``
2+
character in their base name (without suffix).
3+
They should no longer be produced by sufficiently new versions of ``setuptools``
4+
(warning introduced in 2005).

changelog.d/3948.breaking.3.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Remove deprecated APIs in ``easy_install``: ``get_script_args``,
2+
``get_script_header`` and ``get_writer``.
3+
The direct usage of ``easy_install`` has been deprecated since v58.3.0,
4+
and the warnings regarding these APIs predate that version.

changelog.d/3948.breaking.4.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Removed ``egg_info.get_pkg_info_revision`` (deprecated since 2015).

changelog.d/3948.breaking.5.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Removed ``setuptools.dist._get_unpatched`` (deprecated since 2016)

changelog.d/3948.breaking.6.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Removed support for SVN in ``setuptools.package_index`` (deprecated since 2018).

changelog.d/3948.breaking.7.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Removed support for invalid ``pyproject.toml`` files.
2+
During the implementation of PEP 621, it was identified that some users were
3+
producing invalid files. As a transitional measure, the validation was relaxed
4+
for a few use cases. The grace period, however, came to an end.

setup.cfg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ egg_info.writers =
161161
eager_resources.txt = setuptools.command.egg_info:overwrite_arg
162162
namespace_packages.txt = setuptools.command.egg_info:overwrite_arg
163163
top_level.txt = setuptools.command.egg_info:write_toplevel_names
164-
depends.txt = setuptools.command.egg_info:warn_depends_obsolete
165164
dependency_links.txt = setuptools.command.egg_info:overwrite_arg
166165

167166
[egg_info]

setuptools/command/develop.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from distutils.util import convert_path
22
from distutils import log
3-
from distutils.errors import DistutilsError, DistutilsOptionError
3+
from distutils.errors import DistutilsOptionError
44
import os
55
import glob
66
import io
@@ -45,10 +45,6 @@ def finalize_options(self):
4545
import pkg_resources
4646

4747
ei = self.get_finalized_command("egg_info")
48-
if ei.broken_egg_info:
49-
template = "Please rename %r to %r before using 'develop'"
50-
args = ei.egg_info, ei.broken_egg_info
51-
raise DistutilsError(template % args)
5248
self.args = [ei.egg_name]
5349

5450
easy_install.finalize_options(self)

setuptools/command/easy_install.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,24 +2115,6 @@ def importlib_load_entry_point(spec, group, name):
21152115

21162116
command_spec_class = CommandSpec
21172117

2118-
@classmethod
2119-
def get_script_args(cls, dist, executable=None, wininst=False):
2120-
# for backward compatibility
2121-
EasyInstallDeprecationWarning.emit("Use get_args", due_date=(2023, 6, 1))
2122-
# This is a direct API call, it should be safe to remove soon.
2123-
writer = (WindowsScriptWriter if wininst else ScriptWriter).best()
2124-
header = cls.get_script_header("", executable, wininst)
2125-
return writer.get_args(dist, header)
2126-
2127-
@classmethod
2128-
def get_script_header(cls, script_text, executable=None, wininst=False):
2129-
# for backward compatibility
2130-
EasyInstallDeprecationWarning.emit("Use get_header", due_date=(2023, 6, 1))
2131-
# This is a direct API call, it should be safe to remove soon.
2132-
if wininst:
2133-
executable = "python.exe"
2134-
return cls.get_header(script_text, executable)
2135-
21362118
@classmethod
21372119
def get_args(cls, dist, header=None):
21382120
"""
@@ -2160,13 +2142,6 @@ def _ensure_safe_name(name):
21602142
if has_path_sep:
21612143
raise ValueError("Path separators not allowed in script names")
21622144

2163-
@classmethod
2164-
def get_writer(cls, force_windows):
2165-
# for backward compatibility
2166-
EasyInstallDeprecationWarning.emit("Use best", due_date=(2023, 6, 1))
2167-
# This is a direct API call, it should be safe to remove soon.
2168-
return WindowsScriptWriter.best() if force_windows else cls.best()
2169-
21702145
@classmethod
21712146
def best(cls):
21722147
"""
@@ -2193,13 +2168,6 @@ def get_header(cls, script_text="", executable=None):
21932168
class WindowsScriptWriter(ScriptWriter):
21942169
command_spec_class = WindowsCommandSpec
21952170

2196-
@classmethod
2197-
def get_writer(cls):
2198-
# for backward compatibility
2199-
EasyInstallDeprecationWarning.emit("Use best", due_date=(2023, 6, 1))
2200-
# This is a direct API call, it should be safe to remove soon.
2201-
return cls.best()
2202-
22032171
@classmethod
22042172
def best(cls):
22052173
"""
@@ -2287,11 +2255,6 @@ def _get_script_args(cls, type_, name, header, script_text):
22872255
yield (m_name, load_launcher_manifest(name), 't')
22882256

22892257

2290-
# for backward-compatibility
2291-
get_script_args = ScriptWriter.get_script_args
2292-
get_script_header = ScriptWriter.get_script_header
2293-
2294-
22952258
def get_win_launcher(type):
22962259
"""
22972260
Load the Windows launcher (executable) suitable for launching a script.

setuptools/command/egg_info.py

Lines changed: 7 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ def initialize_options(self):
181181
self.egg_name = None
182182
self.egg_info = None
183183
self.egg_version = None
184-
self.broken_egg_info = False
185184
self.ignore_egg_info_in_manifest = False
186185

187186
####################################
@@ -236,8 +235,6 @@ def finalize_options(self):
236235
self.egg_info = _normalization.filename_component(self.egg_name) + '.egg-info'
237236
if self.egg_base != os.curdir:
238237
self.egg_info = os.path.join(self.egg_base, self.egg_info)
239-
if '-' in self.egg_name:
240-
self.check_broken_egg_info()
241238

242239
# Set package version for the benefit of dumber commands
243240
# (e.g. sdist, bdist_wininst, etc.)
@@ -325,25 +322,6 @@ def find_sources(self):
325322
mm.run()
326323
self.filelist = mm.filelist
327324

328-
def check_broken_egg_info(self):
329-
bei = self.egg_name + '.egg-info'
330-
if self.egg_base != os.curdir:
331-
bei = os.path.join(self.egg_base, bei)
332-
if os.path.exists(bei):
333-
EggInfoDeprecationWarning.emit(
334-
"Invalid egg-info directory name.",
335-
f"""
336-
Your current .egg-info directory has a '-' in its name;
337-
this will not work correctly with setuptools commands.
338-
339-
Please rename {bei!r} to {self.egg_info!r} to correct this problem.
340-
""",
341-
due_date=(2023, 6, 1),
342-
# Old warning, introduced in 2005, might be safe to remove soon
343-
)
344-
self.broken_egg_info = self.egg_info
345-
self.egg_info = bei # make it work for now
346-
347325

348326
class FileList(_FileList):
349327
# Implementations of the various MANIFEST.in commands
@@ -706,17 +684,13 @@ def write_pkg_info(cmd, basename, filename):
706684

707685

708686
def warn_depends_obsolete(cmd, basename, filename):
709-
if os.path.exists(filename):
710-
EggInfoDeprecationWarning.emit(
711-
"Deprecated config.",
712-
"""
713-
'depends.txt' is not used by setuptools >= 0.6!
714-
Configure your dependencies via `setup.cfg` or `pyproject.toml` instead.
715-
""",
716-
see_docs="userguide/declarative_config.html",
717-
due_date=(2023, 6, 1),
718-
# Old warning, introduced in 2005, it might be safe to remove soon.
719-
)
687+
"""
688+
Unused: left to avoid errors when updating (from source) from <= 67.8.
689+
Old installations have a .dist-info directory with the entry-point
690+
``depends.txt = setuptools.command.egg_info:warn_depends_obsolete``.
691+
This may trigger errors when running the first egg_info in build_meta.
692+
TODO: Remove this function in a version sufficiently > 68.
693+
"""
720694

721695

722696
def _write_requirements(stream, reqs):
@@ -773,26 +747,6 @@ def write_entries(cmd, basename, filename):
773747
cmd.write_or_delete_file('entry points', filename, defn, True)
774748

775749

776-
def get_pkg_info_revision():
777-
"""
778-
Get a -r### off of PKG-INFO Version in case this is an sdist of
779-
a subversion revision.
780-
"""
781-
EggInfoDeprecationWarning.emit(
782-
"Deprecated API call",
783-
"get_pkg_info_revision is deprecated.",
784-
due_date=(2023, 6, 1),
785-
# Warning introduced in 11 Dec 2015, should be safe to remove
786-
)
787-
if os.path.exists('PKG-INFO'):
788-
with io.open('PKG-INFO') as f:
789-
for line in f:
790-
match = re.match(r"Version:.*-r(\d+)\s*$", line)
791-
if match:
792-
return int(match.group(1))
793-
return 0
794-
795-
796750
def _egg_basename(egg_name, egg_version, py_version=None, platform=None):
797751
"""Compute filename of the output egg. Private API."""
798752
name = _normalization.filename_component(egg_name)

setuptools/config/pyprojecttoml.py

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ def read_configuration(
114114
# the default would be an improvement.
115115
# `ini2toml` backfills include_package_data=False when nothing is explicitly given,
116116
# therefore setting a default here is backwards compatible.
117-
orig_setuptools_table = setuptools_table.copy()
118117
if dist and getattr(dist, "include_package_data", None) is not None:
119118
setuptools_table.setdefault("include-package-data", dist.include_package_data)
120119
else:
@@ -123,20 +122,10 @@ def read_configuration(
123122
asdict["tool"] = tool_table
124123
tool_table["setuptools"] = setuptools_table
125124

126-
try:
125+
with _ignore_errors(ignore_option_errors):
127126
# Don't complain about unrelated errors (e.g. tools not using the "tool" table)
128127
subset = {"project": project_table, "tool": {"setuptools": setuptools_table}}
129128
validate(subset, filepath)
130-
except Exception as ex:
131-
# TODO: Remove the following once the feature stabilizes:
132-
if _skip_bad_config(project_table, orig_setuptools_table, dist):
133-
return {}
134-
# TODO: After the previous statement is removed the try/except can be replaced
135-
# by the _ignore_errors context manager.
136-
if ignore_option_errors:
137-
_logger.debug(f"ignored error: {ex.__class__.__name__} - {ex}")
138-
else:
139-
raise # re-raise exception
140129

141130
if expand:
142131
root_dir = os.path.dirname(filepath)
@@ -145,36 +134,6 @@ def read_configuration(
145134
return asdict
146135

147136

148-
def _skip_bad_config(
149-
project_cfg: dict, setuptools_cfg: dict, dist: Optional["Distribution"]
150-
) -> bool:
151-
"""Be temporarily forgiving with invalid ``pyproject.toml``"""
152-
# See pypa/setuptools#3199 and pypa/cibuildwheel#1064
153-
154-
if dist is None or (
155-
dist.metadata.name is None
156-
and dist.metadata.version is None
157-
and dist.install_requires is None
158-
):
159-
# It seems that the build is not getting any configuration from other places
160-
return False
161-
162-
if setuptools_cfg:
163-
# If `[tool.setuptools]` is set, then `pyproject.toml` config is intentional
164-
return False
165-
166-
given_config = set(project_cfg.keys())
167-
popular_subset = {"name", "version", "python_requires", "requires-python"}
168-
if given_config <= popular_subset:
169-
# It seems that the docs in cibuildtool has been inadvertently encouraging users
170-
# to create `pyproject.toml` files that are not compliant with the standards.
171-
# Let's be forgiving for the time being.
172-
_InvalidFile.emit()
173-
return True
174-
175-
return False
176-
177-
178137
def expand_configuration(
179138
config: dict,
180139
root_dir: Optional[_Path] = None,
@@ -476,21 +435,3 @@ def __exit__(self, exc_type, exc_value, traceback):
476435

477436
class _BetaConfiguration(SetuptoolsWarning):
478437
_SUMMARY = "Support for `[tool.setuptools]` in `pyproject.toml` is still *beta*."
479-
480-
481-
class _InvalidFile(SetuptoolsWarning):
482-
_SUMMARY = "The given `pyproject.toml` file is invalid and would be ignored."
483-
_DETAILS = """
484-
############################
485-
# Invalid `pyproject.toml` #
486-
############################
487-
488-
Any configurations in `pyproject.toml` will be ignored.
489-
Please note that future releases of setuptools will halt the build process
490-
if an invalid file is given.
491-
492-
To prevent setuptools from considering `pyproject.toml` please
493-
DO NOT include both `[project]` or `[tool.setuptools]` tables in your file.
494-
"""
495-
_DUE_DATE = (2023, 6, 1) # warning introduced in 2022-03-26
496-
_SEE_DOCS = "userguide/pyproject_config.html"

setuptools/dist.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,6 @@
5151
__import__('setuptools.extern.packaging.version')
5252

5353

54-
def _get_unpatched(cls):
55-
DistDeprecationWarning.emit(
56-
"Private function",
57-
"Do not call this function",
58-
due_date=(2023, 6, 1),
59-
# Warning initially introduced in 2016
60-
)
61-
return get_unpatched(cls)
62-
63-
6454
def get_metadata_version(self):
6555
mv = getattr(self, 'metadata_version', None)
6656
if mv is None:

setuptools/package_index.py

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
from fnmatch import translate
4040
from setuptools.wheel import Wheel
4141
from setuptools.extern.more_itertools import unique_everseen
42-
from setuptools.warnings import SetuptoolsDeprecationWarning
4342

4443

4544
EGG_FRAGMENT = re.compile(r'^egg=([-A-Za-z0-9_.+!]+)$')
@@ -849,50 +848,16 @@ def scan_url(self, url):
849848
def _attempt_download(self, url, filename):
850849
headers = self._download_to(url, filename)
851850
if 'html' in headers.get('content-type', '').lower():
852-
return self._download_html(url, headers, filename)
851+
return self._invalid_download_html(url, headers, filename)
853852
else:
854853
return filename
855854

856-
def _download_html(self, url, headers, filename):
857-
file = open(filename)
858-
for line in file:
859-
if line.strip():
860-
# Check for a subversion index page
861-
if re.search(r'<title>([^- ]+ - )?Revision \d+:', line):
862-
# it's a subversion index page:
863-
file.close()
864-
os.unlink(filename)
865-
return self._download_svn(url, filename)
866-
break # not an index page
867-
file.close()
855+
def _invalid_download_html(self, url, headers, filename):
868856
os.unlink(filename)
869-
raise DistutilsError("Unexpected HTML page found at " + url)
857+
raise DistutilsError(f"Unexpected HTML page found at {url}")
870858

871-
def _download_svn(self, url, filename):
872-
SetuptoolsDeprecationWarning.emit(
873-
"Invalid config",
874-
f"SVN download support is deprecated: {url}",
875-
due_date=(2023, 6, 1), # Initially introduced in 23 Sept 2018
876-
)
877-
url = url.split('#', 1)[0] # remove any fragment for svn's sake
878-
creds = ''
879-
if url.lower().startswith('svn:') and '@' in url:
880-
scheme, netloc, path, p, q, f = urllib.parse.urlparse(url)
881-
if not netloc and path.startswith('//') and '/' in path[2:]:
882-
netloc, path = path[2:].split('/', 1)
883-
auth, host = _splituser(netloc)
884-
if auth:
885-
if ':' in auth:
886-
user, pw = auth.split(':', 1)
887-
creds = " --username=%s --password=%s" % (user, pw)
888-
else:
889-
creds = " --username=" + auth
890-
netloc = host
891-
parts = scheme, netloc, url, p, q, f
892-
url = urllib.parse.urlunparse(parts)
893-
self.info("Doing subversion checkout from %s to %s", url, filename)
894-
os.system("svn checkout%s -q %s %s" % (creds, url, filename))
895-
return filename
859+
def _download_svn(self, url, _filename):
860+
raise DistutilsError(f"Invalid config, SVN download is not supported: {url}")
896861

897862
@staticmethod
898863
def _vcs_split_rev_from_url(url, pop_prefix=False):

0 commit comments

Comments
 (0)