1"""setuptools.errors
2
3Provides exceptions used by setuptools modules.
4"""
5
6from __future__ import annotations
7
8from typing import TYPE_CHECKING
9
10from distutils import errors as _distutils_errors
11
12if TYPE_CHECKING:
13 from typing_extensions import TypeAlias
14
15# Re-export errors from distutils to facilitate the migration to PEP632
16
17ByteCompileError: TypeAlias = _distutils_errors.DistutilsByteCompileError
18CCompilerError: TypeAlias = _distutils_errors.CCompilerError
19ClassError: TypeAlias = _distutils_errors.DistutilsClassError
20CompileError: TypeAlias = _distutils_errors.CompileError
21ExecError: TypeAlias = _distutils_errors.DistutilsExecError
22FileError: TypeAlias = _distutils_errors.DistutilsFileError
23InternalError: TypeAlias = _distutils_errors.DistutilsInternalError
24LibError: TypeAlias = _distutils_errors.LibError
25LinkError: TypeAlias = _distutils_errors.LinkError
26ModuleError: TypeAlias = _distutils_errors.DistutilsModuleError
27OptionError: TypeAlias = _distutils_errors.DistutilsOptionError
28PlatformError: TypeAlias = _distutils_errors.DistutilsPlatformError
29PreprocessError: TypeAlias = _distutils_errors.PreprocessError
30SetupError: TypeAlias = _distutils_errors.DistutilsSetupError
31TemplateError: TypeAlias = _distutils_errors.DistutilsTemplateError
32UnknownFileError: TypeAlias = _distutils_errors.UnknownFileError
33
34# The root error class in the hierarchy
35BaseError: TypeAlias = _distutils_errors.DistutilsError
36
37
38class InvalidConfigError(OptionError):
39 """Error used for invalid configurations."""
40
41
42class RemovedConfigError(OptionError):
43 """Error used for configurations that were deprecated and removed."""
44
45
46class RemovedCommandError(BaseError, RuntimeError):
47 """Error used for commands that have been removed in setuptools.
48
49 Since ``setuptools`` is built on ``distutils``, simply removing a command
50 from ``setuptools`` will make the behavior fall back to ``distutils``; this
51 error is raised if a command exists in ``distutils`` but has been actively
52 removed in ``setuptools``.
53 """
54
55
56class PackageDiscoveryError(BaseError, RuntimeError):
57 """Impossible to perform automatic discovery of packages and/or modules.
58
59 The current project layout or given discovery options can lead to problems when
60 scanning the project directory.
61
62 Setuptools might also refuse to complete auto-discovery if an error prone condition
63 is detected (e.g. when a project is organised as a flat-layout but contains
64 multiple directories that can be taken as top-level packages inside a single
65 distribution [*]_). In these situations the users are encouraged to be explicit
66 about which packages to include or to make the discovery parameters more specific.
67
68 .. [*] Since multi-package distributions are uncommon it is very likely that the
69 developers did not intend for all the directories to be packaged, and are just
70 leaving auxiliary code in the repository top-level, such as maintenance-related
71 scripts.
72 """