...
 
Commits (21)
    https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/54be97e05ce6e303dddb95f9d8d0291c35f7189c Use strict optional checking in glibc 2023-06-20T01:42:51-07:00 hauntsaninja hauntsaninja@gmail.com Suggested by pradyunsg in #11374 `--no-strict-optional` defeats half the purpose of using mypy. This change is trivial, we already catch AttributeError in the case that mypy is concerned about. https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/b5a40ed64bf534858f9cd43d0a9fcd86e478c836 news 2023-06-20T01:45:24-07:00 hauntsaninja hauntsaninja@gmail.com https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/42117756313b1b59c3a6b4f637795688fc36b19e remove the error code to silence ruff 2023-06-20T01:48:49-07:00 hauntsaninja hauntsaninja@gmail.com https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/36014e6f495bd57363e935e466da8f165acd51f6 don't catch attributeerror 2023-06-20T01:51:56-07:00 hauntsaninja hauntsaninja@gmail.com https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/e995f2564495d0bb0cb609c0b48091c3f5708ed8 nope 2023-06-20T01:54:20-07:00 hauntsaninja hauntsaninja@gmail.com https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/b5377aeb73ac1fabc45abb07ed92b209b3213e98 nope 2023-06-20T02:04:36-07:00 hauntsaninja hauntsaninja@gmail.com https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/782cff7e0121d5160acddbfae2ef41e98492ffe5 Warn when legacy versions and specifiers are resolved 2023-06-27T16:43:32+02:00 Stéphane Bidoul stephane.bidoul@gmail.com Also warn in pip check. ... https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/45468f06d429080a9042909b76cfc25fce9bee5a Pass revisions options explicitly to mercurial commands 2023-07-01T13:41:34+02:00 Stéphane Bidoul stephane.bidoul@gmail.com https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/b99e082b003788f2e8abbad47d461f495faad892 Record download of completed partial requirements 2023-07-01T14:42:10+01:00 Paul Moore p.f.moore@gmail.com https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/cb25bf3731d46697586fc72a24ba1f8e57311377 Add a news file 2023-07-01T14:51:10+01:00 Paul Moore p.f.moore@gmail.com https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/647ba8d07e7832ea69d93f9a686d8f276e669a14 Limit the double download fix to wheels 2023-07-03T10:35:01+01:00 Paul Moore p.f.moore@gmail.com https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/8e80a3ad9a5b80de72efad6cbad3bebf2328642b Fix typo 2023-07-03T10:45:01+01:00 Paul Moore p.f.moore@gmail.com https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/4145168d68884a6ec10948dd28b1a6f54f17e63b Merge pull request #12119 from sbidoul/hg-explicit-rev-sbi 2023-07-03T13:05:30+02:00 Stéphane Bidoul stephane.bidoul@gmail.com Pass revisions options explicitly to mercurial commands https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/4cc183e445f22f8d31ca1852934be0b0524ac981 Merge pull request #12120 from pfmoore/fix_11847 2023-07-03T13:15:13+01:00 Paul Moore p.f.moore@gmail.com Record download of completed partial requirements https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/b88addeaf5fde848733d7ef631caa522eb1cfa53 Merge pull request #11945 from sbidoul/legacy-version-and-specifier-deprecati... 2023-07-03T13:51:18+01:00 Pradyun Gedam pradyunsg@gmail.com Surface LegacyVersion and LegacySpecifier deprecation warnings https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/997f92a450e38d7e99052d8bb840f627335d5a3f Merge branch 'main' into strict-optional-glibc 2023-07-05T01:23:21-07:00 Shantanu 12621235+hauntsaninja@users.noreply.github.com https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/4734c4c735ce63664efd165a6f54fa0e957f13f7 Merge pull request #12091 from hauntsaninja/strict-optional-glibc 2023-07-05T17:44:51+08:00 Tzu-ping Chung uranusjr@gmail.com https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/5dc65eabb75f89d4f4749b6c764042c227f6870a Don't exclude setuptools, distribute & wheel from freeze output on Python 3.12+ 2023-07-07T01:46:03+03:00 Роман Донченко dpb@corrigendum.ru Due to the advent of build isolation, it is no longer necessary to install setuptools and wheel in an environment just to install other packages. Moreover, on Python 3.12 both ensurepip [1] and virtualenv [2] are to stop installing setuptools &amp; wheel by default. This means that when those packages are present in a Python 3.12+ environment, it is reasonable to assume that they are runtime dependencies of the user's project, and therefore should be included in freeze output. distribute is just obsolete. [1] <a href="https://github.com/python/cpython/issues/95299" rel="nofollow noreferrer noopener" target="_blank">https://github.com/python/cpython/issues/95299</a> [2] <a href="https://github.com/pypa/virtualenv/pull/2558" rel="nofollow noreferrer noopener" target="_blank">https://github.com/pypa/virtualenv/pull/2558</a> https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/393ccfbc31eccdf7f053ee4d62b055e515ef3183 test_freeze_with_setuptools: use mocks 2023-07-07T01:46:03+03:00 Роман Донченко dpb@corrigendum.ru This makes it possible to test both branches on any Python version. https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/7a69c00720fb8e660ef0d1df174b79e039bdba95 Make the changelog entry more verbose 2023-07-07T01:48:03+03:00 Роман Донченко dpb@corrigendum.ru Co-authored-by: <span data-trailer="Co-authored-by:"><a href="mailto:uranusjr@gmail.com" title="uranusjr@gmail.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg5" style="text-decoration: none">N</a><a href="mailto:uranusjr@gmail.com" title="uranusjr@gmail.com">Tzu-ping Chung</a> &lt;<a href="mailto:uranusjr@gmail.com" title="uranusjr@gmail.com">uranusjr@gmail.com</a>&gt;</span> https://gitcode.net/awesome-mirrors/pypa/pip/-/commit/177cf88c5c989caabd4c233a1784d1e27c459aec Merge pull request #12032 from SpecLad/freeze-setuptools 2023-07-07T20:44:10+01:00 Pradyun Gedam pradyunsg@gmail.com
Prevent downloading files twice when PEP 658 metadata is present
Deprecate legacy version and version specifiers that don't conform to `PEP 440
<https://peps.python.org/pep-0440/>`_
Pass the ``-r`` flag to mercurial to be explicit that a revision is passed and protect
against ``hg`` options injection as part of VCS URLs. Users that do not have control on
VCS URLs passed to pip are advised to upgrade.
``freeze`` no longer excludes the ``setuptools``, ``distribute``, and ``wheel``
from the output when running on Python 3.12 or later, where they are not
included in a virtual environment by default. Use ``--exclude`` if you wish to
exclude any of these packages.
......@@ -7,6 +7,7 @@ from pip._internal.cli.status_codes import ERROR, SUCCESS
from pip._internal.operations.check import (
check_package_set,
create_package_set_from_installed,
warn_legacy_versions_and_specifiers,
)
from pip._internal.utils.misc import write_output
......@@ -21,6 +22,7 @@ class CheckCommand(Command):
def run(self, options: Values, args: List[str]) -> int:
package_set, parsing_probs = create_package_set_from_installed()
warn_legacy_versions_and_specifiers(package_set)
missing, conflicting = check_package_set(package_set)
for project_name in missing:
......
......@@ -130,6 +130,7 @@ class DownloadCommand(RequirementCommand):
self.trace_basic_info(finder)
requirement_set = resolver.resolve(reqs, check_supported_wheels=True)
requirement_set.warn_legacy_versions_and_specifiers()
downloaded: List[str] = []
for req in requirement_set.requirements.values():
......
import sys
from optparse import Values
from typing import List
from typing import AbstractSet, List
from pip._internal.cli import cmdoptions
from pip._internal.cli.base_command import Command
......@@ -8,7 +8,18 @@ from pip._internal.cli.status_codes import SUCCESS
from pip._internal.operations.freeze import freeze
from pip._internal.utils.compat import stdlib_pkgs
DEV_PKGS = {"pip", "setuptools", "distribute", "wheel"}
def _should_suppress_build_backends() -> bool:
return sys.version_info < (3, 12)
def _dev_pkgs() -> AbstractSet[str]:
pkgs = {"pip"}
if _should_suppress_build_backends():
pkgs |= {"setuptools", "distribute", "wheel"}
return pkgs
class FreezeCommand(Command):
......@@ -61,7 +72,7 @@ class FreezeCommand(Command):
action="store_true",
help=(
"Do not skip these packages in the output:"
" {}".format(", ".join(DEV_PKGS))
" {}".format(", ".join(_dev_pkgs()))
),
)
self.cmd_opts.add_option(
......@@ -77,7 +88,7 @@ class FreezeCommand(Command):
def run(self, options: Values, args: List[str]) -> int:
skip = set(stdlib_pkgs)
if not options.freeze_all:
skip.update(DEV_PKGS)
skip.update(_dev_pkgs())
if options.excludes:
skip.update(options.excludes)
......
......@@ -387,6 +387,9 @@ class InstallCommand(RequirementCommand):
json.dump(report.to_dict(), f, indent=2, ensure_ascii=False)
if options.dry_run:
# In non dry-run mode, the legacy versions and specifiers check
# will be done as part of conflict detection.
requirement_set.warn_legacy_versions_and_specifiers()
would_install_items = sorted(
(r.metadata["name"], r.metadata["version"])
for r in requirement_set.requirements_to_install
......
......@@ -145,6 +145,7 @@ class WheelCommand(RequirementCommand):
self.trace_basic_info(finder)
requirement_set = resolver.resolve(reqs, check_supported_wheels=True)
requirement_set.warn_legacy_versions_and_specifiers()
reqs_to_build: List[InstallRequirement] = []
for req in requirement_set.requirements.values():
......
......@@ -5,12 +5,15 @@ import logging
from typing import Callable, Dict, List, NamedTuple, Optional, Set, Tuple
from pip._vendor.packaging.requirements import Requirement
from pip._vendor.packaging.specifiers import LegacySpecifier
from pip._vendor.packaging.utils import NormalizedName, canonicalize_name
from pip._vendor.packaging.version import LegacyVersion
from pip._internal.distributions import make_distribution_for_install_requirement
from pip._internal.metadata import get_default_environment
from pip._internal.metadata.base import DistributionVersion
from pip._internal.req.req_install import InstallRequirement
from pip._internal.utils.deprecation import deprecated
logger = logging.getLogger(__name__)
......@@ -57,6 +60,8 @@ def check_package_set(
package name and returns a boolean.
"""
warn_legacy_versions_and_specifiers(package_set)
missing = {}
conflicting = {}
......@@ -147,3 +152,36 @@ def _create_whitelist(
break
return packages_affected
def warn_legacy_versions_and_specifiers(package_set: PackageSet) -> None:
for project_name, package_details in package_set.items():
if isinstance(package_details.version, LegacyVersion):
deprecated(
reason=(
f"{project_name} {package_details.version} "
f"has a non-standard version number."
),
replacement=(
f"to upgrade to a newer version of {project_name} "
f"or contact the author to suggest that they "
f"release a version with a conforming version number"
),
issue=12063,
gone_in="23.3",
)
for dep in package_details.dependencies:
if any(isinstance(spec, LegacySpecifier) for spec in dep.specifier):
deprecated(
reason=(
f"{project_name} {package_details.version} "
f"has a non-standard dependency specifier {dep}."
),
replacement=(
f"to upgrade to a newer version of {project_name} "
f"or contact the author to suggest that they "
f"release a version with a conforming dependency specifiers"
),
issue=12063,
gone_in="23.3",
)
......@@ -471,6 +471,19 @@ class RequirementPreparer:
logger.debug("Downloading link %s to %s", link, filepath)
req = links_to_fully_download[link]
req.local_file_path = filepath
# TODO: This needs fixing for sdists
# This is an emergency fix for #11847, which reports that
# distributions get downloaded twice when metadata is loaded
# from a PEP 658 standalone metadata file. Setting _downloaded
# fixes this for wheels, but breaks the sdist case (tests
# test_download_metadata). As PyPI is currently only serving
# metadata for wheels, this is not an immediate issue.
# Fixing the problem properly looks like it will require a
# complete refactoring of the `prepare_linked_requirements_more`
# logic, and I haven't a clue where to start on that, so for now
# I have fixed the issue *just* for wheels.
if req.is_wheel:
self._downloaded[req.link.url] = filepath
# This step is necessary to ensure all lazy wheels are processed
# successfully by the 'download', 'wheel', and 'install' commands.
......
......@@ -2,9 +2,12 @@ import logging
from collections import OrderedDict
from typing import Dict, List
from pip._vendor.packaging.specifiers import LegacySpecifier
from pip._vendor.packaging.utils import canonicalize_name
from pip._vendor.packaging.version import LegacyVersion
from pip._internal.req.req_install import InstallRequirement
from pip._internal.utils.deprecation import deprecated
logger = logging.getLogger(__name__)
......@@ -80,3 +83,37 @@ class RequirementSet:
for install_req in self.all_requirements
if not install_req.constraint and not install_req.satisfied_by
]
def warn_legacy_versions_and_specifiers(self) -> None:
for req in self.requirements_to_install:
version = req.get_dist().version
if isinstance(version, LegacyVersion):
deprecated(
reason=(
f"pip has selected the non standard version {version} "
f"of {req}. In the future this version will be "
f"ignored as it isn't standard compliant."
),
replacement=(
"set or update constraints to select another version "
"or contact the package author to fix the version number"
),
issue=12063,
gone_in="23.3",
)
for dep in req.get_dist().iter_dependencies():
if any(isinstance(spec, LegacySpecifier) for spec in dep.specifier):
deprecated(
reason=(
f"pip has selected {req} {version} which has non "
f"standard dependency specifier {dep}. "
f"In the future this version of {req} will be "
f"ignored as it isn't standard compliant."
),
replacement=(
"set or update constraints to select another version "
"or contact the package author to fix the version number"
),
issue=12063,
gone_in="23.3",
)
# The following comment should be removed at some point in the future.
# mypy: strict-optional=False
import os
import sys
from typing import Optional, Tuple
......@@ -20,8 +17,11 @@ def glibc_version_string_confstr() -> Optional[str]:
if sys.platform == "win32":
return None
try:
gnu_libc_version = os.confstr("CS_GNU_LIBC_VERSION")
if gnu_libc_version is None:
return None
# os.confstr("CS_GNU_LIBC_VERSION") returns a string like "glibc 2.17":
_, version = os.confstr("CS_GNU_LIBC_VERSION").split()
_, version = gnu_libc_version.split()
except (AttributeError, OSError, ValueError):
# os.confstr() or CS_GNU_LIBC_VERSION not available (or a bad value)...
return None
......
......@@ -31,7 +31,7 @@ class Mercurial(VersionControl):
@staticmethod
def get_base_rev_args(rev: str) -> List[str]:
return [rev]
return ["-r", rev]
def fetch_new(
self, dest: str, url: HiddenText, rev_options: RevOptions, verbosity: int
......
......@@ -88,11 +88,49 @@ def test_basic_freeze(script: PipTestEnvironment) -> None:
def test_freeze_with_pip(script: PipTestEnvironment) -> None:
"""Test pip shows itself"""
"""Test that pip shows itself only when --all is used"""
result = script.pip("freeze")
assert "pip==" not in result.stdout
result = script.pip("freeze", "--all")
assert "pip==" in result.stdout
def test_freeze_with_setuptools(script: PipTestEnvironment) -> None:
"""
Test that pip shows setuptools only when --all is used
or _should_suppress_build_backends() returns false
"""
result = script.pip("freeze", "--all")
assert "setuptools==" in result.stdout
(script.site_packages_path / "mock.pth").write_text("import mock\n")
(script.site_packages_path / "mock.py").write_text(
textwrap.dedent(
"""\
import pip._internal.commands.freeze as freeze
freeze._should_suppress_build_backends = lambda: False
"""
)
)
result = script.pip("freeze")
assert "setuptools==" in result.stdout
(script.site_packages_path / "mock.py").write_text(
textwrap.dedent(
"""\
import pip._internal.commands.freeze as freeze
freeze._should_suppress_build_backends = lambda: True
"""
)
)
result = script.pip("freeze")
assert "setuptools==" not in result.stdout
def test_exclude_and_normalization(script: PipTestEnvironment, tmpdir: Path) -> None:
req_path = wheel.make_wheel(name="Normalizable_Name", version="1.0").save_to_dir(
tmpdir
......
......@@ -66,7 +66,7 @@ def test_rev_options_repr() -> None:
# First check VCS-specific RevOptions behavior.
(Bazaar, [], ["-r", "123"], {}),
(Git, ["HEAD"], ["123"], {}),
(Mercurial, [], ["123"], {}),
(Mercurial, [], ["-r", "123"], {}),
(Subversion, [], ["-r", "123"], {}),
# Test extra_args. For this, test using a single VersionControl class.
(
......