diff --git a/a0e34e9cf707c542783b25a9d129982d6e0e195d.patch b/a0e34e9cf707c542783b25a9d129982d6e0e195d.patch new file mode 100644 index 0000000000000000000000000000000000000000..99b89838b9e588d4f8f743beee2746e14a5489c8 --- /dev/null +++ b/a0e34e9cf707c542783b25a9d129982d6e0e195d.patch @@ -0,0 +1,194 @@ +diff --git a/news/4256.feature.rst b/news/4256.feature.rst +new file mode 100644 +index 0000000000..03d7c95d77 +--- /dev/null ++++ b/news/4256.feature.rst +@@ -0,0 +1 @@ ++Add ``--exclude`` option to ``pip freeze`` and ``pip list`` commands to explicitly exclude packages from the output. +diff --git a/news/4256.removal.rst b/news/4256.removal.rst +new file mode 100644 +index 0000000000..6d560b7bba +--- /dev/null ++++ b/news/4256.removal.rst +@@ -0,0 +1,2 @@ ++``pip freeze`` will stop filtering the ``pip``, ``setuptools``, ``distribute`` and ``wheel`` packages from ``pip freeze`` output in a future version. ++To keep the previous behavior, users should use the new ``--exclude`` option. +diff --git a/src/pip/_internal/cli/cmdoptions.py b/src/pip/_internal/cli/cmdoptions.py +index ec4df3fcc7..6a6634fb8b 100644 +--- a/src/pip/_internal/cli/cmdoptions.py ++++ b/src/pip/_internal/cli/cmdoptions.py +@@ -20,6 +20,8 @@ + from optparse import SUPPRESS_HELP, Option, OptionGroup + from textwrap import dedent + ++from pip._vendor.packaging.utils import canonicalize_name ++ + from pip._internal.cli.progress_bars import BAR_TYPES + from pip._internal.exceptions import CommandError + from pip._internal.locations import USER_CACHE_DIR, get_src_prefix +@@ -133,9 +135,15 @@ def _path_option_check(option, opt, value): + return os.path.expanduser(value) + + ++def _package_name_option_check(option, opt, value): ++ # type: (Option, str, str) -> str ++ return canonicalize_name(value) ++ ++ + class PipOption(Option): +- TYPES = Option.TYPES + ("path",) ++ TYPES = Option.TYPES + ("path", "package_name") + TYPE_CHECKER = Option.TYPE_CHECKER.copy() ++ TYPE_CHECKER["package_name"] = _package_name_option_check + TYPE_CHECKER["path"] = _path_option_check + + +@@ -866,6 +874,17 @@ def check_list_path_option(options): + ) + + ++list_exclude = partial( ++ PipOption, ++ '--exclude', ++ dest='excludes', ++ action='append', ++ metavar='package', ++ type='package_name', ++ help="Exclude specified package from the output", ++) # type: Callable[..., Option] ++ ++ + no_python_version_warning = partial( + Option, + '--no-python-version-warning', +diff --git a/src/pip/_internal/commands/freeze.py b/src/pip/_internal/commands/freeze.py +index 20084a4981..4d1ce69a12 100644 +--- a/src/pip/_internal/commands/freeze.py ++++ b/src/pip/_internal/commands/freeze.py +@@ -74,6 +74,7 @@ def add_options(self): + dest='exclude_editable', + action='store_true', + help='Exclude editable package from output.') ++ self.cmd_opts.add_option(cmdoptions.list_exclude()) + + self.parser.insert_option_group(0, self.cmd_opts) + +@@ -85,6 +86,9 @@ def run(self, options, args): + if not options.freeze_all: + skip.update(DEV_PKGS) + ++ if options.excludes: ++ skip.update(options.excludes) ++ + cmdoptions.check_list_path_option(options) + + if options.find_links: +diff --git a/src/pip/_internal/commands/list.py b/src/pip/_internal/commands/list.py +index a6dfa5fd57..27b15d70a5 100644 +--- a/src/pip/_internal/commands/list.py ++++ b/src/pip/_internal/commands/list.py +@@ -12,6 +12,7 @@ + from pip._internal.index.collector import LinkCollector + from pip._internal.index.package_finder import PackageFinder + from pip._internal.models.selection_prefs import SelectionPreferences ++from pip._internal.utils.compat import stdlib_pkgs + from pip._internal.utils.misc import ( + dist_is_editable, + get_installed_distributions, +@@ -114,6 +115,7 @@ def add_options(self): + help='Include editable package from output.', + default=True, + ) ++ self.cmd_opts.add_option(cmdoptions.list_exclude()) + index_opts = cmdoptions.make_option_group( + cmdoptions.index_group, self.parser + ) +@@ -147,12 +149,17 @@ def run(self, options, args): + + cmdoptions.check_list_path_option(options) + ++ skip = set(stdlib_pkgs) ++ if options.excludes: ++ skip.update(options.excludes) ++ + packages = get_installed_distributions( + local_only=options.local, + user_only=options.user, + editables_only=options.editable, + include_editables=options.include_editable, + paths=options.path, ++ skip=skip, + ) + + # get_not_required must be called firstly in order to find and +diff --git a/tests/functional/test_freeze.py b/tests/functional/test_freeze.py +index 74d676aeda..f0a2265f3a 100644 +--- a/tests/functional/test_freeze.py ++++ b/tests/functional/test_freeze.py +@@ -16,6 +16,7 @@ + need_mercurial, + need_svn, + path_to_url, ++ wheel, + ) + + distribute_re = re.compile('^distribute==[0-9.]+\n', re.MULTILINE) +@@ -80,6 +81,25 @@ def test_freeze_with_pip(script): + assert 'pip==' in result.stdout + + ++def test_exclude_and_normalization(script, tmpdir): ++ req_path = wheel.make_wheel( ++ name="Normalizable_Name", version="1.0").save_to_dir(tmpdir) ++ script.pip("install", "--no-index", req_path) ++ result = script.pip("freeze") ++ assert "Normalizable-Name" in result.stdout ++ result = script.pip("freeze", "--exclude", "normalizablE-namE") ++ assert "Normalizable-Name" not in result.stdout ++ ++ ++def test_freeze_multiple_exclude_with_all(script, with_wheel): ++ result = script.pip('freeze', '--all') ++ assert 'pip==' in result.stdout ++ assert 'wheel==' in result.stdout ++ result = script.pip('freeze', '--all', '--exclude', 'pip', '--exclude', 'wheel') ++ assert 'pip==' not in result.stdout ++ assert 'wheel==' not in result.stdout ++ ++ + def test_freeze_with_invalid_names(script): + """ + Test that invalid names produce warnings and are passed over gracefully. +diff --git a/tests/functional/test_list.py b/tests/functional/test_list.py +index 37787246bd..40dfbdea30 100644 +--- a/tests/functional/test_list.py ++++ b/tests/functional/test_list.py +@@ -3,7 +3,7 @@ + + import pytest + +-from tests.lib import create_test_package_with_setup ++from tests.lib import create_test_package_with_setup, wheel + from tests.lib.path import Path + + +@@ -94,6 +94,19 @@ def test_local_columns_flag(simple_script): + assert 'simple 1.0' in result.stdout, str(result) + + ++def test_multiple_exclude_and_normalization(script, tmpdir): ++ req_path = wheel.make_wheel( ++ name="Normalizable_Name", version="1.0").save_to_dir(tmpdir) ++ script.pip("install", "--no-index", req_path) ++ result = script.pip("list") ++ print(result.stdout) ++ assert "Normalizable-Name" in result.stdout ++ assert "pip" in result.stdout ++ result = script.pip("list", "--exclude", "normalizablE-namE", "--exclude", "pIp") ++ assert "Normalizable-Name" not in result.stdout ++ assert "pip" not in result.stdout ++ ++ + @pytest.mark.network + @pytest.mark.incompatible_with_test_venv + def test_user_flag(script, data): diff --git a/python-pip.spec b/python-pip.spec index 05f810a986da3034c3f240b38e74be80b2c67322..bf24e90c3881013bd97ccce2977120c1d7ef4d1c 100644 --- a/python-pip.spec +++ b/python-pip.spec @@ -7,7 +7,7 @@ pip is the package installer for Python. You can use pip to install packages fro %global bashcompdir %(b=$(pkg-config --variable=completionsdir bash-completion 2>/dev/null); echo ${b:-%{_sysconfdir}/bash_completion.d}) Name: python-%{srcname} Version: 20.2.2 -Release: 2 +Release: 3 Summary: A tool for installing and managing Python packages License: MIT and Python and ASL 2.0 and BSD and ISC and LGPLv2 and MPLv2.0 and (ASL 2.0 or BSD) URL: http://www.pip-installer.org @@ -17,6 +17,7 @@ Patch1: allow-stripping-given-prefix-from-wheel-RECORD-files.patch Patch2: emit-a-warning-when-running-with-root-privileges.patch Patch3: remove-existing-dist-only-if-path-conflicts.patch Patch6000: dummy-certifi.patch +Patch6001: a0e34e9cf707c542783b25a9d129982d6e0e195d.patch Source10: pip-allow-older-versions.patch %description %{_description} @@ -140,6 +141,9 @@ install -p dist/%{python_wheelname} -t %{buildroot}%{python_wheeldir} %{python_wheeldir}/%{python_wheelname} %changelog +* 20201031183007637838 patch-tracking 20.2.2-3 +- append patch file of upstream repository from to + * Tue Sep 1 2020 wenzhanli - 20.2.2-2 - add pip-allow-older-versions.patch @@ -183,4 +187,4 @@ install -p dist/%{python_wheelname} -t %{buildroot}%{python_wheeldir} - DESC: Synchronize a patch * Mon Sep 23 2019 openEuler Buildteam - 18.0-6 -- Package init +- Package init \ No newline at end of file