|
20 | 20 | import tomli as tomllib
|
21 | 21 |
|
22 | 22 | import click
|
| 23 | +import pip |
23 | 24 | from click.utils import LazyFile
|
24 | 25 | from pip._internal.req import InstallRequirement
|
25 |
| -from pip._internal.req.constructors import install_req_from_line |
| 26 | +from pip._internal.req.constructors import ( |
| 27 | + install_req_from_line as _install_req_from_line, |
| 28 | +) |
26 | 29 | from pip._internal.resolution.resolvelib.base import Requirement as PipRequirement
|
27 | 30 | from pip._internal.utils.misc import redact_auth_from_url
|
28 | 31 | from pip._internal.vcs import is_url
|
|
31 | 34 | from pip._vendor.packaging.specifiers import SpecifierSet
|
32 | 35 | from pip._vendor.packaging.utils import canonicalize_name
|
33 | 36 | from pip._vendor.packaging.version import Version
|
| 37 | +from pip._vendor.packaging.version import parse as parse_version |
34 | 38 | from pip._vendor.pkg_resources import get_distribution
|
35 | 39 |
|
36 |
| -from piptools._compat import PIP_VERSION |
37 | 40 | from piptools.locations import DEFAULT_CONFIG_FILE_NAMES
|
38 | 41 | from piptools.subprocess_utils import run_python_snippet
|
39 | 42 |
|
|
42 | 45 | _T = TypeVar("_T")
|
43 | 46 | _S = TypeVar("_S")
|
44 | 47 |
|
| 48 | +PIP_VERSION = tuple(map(int, parse_version(pip.__version__).base_version.split("."))) |
| 49 | + |
45 | 50 | UNSAFE_PACKAGES = {"setuptools", "distribute", "pip"}
|
46 | 51 | COMPILE_EXCLUDE_OPTIONS = {
|
47 | 52 | "--dry-run",
|
@@ -88,6 +93,10 @@ def comment(text: str) -> str:
|
88 | 93 | return click.style(text, fg="green")
|
89 | 94 |
|
90 | 95 |
|
| 96 | +def install_req_from_line(*args: Any, **kwargs: Any) -> InstallRequirement: |
| 97 | + return copy_install_requirement(_install_req_from_line(*args, **kwargs)) |
| 98 | + |
| 99 | + |
91 | 100 | def make_install_requirement(
|
92 | 101 | name: str, version: str | Version, ireq: InstallRequirement
|
93 | 102 | ) -> InstallRequirement:
|
@@ -515,6 +524,10 @@ def copy_install_requirement(
|
515 | 524 | if "req" not in kwargs:
|
516 | 525 | kwargs["req"] = copy.deepcopy(template.req)
|
517 | 526 |
|
| 527 | + kwargs["extras"] = set(map(canonicalize_name, kwargs["extras"])) |
| 528 | + if kwargs["req"]: |
| 529 | + kwargs["req"].extras = set(kwargs["extras"]) |
| 530 | + |
518 | 531 | ireq = InstallRequirement(**kwargs)
|
519 | 532 |
|
520 | 533 | # If the original_link was None, keep it so. Passing `link` as an
|
|
0 commit comments