選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

781 行
26 KiB

  1. """
  2. Load setuptools configuration from ``setup.cfg`` files.
  3. **API will be made private in the future**
  4. To read project metadata, consider using
  5. ``build.util.project_wheel_metadata`` (https://pypi.org/project/build/).
  6. For simple scenarios, you can also try parsing the file directly
  7. with the help of ``configparser``.
  8. """
  9. from __future__ import annotations
  10. import contextlib
  11. import functools
  12. import os
  13. from collections import defaultdict
  14. from collections.abc import Iterable, Iterator
  15. from functools import partial, wraps
  16. from typing import TYPE_CHECKING, Any, Callable, ClassVar, Generic, TypeVar, cast
  17. from packaging.markers import default_environment as marker_env
  18. from packaging.requirements import InvalidRequirement, Requirement
  19. from packaging.version import InvalidVersion, Version
  20. from .. import _static
  21. from .._path import StrPath
  22. from ..errors import FileError, OptionError
  23. from ..warnings import SetuptoolsDeprecationWarning
  24. from . import expand
  25. if TYPE_CHECKING:
  26. from typing_extensions import TypeAlias
  27. from setuptools.dist import Distribution
  28. from distutils.dist import DistributionMetadata
  29. SingleCommandOptions: TypeAlias = dict[str, tuple[str, Any]]
  30. """Dict that associate the name of the options of a particular command to a
  31. tuple. The first element of the tuple indicates the origin of the option value
  32. (e.g. the name of the configuration file where it was read from),
  33. while the second element of the tuple is the option value itself
  34. """
  35. AllCommandOptions: TypeAlias = dict[str, SingleCommandOptions]
  36. """cmd name => its options"""
  37. Target = TypeVar("Target", "Distribution", "DistributionMetadata")
  38. def read_configuration(
  39. filepath: StrPath, find_others: bool = False, ignore_option_errors: bool = False
  40. ) -> dict:
  41. """Read given configuration file and returns options from it as a dict.
  42. :param str|unicode filepath: Path to configuration file
  43. to get options from.
  44. :param bool find_others: Whether to search for other configuration files
  45. which could be on in various places.
  46. :param bool ignore_option_errors: Whether to silently ignore
  47. options, values of which could not be resolved (e.g. due to exceptions
  48. in directives such as file:, attr:, etc.).
  49. If False exceptions are propagated as expected.
  50. :rtype: dict
  51. """
  52. from setuptools.dist import Distribution
  53. dist = Distribution()
  54. filenames = dist.find_config_files() if find_others else []
  55. handlers = _apply(dist, filepath, filenames, ignore_option_errors)
  56. return configuration_to_dict(handlers)
  57. def apply_configuration(dist: Distribution, filepath: StrPath) -> Distribution:
  58. """Apply the configuration from a ``setup.cfg`` file into an existing
  59. distribution object.
  60. """
  61. _apply(dist, filepath)
  62. dist._finalize_requires()
  63. return dist
  64. def _apply(
  65. dist: Distribution,
  66. filepath: StrPath,
  67. other_files: Iterable[StrPath] = (),
  68. ignore_option_errors: bool = False,
  69. ) -> tuple[ConfigMetadataHandler, ConfigOptionsHandler]:
  70. """Read configuration from ``filepath`` and applies to the ``dist`` object."""
  71. from setuptools.dist import _Distribution
  72. filepath = os.path.abspath(filepath)
  73. if not os.path.isfile(filepath):
  74. raise FileError(f'Configuration file {filepath} does not exist.')
  75. current_directory = os.getcwd()
  76. os.chdir(os.path.dirname(filepath))
  77. filenames = [*other_files, filepath]
  78. try:
  79. # TODO: Temporary cast until mypy 1.12 is released with upstream fixes from typeshed
  80. _Distribution.parse_config_files(dist, filenames=cast(list[str], filenames))
  81. handlers = parse_configuration(
  82. dist, dist.command_options, ignore_option_errors=ignore_option_errors
  83. )
  84. dist._finalize_license_files()
  85. finally:
  86. os.chdir(current_directory)
  87. return handlers
  88. def _get_option(target_obj: Distribution | DistributionMetadata, key: str):
  89. """
  90. Given a target object and option key, get that option from
  91. the target object, either through a get_{key} method or
  92. from an attribute directly.
  93. """
  94. getter_name = f'get_{key}'
  95. by_attribute = functools.partial(getattr, target_obj, key)
  96. getter = getattr(target_obj, getter_name, by_attribute)
  97. return getter()
  98. def configuration_to_dict(
  99. handlers: Iterable[
  100. ConfigHandler[Distribution] | ConfigHandler[DistributionMetadata]
  101. ],
  102. ) -> dict:
  103. """Returns configuration data gathered by given handlers as a dict.
  104. :param Iterable[ConfigHandler] handlers: Handlers list,
  105. usually from parse_configuration()
  106. :rtype: dict
  107. """
  108. config_dict: dict = defaultdict(dict)
  109. for handler in handlers:
  110. for option in handler.set_options:
  111. value = _get_option(handler.target_obj, option)
  112. config_dict[handler.section_prefix][option] = value
  113. return config_dict
  114. def parse_configuration(
  115. distribution: Distribution,
  116. command_options: AllCommandOptions,
  117. ignore_option_errors: bool = False,
  118. ) -> tuple[ConfigMetadataHandler, ConfigOptionsHandler]:
  119. """Performs additional parsing of configuration options
  120. for a distribution.
  121. Returns a list of used option handlers.
  122. :param Distribution distribution:
  123. :param dict command_options:
  124. :param bool ignore_option_errors: Whether to silently ignore
  125. options, values of which could not be resolved (e.g. due to exceptions
  126. in directives such as file:, attr:, etc.).
  127. If False exceptions are propagated as expected.
  128. :rtype: list
  129. """
  130. with expand.EnsurePackagesDiscovered(distribution) as ensure_discovered:
  131. options = ConfigOptionsHandler(
  132. distribution,
  133. command_options,
  134. ignore_option_errors,
  135. ensure_discovered,
  136. )
  137. options.parse()
  138. if not distribution.package_dir:
  139. distribution.package_dir = options.package_dir # Filled by `find_packages`
  140. meta = ConfigMetadataHandler(
  141. distribution.metadata,
  142. command_options,
  143. ignore_option_errors,
  144. ensure_discovered,
  145. distribution.package_dir,
  146. distribution.src_root,
  147. )
  148. meta.parse()
  149. distribution._referenced_files.update(
  150. options._referenced_files, meta._referenced_files
  151. )
  152. return meta, options
  153. def _warn_accidental_env_marker_misconfig(label: str, orig_value: str, parsed: list):
  154. """Because users sometimes misinterpret this configuration:
  155. [options.extras_require]
  156. foo = bar;python_version<"4"
  157. It looks like one requirement with an environment marker
  158. but because there is no newline, it's parsed as two requirements
  159. with a semicolon as separator.
  160. Therefore, if:
  161. * input string does not contain a newline AND
  162. * parsed result contains two requirements AND
  163. * parsing of the two parts from the result ("<first>;<second>")
  164. leads in a valid Requirement with a valid marker
  165. a UserWarning is shown to inform the user about the possible problem.
  166. """
  167. if "\n" in orig_value or len(parsed) != 2:
  168. return
  169. markers = marker_env().keys()
  170. try:
  171. req = Requirement(parsed[1])
  172. if req.name in markers:
  173. _AmbiguousMarker.emit(field=label, req=parsed[1])
  174. except InvalidRequirement as ex:
  175. if any(parsed[1].startswith(marker) for marker in markers):
  176. msg = _AmbiguousMarker.message(field=label, req=parsed[1])
  177. raise InvalidRequirement(msg) from ex
  178. class ConfigHandler(Generic[Target]):
  179. """Handles metadata supplied in configuration files."""
  180. section_prefix: str
  181. """Prefix for config sections handled by this handler.
  182. Must be provided by class heirs.
  183. """
  184. aliases: ClassVar[dict[str, str]] = {}
  185. """Options aliases.
  186. For compatibility with various packages. E.g.: d2to1 and pbr.
  187. Note: `-` in keys is replaced with `_` by config parser.
  188. """
  189. def __init__(
  190. self,
  191. target_obj: Target,
  192. options: AllCommandOptions,
  193. ignore_option_errors,
  194. ensure_discovered: expand.EnsurePackagesDiscovered,
  195. ) -> None:
  196. self.ignore_option_errors = ignore_option_errors
  197. self.target_obj: Target = target_obj
  198. self.sections = dict(self._section_options(options))
  199. self.set_options: list[str] = []
  200. self.ensure_discovered = ensure_discovered
  201. self._referenced_files = set[str]()
  202. """After parsing configurations, this property will enumerate
  203. all files referenced by the "file:" directive. Private API for setuptools only.
  204. """
  205. @classmethod
  206. def _section_options(
  207. cls, options: AllCommandOptions
  208. ) -> Iterator[tuple[str, SingleCommandOptions]]:
  209. for full_name, value in options.items():
  210. pre, _sep, name = full_name.partition(cls.section_prefix)
  211. if pre:
  212. continue
  213. yield name.lstrip('.'), value
  214. @property
  215. def parsers(self):
  216. """Metadata item name to parser function mapping."""
  217. raise NotImplementedError(
  218. f'{self.__class__.__name__} must provide .parsers property'
  219. )
  220. def __setitem__(self, option_name, value) -> None:
  221. target_obj = self.target_obj
  222. # Translate alias into real name.
  223. option_name = self.aliases.get(option_name, option_name)
  224. try:
  225. current_value = getattr(target_obj, option_name)
  226. except AttributeError as e:
  227. raise KeyError(option_name) from e
  228. if current_value:
  229. # Already inhabited. Skipping.
  230. return
  231. try:
  232. parsed = self.parsers.get(option_name, lambda x: x)(value)
  233. except (Exception,) * self.ignore_option_errors:
  234. return
  235. simple_setter = functools.partial(target_obj.__setattr__, option_name)
  236. setter = getattr(target_obj, f"set_{option_name}", simple_setter)
  237. setter(parsed)
  238. self.set_options.append(option_name)
  239. @classmethod
  240. def _parse_list(cls, value, separator=','):
  241. """Represents value as a list.
  242. Value is split either by separator (defaults to comma) or by lines.
  243. :param value:
  244. :param separator: List items separator character.
  245. :rtype: list
  246. """
  247. if isinstance(value, list): # _get_parser_compound case
  248. return value
  249. if '\n' in value:
  250. value = value.splitlines()
  251. else:
  252. value = value.split(separator)
  253. return [chunk.strip() for chunk in value if chunk.strip()]
  254. @classmethod
  255. def _parse_dict(cls, value):
  256. """Represents value as a dict.
  257. :param value:
  258. :rtype: dict
  259. """
  260. separator = '='
  261. result = {}
  262. for line in cls._parse_list(value):
  263. key, sep, val = line.partition(separator)
  264. if sep != separator:
  265. raise OptionError(f"Unable to parse option value to dict: {value}")
  266. result[key.strip()] = val.strip()
  267. return result
  268. @classmethod
  269. def _parse_bool(cls, value):
  270. """Represents value as boolean.
  271. :param value:
  272. :rtype: bool
  273. """
  274. value = value.lower()
  275. return value in ('1', 'true', 'yes')
  276. @classmethod
  277. def _exclude_files_parser(cls, key):
  278. """Returns a parser function to make sure field inputs
  279. are not files.
  280. Parses a value after getting the key so error messages are
  281. more informative.
  282. :param key:
  283. :rtype: callable
  284. """
  285. def parser(value):
  286. exclude_directive = 'file:'
  287. if value.startswith(exclude_directive):
  288. raise ValueError(
  289. f'Only strings are accepted for the {key} field, '
  290. 'files are not accepted'
  291. )
  292. return _static.Str(value)
  293. return parser
  294. def _parse_file(self, value, root_dir: StrPath | None):
  295. """Represents value as a string, allowing including text
  296. from nearest files using `file:` directive.
  297. Directive is sandboxed and won't reach anything outside
  298. directory with setup.py.
  299. Examples:
  300. file: README.rst, CHANGELOG.md, src/file.txt
  301. :param str value:
  302. :rtype: str
  303. """
  304. include_directive = 'file:'
  305. if not isinstance(value, str):
  306. return value
  307. if not value.startswith(include_directive):
  308. return _static.Str(value)
  309. spec = value[len(include_directive) :]
  310. filepaths = [path.strip() for path in spec.split(',')]
  311. self._referenced_files.update(filepaths)
  312. # XXX: Is marking as static contents coming from files too optimistic?
  313. return _static.Str(expand.read_files(filepaths, root_dir))
  314. def _parse_attr(self, value, package_dir, root_dir: StrPath):
  315. """Represents value as a module attribute.
  316. Examples:
  317. attr: package.attr
  318. attr: package.module.attr
  319. :param str value:
  320. :rtype: str
  321. """
  322. attr_directive = 'attr:'
  323. if not value.startswith(attr_directive):
  324. return _static.Str(value)
  325. attr_desc = value.replace(attr_directive, '')
  326. # Make sure package_dir is populated correctly, so `attr:` directives can work
  327. package_dir.update(self.ensure_discovered.package_dir)
  328. return expand.read_attr(attr_desc, package_dir, root_dir)
  329. @classmethod
  330. def _get_parser_compound(cls, *parse_methods):
  331. """Returns parser function to represents value as a list.
  332. Parses a value applying given methods one after another.
  333. :param parse_methods:
  334. :rtype: callable
  335. """
  336. def parse(value):
  337. parsed = value
  338. for method in parse_methods:
  339. parsed = method(parsed)
  340. return parsed
  341. return parse
  342. @classmethod
  343. def _parse_section_to_dict_with_key(cls, section_options, values_parser):
  344. """Parses section options into a dictionary.
  345. Applies a given parser to each option in a section.
  346. :param dict section_options:
  347. :param callable values_parser: function with 2 args corresponding to key, value
  348. :rtype: dict
  349. """
  350. value = {}
  351. for key, (_, val) in section_options.items():
  352. value[key] = values_parser(key, val)
  353. return value
  354. @classmethod
  355. def _parse_section_to_dict(cls, section_options, values_parser=None):
  356. """Parses section options into a dictionary.
  357. Optionally applies a given parser to each value.
  358. :param dict section_options:
  359. :param callable values_parser: function with 1 arg corresponding to option value
  360. :rtype: dict
  361. """
  362. parser = (lambda _, v: values_parser(v)) if values_parser else (lambda _, v: v)
  363. return cls._parse_section_to_dict_with_key(section_options, parser)
  364. def parse_section(self, section_options) -> None:
  365. """Parses configuration file section.
  366. :param dict section_options:
  367. """
  368. for name, (_, value) in section_options.items():
  369. with contextlib.suppress(KeyError):
  370. # Keep silent for a new option may appear anytime.
  371. self[name] = value
  372. def parse(self) -> None:
  373. """Parses configuration file items from one
  374. or more related sections.
  375. """
  376. for section_name, section_options in self.sections.items():
  377. method_postfix = ''
  378. if section_name: # [section.option] variant
  379. method_postfix = f"_{section_name}"
  380. section_parser_method: Callable | None = getattr(
  381. self,
  382. # Dots in section names are translated into dunderscores.
  383. f'parse_section{method_postfix}'.replace('.', '__'),
  384. None,
  385. )
  386. if section_parser_method is None:
  387. raise OptionError(
  388. "Unsupported distribution option section: "
  389. f"[{self.section_prefix}.{section_name}]"
  390. )
  391. section_parser_method(section_options)
  392. def _deprecated_config_handler(self, func, msg, **kw):
  393. """this function will wrap around parameters that are deprecated
  394. :param msg: deprecation message
  395. :param func: function to be wrapped around
  396. """
  397. @wraps(func)
  398. def config_handler(*args, **kwargs):
  399. kw.setdefault("stacklevel", 2)
  400. _DeprecatedConfig.emit("Deprecated config in `setup.cfg`", msg, **kw)
  401. return func(*args, **kwargs)
  402. return config_handler
  403. class ConfigMetadataHandler(ConfigHandler["DistributionMetadata"]):
  404. section_prefix = 'metadata'
  405. aliases = {
  406. 'home_page': 'url',
  407. 'summary': 'description',
  408. 'classifier': 'classifiers',
  409. 'platform': 'platforms',
  410. }
  411. strict_mode = False
  412. """We need to keep it loose, to be partially compatible with
  413. `pbr` and `d2to1` packages which also uses `metadata` section.
  414. """
  415. def __init__(
  416. self,
  417. target_obj: DistributionMetadata,
  418. options: AllCommandOptions,
  419. ignore_option_errors: bool,
  420. ensure_discovered: expand.EnsurePackagesDiscovered,
  421. package_dir: dict | None = None,
  422. root_dir: StrPath | None = os.curdir,
  423. ) -> None:
  424. super().__init__(target_obj, options, ignore_option_errors, ensure_discovered)
  425. self.package_dir = package_dir
  426. self.root_dir = root_dir
  427. @property
  428. def parsers(self):
  429. """Metadata item name to parser function mapping."""
  430. parse_list_static = self._get_parser_compound(self._parse_list, _static.List)
  431. parse_dict_static = self._get_parser_compound(self._parse_dict, _static.Dict)
  432. parse_file = partial(self._parse_file, root_dir=self.root_dir)
  433. exclude_files_parser = self._exclude_files_parser
  434. return {
  435. 'author': _static.Str,
  436. 'author_email': _static.Str,
  437. 'maintainer': _static.Str,
  438. 'maintainer_email': _static.Str,
  439. 'platforms': parse_list_static,
  440. 'keywords': parse_list_static,
  441. 'provides': parse_list_static,
  442. 'obsoletes': parse_list_static,
  443. 'classifiers': self._get_parser_compound(parse_file, parse_list_static),
  444. 'license': exclude_files_parser('license'),
  445. 'license_files': parse_list_static,
  446. 'description': parse_file,
  447. 'long_description': parse_file,
  448. 'long_description_content_type': _static.Str,
  449. 'version': self._parse_version, # Cannot be marked as dynamic
  450. 'url': _static.Str,
  451. 'project_urls': parse_dict_static,
  452. }
  453. def _parse_version(self, value):
  454. """Parses `version` option value.
  455. :param value:
  456. :rtype: str
  457. """
  458. version = self._parse_file(value, self.root_dir)
  459. if version != value:
  460. version = version.strip()
  461. # Be strict about versions loaded from file because it's easy to
  462. # accidentally include newlines and other unintended content
  463. try:
  464. Version(version)
  465. except InvalidVersion as e:
  466. raise OptionError(
  467. f'Version loaded from {value} does not '
  468. f'comply with PEP 440: {version}'
  469. ) from e
  470. return version
  471. return expand.version(self._parse_attr(value, self.package_dir, self.root_dir))
  472. class ConfigOptionsHandler(ConfigHandler["Distribution"]):
  473. section_prefix = 'options'
  474. def __init__(
  475. self,
  476. target_obj: Distribution,
  477. options: AllCommandOptions,
  478. ignore_option_errors: bool,
  479. ensure_discovered: expand.EnsurePackagesDiscovered,
  480. ) -> None:
  481. super().__init__(target_obj, options, ignore_option_errors, ensure_discovered)
  482. self.root_dir = target_obj.src_root
  483. self.package_dir: dict[str, str] = {} # To be filled by `find_packages`
  484. @classmethod
  485. def _parse_list_semicolon(cls, value):
  486. return cls._parse_list(value, separator=';')
  487. def _parse_file_in_root(self, value):
  488. return self._parse_file(value, root_dir=self.root_dir)
  489. def _parse_requirements_list(self, label: str, value: str):
  490. # Parse a requirements list, either by reading in a `file:`, or a list.
  491. parsed = self._parse_list_semicolon(self._parse_file_in_root(value))
  492. _warn_accidental_env_marker_misconfig(label, value, parsed)
  493. # Filter it to only include lines that are not comments. `parse_list`
  494. # will have stripped each line and filtered out empties.
  495. return _static.List(line for line in parsed if not line.startswith("#"))
  496. # ^-- Use `_static.List` to mark a non-`Dynamic` Core Metadata
  497. @property
  498. def parsers(self):
  499. """Metadata item name to parser function mapping."""
  500. parse_list = self._parse_list
  501. parse_bool = self._parse_bool
  502. parse_cmdclass = self._parse_cmdclass
  503. return {
  504. 'zip_safe': parse_bool,
  505. 'include_package_data': parse_bool,
  506. 'package_dir': self._parse_dict,
  507. 'scripts': parse_list,
  508. 'eager_resources': parse_list,
  509. 'dependency_links': parse_list,
  510. 'namespace_packages': self._deprecated_config_handler(
  511. parse_list,
  512. "The namespace_packages parameter is deprecated, "
  513. "consider using implicit namespaces instead (PEP 420).",
  514. # TODO: define due date, see setuptools.dist:check_nsp.
  515. ),
  516. 'install_requires': partial( # Core Metadata
  517. self._parse_requirements_list, "install_requires"
  518. ),
  519. 'setup_requires': self._parse_list_semicolon,
  520. 'packages': self._parse_packages,
  521. 'entry_points': self._parse_file_in_root,
  522. 'py_modules': parse_list,
  523. 'python_requires': _static.SpecifierSet, # Core Metadata
  524. 'cmdclass': parse_cmdclass,
  525. }
  526. def _parse_cmdclass(self, value):
  527. package_dir = self.ensure_discovered.package_dir
  528. return expand.cmdclass(self._parse_dict(value), package_dir, self.root_dir)
  529. def _parse_packages(self, value):
  530. """Parses `packages` option value.
  531. :param value:
  532. :rtype: list
  533. """
  534. find_directives = ['find:', 'find_namespace:']
  535. trimmed_value = value.strip()
  536. if trimmed_value not in find_directives:
  537. return self._parse_list(value)
  538. # Read function arguments from a dedicated section.
  539. find_kwargs = self.parse_section_packages__find(
  540. self.sections.get('packages.find', {})
  541. )
  542. find_kwargs.update(
  543. namespaces=(trimmed_value == find_directives[1]),
  544. root_dir=self.root_dir,
  545. fill_package_dir=self.package_dir,
  546. )
  547. return expand.find_packages(**find_kwargs)
  548. def parse_section_packages__find(self, section_options):
  549. """Parses `packages.find` configuration file section.
  550. To be used in conjunction with _parse_packages().
  551. :param dict section_options:
  552. """
  553. section_data = self._parse_section_to_dict(section_options, self._parse_list)
  554. valid_keys = ['where', 'include', 'exclude']
  555. find_kwargs = {k: v for k, v in section_data.items() if k in valid_keys and v}
  556. where = find_kwargs.get('where')
  557. if where is not None:
  558. find_kwargs['where'] = where[0] # cast list to single val
  559. return find_kwargs
  560. def parse_section_entry_points(self, section_options) -> None:
  561. """Parses `entry_points` configuration file section.
  562. :param dict section_options:
  563. """
  564. parsed = self._parse_section_to_dict(section_options, self._parse_list)
  565. self['entry_points'] = parsed
  566. def _parse_package_data(self, section_options):
  567. package_data = self._parse_section_to_dict(section_options, self._parse_list)
  568. return expand.canonic_package_data(package_data)
  569. def parse_section_package_data(self, section_options) -> None:
  570. """Parses `package_data` configuration file section.
  571. :param dict section_options:
  572. """
  573. self['package_data'] = self._parse_package_data(section_options)
  574. def parse_section_exclude_package_data(self, section_options) -> None:
  575. """Parses `exclude_package_data` configuration file section.
  576. :param dict section_options:
  577. """
  578. self['exclude_package_data'] = self._parse_package_data(section_options)
  579. def parse_section_extras_require(self, section_options) -> None: # Core Metadata
  580. """Parses `extras_require` configuration file section.
  581. :param dict section_options:
  582. """
  583. parsed = self._parse_section_to_dict_with_key(
  584. section_options,
  585. lambda k, v: self._parse_requirements_list(f"extras_require[{k}]", v),
  586. )
  587. self['extras_require'] = _static.Dict(parsed)
  588. # ^-- Use `_static.Dict` to mark a non-`Dynamic` Core Metadata
  589. def parse_section_data_files(self, section_options) -> None:
  590. """Parses `data_files` configuration file section.
  591. :param dict section_options:
  592. """
  593. parsed = self._parse_section_to_dict(section_options, self._parse_list)
  594. self['data_files'] = expand.canonic_data_files(parsed, self.root_dir)
  595. class _AmbiguousMarker(SetuptoolsDeprecationWarning):
  596. _SUMMARY = "Ambiguous requirement marker."
  597. _DETAILS = """
  598. One of the parsed requirements in `{field}` looks like a valid environment marker:
  599. {req!r}
  600. Please make sure that the configuration file is correct.
  601. You can use dangling lines to avoid this problem.
  602. """
  603. _SEE_DOCS = "userguide/declarative_config.html#opt-2"
  604. # TODO: should we include due_date here? Initially introduced in 6 Aug 2022.
  605. # Does this make sense with latest version of packaging?
  606. @classmethod
  607. def message(cls, **kw):
  608. docs = f"https://setuptools.pypa.io/en/latest/{cls._SEE_DOCS}"
  609. return cls._format(cls._SUMMARY, cls._DETAILS, see_url=docs, format_args=kw)
  610. class _DeprecatedConfig(SetuptoolsDeprecationWarning):
  611. _SEE_DOCS = "userguide/declarative_config.html"