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 some deprecated code #3948

Merged
merged 10 commits into from Jun 19, 2023
1 change: 1 addition & 0 deletions changelog.d/3948.breaking.1.rst
@@ -0,0 +1 @@
Removed verification for existing ``depends.txt`` file (deprecated since v0.5a4).
4 changes: 4 additions & 0 deletions changelog.d/3948.breaking.2.rst
@@ -0,0 +1,4 @@
Remove autofixing of broken ``.egg-info`` directories containing the ``-``
character in their base name (without suffix).
They should no longer be produced by sufficiently new versions of ``setuptools``
(warning introduced in 2005).
4 changes: 4 additions & 0 deletions changelog.d/3948.breaking.3.rst
@@ -0,0 +1,4 @@
Remove deprecated APIs in ``easy_install``: ``get_script_args``,
``get_script_header`` and ``get_writer``.
The direct usage of ``easy_install`` has been deprecated since v58.3.0,
and the warnings regarding these APIs predate that version.
1 change: 1 addition & 0 deletions changelog.d/3948.breaking.4.rst
@@ -0,0 +1 @@
Removed ``egg_info.get_pkg_info_revision`` (deprecated since 2015).
1 change: 1 addition & 0 deletions changelog.d/3948.breaking.5.rst
@@ -0,0 +1 @@
Removed ``setuptools.dist._get_unpatched`` (deprecated since 2016)
1 change: 1 addition & 0 deletions changelog.d/3948.breaking.6.rst
@@ -0,0 +1 @@
Removed support for SVN in ``setuptools.package_index`` (deprecated since 2018).
4 changes: 4 additions & 0 deletions changelog.d/3948.breaking.7.rst
@@ -0,0 +1,4 @@
Removed support for invalid ``pyproject.toml`` files.
During the implementation of PEP 621, it was identified that some users were
producing invalid files. As a transitional measure, the validation was relaxed
for a few use cases. The grace period, however, came to an end.
1 change: 0 additions & 1 deletion setup.cfg
Expand Up @@ -161,7 +161,6 @@ egg_info.writers =
eager_resources.txt = setuptools.command.egg_info:overwrite_arg
namespace_packages.txt = setuptools.command.egg_info:overwrite_arg
top_level.txt = setuptools.command.egg_info:write_toplevel_names
depends.txt = setuptools.command.egg_info:warn_depends_obsolete
dependency_links.txt = setuptools.command.egg_info:overwrite_arg

[egg_info]
Expand Down
6 changes: 1 addition & 5 deletions setuptools/command/develop.py
@@ -1,6 +1,6 @@
from distutils.util import convert_path
from distutils import log
from distutils.errors import DistutilsError, DistutilsOptionError
from distutils.errors import DistutilsOptionError
import os
import glob
import io
Expand Down Expand Up @@ -45,10 +45,6 @@ def finalize_options(self):
import pkg_resources

ei = self.get_finalized_command("egg_info")
if ei.broken_egg_info:
template = "Please rename %r to %r before using 'develop'"
args = ei.egg_info, ei.broken_egg_info
raise DistutilsError(template % args)
self.args = [ei.egg_name]

easy_install.finalize_options(self)
Expand Down
37 changes: 0 additions & 37 deletions setuptools/command/easy_install.py
Expand Up @@ -2115,24 +2115,6 @@ def importlib_load_entry_point(spec, group, name):

command_spec_class = CommandSpec

@classmethod
def get_script_args(cls, dist, executable=None, wininst=False):
# for backward compatibility
EasyInstallDeprecationWarning.emit("Use get_args", due_date=(2023, 6, 1))
# This is a direct API call, it should be safe to remove soon.
writer = (WindowsScriptWriter if wininst else ScriptWriter).best()
header = cls.get_script_header("", executable, wininst)
return writer.get_args(dist, header)

@classmethod
def get_script_header(cls, script_text, executable=None, wininst=False):
# for backward compatibility
EasyInstallDeprecationWarning.emit("Use get_header", due_date=(2023, 6, 1))
# This is a direct API call, it should be safe to remove soon.
if wininst:
executable = "python.exe"
return cls.get_header(script_text, executable)

@classmethod
def get_args(cls, dist, header=None):
"""
Expand Down Expand Up @@ -2160,13 +2142,6 @@ def _ensure_safe_name(name):
if has_path_sep:
raise ValueError("Path separators not allowed in script names")

@classmethod
def get_writer(cls, force_windows):
# for backward compatibility
EasyInstallDeprecationWarning.emit("Use best", due_date=(2023, 6, 1))
# This is a direct API call, it should be safe to remove soon.
return WindowsScriptWriter.best() if force_windows else cls.best()

@classmethod
def best(cls):
"""
Expand All @@ -2193,13 +2168,6 @@ def get_header(cls, script_text="", executable=None):
class WindowsScriptWriter(ScriptWriter):
command_spec_class = WindowsCommandSpec

@classmethod
def get_writer(cls):
# for backward compatibility
EasyInstallDeprecationWarning.emit("Use best", due_date=(2023, 6, 1))
# This is a direct API call, it should be safe to remove soon.
return cls.best()

@classmethod
def best(cls):
"""
Expand Down Expand Up @@ -2287,11 +2255,6 @@ def _get_script_args(cls, type_, name, header, script_text):
yield (m_name, load_launcher_manifest(name), 't')


# for backward-compatibility
get_script_args = ScriptWriter.get_script_args
get_script_header = ScriptWriter.get_script_header


def get_win_launcher(type):
"""
Load the Windows launcher (executable) suitable for launching a script.
Expand Down
60 changes: 7 additions & 53 deletions setuptools/command/egg_info.py
Expand Up @@ -181,7 +181,6 @@ def initialize_options(self):
self.egg_name = None
self.egg_info = None
self.egg_version = None
self.broken_egg_info = False
self.ignore_egg_info_in_manifest = False

####################################
Expand Down Expand Up @@ -236,8 +235,6 @@ def finalize_options(self):
self.egg_info = _normalization.filename_component(self.egg_name) + '.egg-info'
if self.egg_base != os.curdir:
self.egg_info = os.path.join(self.egg_base, self.egg_info)
if '-' in self.egg_name:
self.check_broken_egg_info()

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

def check_broken_egg_info(self):
bei = self.egg_name + '.egg-info'
if self.egg_base != os.curdir:
bei = os.path.join(self.egg_base, bei)
if os.path.exists(bei):
EggInfoDeprecationWarning.emit(
"Invalid egg-info directory name.",
f"""
Your current .egg-info directory has a '-' in its name;
this will not work correctly with setuptools commands.

Please rename {bei!r} to {self.egg_info!r} to correct this problem.
""",
due_date=(2023, 6, 1),
# Old warning, introduced in 2005, might be safe to remove soon
)
self.broken_egg_info = self.egg_info
self.egg_info = bei # make it work for now


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


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


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


def get_pkg_info_revision():
"""
Get a -r### off of PKG-INFO Version in case this is an sdist of
a subversion revision.
"""
EggInfoDeprecationWarning.emit(
"Deprecated API call",
"get_pkg_info_revision is deprecated.",
due_date=(2023, 6, 1),
# Warning introduced in 11 Dec 2015, should be safe to remove
)
if os.path.exists('PKG-INFO'):
with io.open('PKG-INFO') as f:
for line in f:
match = re.match(r"Version:.*-r(\d+)\s*$", line)
if match:
return int(match.group(1))
return 0


def _egg_basename(egg_name, egg_version, py_version=None, platform=None):
"""Compute filename of the output egg. Private API."""
name = _normalization.filename_component(egg_name)
Expand Down
61 changes: 1 addition & 60 deletions setuptools/config/pyprojecttoml.py
Expand Up @@ -114,7 +114,6 @@ def read_configuration(
# the default would be an improvement.
# `ini2toml` backfills include_package_data=False when nothing is explicitly given,
# therefore setting a default here is backwards compatible.
orig_setuptools_table = setuptools_table.copy()
if dist and getattr(dist, "include_package_data", None) is not None:
setuptools_table.setdefault("include-package-data", dist.include_package_data)
else:
Expand All @@ -123,20 +122,10 @@ def read_configuration(
asdict["tool"] = tool_table
tool_table["setuptools"] = setuptools_table

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

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


def _skip_bad_config(
project_cfg: dict, setuptools_cfg: dict, dist: Optional["Distribution"]
) -> bool:
"""Be temporarily forgiving with invalid ``pyproject.toml``"""
# See pypa/setuptools#3199 and pypa/cibuildwheel#1064

if dist is None or (
dist.metadata.name is None
and dist.metadata.version is None
and dist.install_requires is None
):
# It seems that the build is not getting any configuration from other places
return False

if setuptools_cfg:
# If `[tool.setuptools]` is set, then `pyproject.toml` config is intentional
return False

given_config = set(project_cfg.keys())
popular_subset = {"name", "version", "python_requires", "requires-python"}
if given_config <= popular_subset:
# It seems that the docs in cibuildtool has been inadvertently encouraging users
# to create `pyproject.toml` files that are not compliant with the standards.
# Let's be forgiving for the time being.
_InvalidFile.emit()
return True

return False


def expand_configuration(
config: dict,
root_dir: Optional[_Path] = None,
Expand Down Expand Up @@ -476,21 +435,3 @@ def __exit__(self, exc_type, exc_value, traceback):

class _BetaConfiguration(SetuptoolsWarning):
_SUMMARY = "Support for `[tool.setuptools]` in `pyproject.toml` is still *beta*."


class _InvalidFile(SetuptoolsWarning):
_SUMMARY = "The given `pyproject.toml` file is invalid and would be ignored."
_DETAILS = """
############################
# Invalid `pyproject.toml` #
############################

Any configurations in `pyproject.toml` will be ignored.
Please note that future releases of setuptools will halt the build process
if an invalid file is given.

To prevent setuptools from considering `pyproject.toml` please
DO NOT include both `[project]` or `[tool.setuptools]` tables in your file.
"""
_DUE_DATE = (2023, 6, 1) # warning introduced in 2022-03-26
_SEE_DOCS = "userguide/pyproject_config.html"
10 changes: 0 additions & 10 deletions setuptools/dist.py
Expand Up @@ -51,16 +51,6 @@
__import__('setuptools.extern.packaging.version')


def _get_unpatched(cls):
DistDeprecationWarning.emit(
"Private function",
"Do not call this function",
due_date=(2023, 6, 1),
# Warning initially introduced in 2016
)
return get_unpatched(cls)


def get_metadata_version(self):
mv = getattr(self, 'metadata_version', None)
if mv is None:
Expand Down
45 changes: 5 additions & 40 deletions setuptools/package_index.py
Expand Up @@ -39,7 +39,6 @@
from fnmatch import translate
from setuptools.wheel import Wheel
from setuptools.extern.more_itertools import unique_everseen
from setuptools.warnings import SetuptoolsDeprecationWarning


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

def _download_html(self, url, headers, filename):
file = open(filename)
for line in file:
if line.strip():
# Check for a subversion index page
if re.search(r'<title>([^- ]+ - )?Revision \d+:', line):
# it's a subversion index page:
file.close()
os.unlink(filename)
return self._download_svn(url, filename)
break # not an index page
file.close()
def _invalid_download_html(self, url, headers, filename):
os.unlink(filename)
raise DistutilsError("Unexpected HTML page found at " + url)
raise DistutilsError(f"Unexpected HTML page found at {url}")

def _download_svn(self, url, filename):
SetuptoolsDeprecationWarning.emit(
"Invalid config",
f"SVN download support is deprecated: {url}",
due_date=(2023, 6, 1), # Initially introduced in 23 Sept 2018
)
url = url.split('#', 1)[0] # remove any fragment for svn's sake
creds = ''
if url.lower().startswith('svn:') and '@' in url:
scheme, netloc, path, p, q, f = urllib.parse.urlparse(url)
if not netloc and path.startswith('//') and '/' in path[2:]:
netloc, path = path[2:].split('/', 1)
auth, host = _splituser(netloc)
if auth:
if ':' in auth:
user, pw = auth.split(':', 1)
creds = " --username=%s --password=%s" % (user, pw)
else:
creds = " --username=" + auth
netloc = host
parts = scheme, netloc, url, p, q, f
url = urllib.parse.urlunparse(parts)
self.info("Doing subversion checkout from %s to %s", url, filename)
os.system("svn checkout%s -q %s %s" % (creds, url, filename))
return filename
def _download_svn(self, url, _filename):
raise DistutilsError(f"Invalid config, SVN download is not supported: {url}")

@staticmethod
def _vcs_split_rev_from_url(url, pop_prefix=False):
Expand Down