|
8 | 8 | import sys
|
9 | 9 | import uuid
|
10 | 10 | import zipfile
|
| 11 | +from optparse import Values |
11 | 12 | from typing import Any, Collection, Dict, Iterable, List, Optional, Sequence, Union
|
12 | 13 |
|
13 | 14 | from pip._vendor.packaging.markers import Marker
|
|
17 | 18 | from pip._vendor.packaging.version import Version
|
18 | 19 | from pip._vendor.packaging.version import parse as parse_version
|
19 | 20 | from pip._vendor.pep517.wrappers import Pep517HookCaller
|
| 21 | +from typing_extensions import Literal # Python 3.7 compatibility |
20 | 22 |
|
21 | 23 | from pip._internal.build_env import BuildEnvironment, NoOpBuildEnvironment
|
22 | 24 | from pip._internal.exceptions import InstallationError, LegacyInstallFailure
|
@@ -877,3 +879,46 @@ def check_invalid_constraint_type(req: InstallRequirement) -> str:
|
877 | 879 | )
|
878 | 880 |
|
879 | 881 | return problem
|
| 882 | + |
| 883 | + |
| 884 | +def _has_option(options: Values, reqs: List[InstallRequirement], option: str) -> bool: |
| 885 | + if getattr(options, option, None): |
| 886 | + return True |
| 887 | + for req in reqs: |
| 888 | + if getattr(req, option, None): |
| 889 | + return True |
| 890 | + return False |
| 891 | + |
| 892 | + |
| 893 | +def check_legacy_setup_py_options( |
| 894 | + options: Values, |
| 895 | + reqs: List[InstallRequirement], |
| 896 | + mode: Literal["install", "wheel", "download"], |
| 897 | +) -> None: |
| 898 | + has_install_options = _has_option(options, reqs, "install_options") |
| 899 | + has_build_options = _has_option(options, reqs, "build_options") |
| 900 | + has_global_options = _has_option(options, reqs, "global_options") |
| 901 | + legacy_setup_py_options_present = ( |
| 902 | + has_install_options or has_build_options or has_global_options |
| 903 | + ) |
| 904 | + if not legacy_setup_py_options_present: |
| 905 | + return |
| 906 | + |
| 907 | + control = options.format_control |
| 908 | + control.disallow_binaries() |
| 909 | + logger.warning( |
| 910 | + "Implying --no-binary=:all: due to the presence of " |
| 911 | + "--build-option / --global-option / --install-option. " |
| 912 | + "Consider using --config-settings for more flexibility.", |
| 913 | + ) |
| 914 | + if mode == "install" and has_install_options: |
| 915 | + deprecated( |
| 916 | + reason=( |
| 917 | + "--install-option is deprecated because " |
| 918 | + "it forces pip to use the 'setup.py install' " |
| 919 | + "command which is itself deprecated." |
| 920 | + ), |
| 921 | + issue=11358, |
| 922 | + replacement="to use --config-settings", |
| 923 | + gone_in=None, |
| 924 | + ) |
0 commit comments