Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for Pip 23.1.1. #2133

Merged
merged 3 commits into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
pip-version: 22_3_1
- os: ubuntu-20.04
python-version: [ 3, 11 ]
pip-version: 23_1
pip-version: 23_1_1
steps:
- name: Calculate Pythons to Expose
id: calculate-pythons-to-expose
Expand Down Expand Up @@ -111,7 +111,7 @@ jobs:
- pypy-version: [ 3, 9 ]
pip-version: 22_3_1
- pypy-version: [ 3, 9 ]
pip-version: 23_1
pip-version: 23_1_1
steps:
- name: Calculate Pythons to Expose
id: calculate-pythons-to-expose
Expand Down Expand Up @@ -158,7 +158,7 @@ jobs:
pip-version: 22_3_1
- os: ubuntu-20.04
python-version: [ 3, 7 ]
pip-version: 23_1
pip-version: 23_1_1
- os: macos-11
python-version: [ 3, 11 ]
pip-version: 20
Expand All @@ -170,7 +170,7 @@ jobs:
pip-version: 22_3_1
- os: ubuntu-20.04
python-version: [ 3, 11 ]
pip-version: 23_1
pip-version: 23_1_1
steps:
- name: Calculate Pythons to Expose
id: calculate-pythons-to-expose
Expand Down Expand Up @@ -223,7 +223,7 @@ jobs:
- pypy-version: [ 3, 9 ]
pip-version: 22_3_1
- pypy-version: [ 3, 9 ]
pip-version: 23_1
pip-version: 23_1_1
steps:
- name: Calculate Pythons to Expose
id: calculate-pythons-to-expose
Expand Down
15 changes: 11 additions & 4 deletions pex/compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ def exec_function(ast, globals_map):
if PY3:
from urllib import parse as urlparse
from urllib.error import HTTPError as HTTPError
from urllib.parse import unquote as unquote
from urllib.parse import quote as _url_quote
from urllib.parse import unquote as _url_unquote
from urllib.request import FileHandler as FileHandler
from urllib.request import HTTPBasicAuthHandler as HTTPBasicAuthHandler
from urllib.request import HTTPDigestAuthHandler as HTTPDigestAuthHandler
Expand All @@ -131,7 +132,8 @@ def exec_function(ast, globals_map):
from urllib.request import Request as Request
from urllib.request import build_opener as build_opener
else:
from urllib import unquote as unquote
from urllib import quote as _url_quote
from urllib import unquote as _url_unquote

import urlparse as urlparse
from urllib2 import FileHandler as FileHandler
Expand All @@ -144,6 +146,9 @@ def exec_function(ast, globals_map):
from urllib2 import Request as Request
from urllib2 import build_opener as build_opener

url_unquote = _url_unquote
url_quote = _url_quote

if PY3:
from queue import Queue as Queue

Expand Down Expand Up @@ -262,6 +267,8 @@ def append(piece):


if PY3:
from shlex import quote as quote
from shlex import quote as _shlex_quote
else:
from pipes import quote as quote
from pipes import quote as _shlex_quote

shlex_quote = _shlex_quote
9 changes: 5 additions & 4 deletions pex/pip/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pex import dist_metadata, targets
from pex.auth import PasswordEntry
from pex.common import safe_mkdir, safe_mkdtemp
from pex.compatibility import get_stderr_bytes_buffer, quote, urlparse
from pex.compatibility import get_stderr_bytes_buffer, shlex_quote, urlparse
from pex.interpreter import PythonInterpreter
from pex.jobs import Job
from pex.network_configuration import NetworkConfiguration
Expand Down Expand Up @@ -44,7 +44,6 @@
Mapping,
Optional,
Sequence,
Text,
Tuple,
)

Expand Down Expand Up @@ -353,8 +352,10 @@ def _spawn_pip_isolated(

args = self._pip_pex.execute_args(*command)

rendered_env = " ".join("{}={}".format(key, quote(value)) for key, value in env.items())
rendered_args = " ".join(quote(s) for s in args)
rendered_env = " ".join(
"{}={}".format(key, shlex_quote(value)) for key, value in env.items()
)
rendered_args = " ".join(shlex_quote(s) for s in args)
TRACER.log("Executing: {} {}".format(rendered_env, rendered_args), V=3)

return args, subprocess.Popen(args=args, env=env, **popen_kwargs)
Expand Down
7 changes: 7 additions & 0 deletions pex/pip/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,12 @@ def values(cls):
requires_python=">=3.7",
)

v23_1_1 = PipVersionValue(
version="23.1.1",
setuptools_version="67.7.1",
wheel_version="0.40.0",
requires_python=">=3.7",
)

VENDORED = v20_3_4_patched
LATEST = LatestPipVersion()
4 changes: 2 additions & 2 deletions pex/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from contextlib import contextmanager

from pex import attrs, dist_metadata, pex_warnings
from pex.compatibility import unquote, urlparse
from pex.compatibility import url_unquote, urlparse
from pex.dist_metadata import (
MetadataError,
ProjectNameAndVersion,
Expand Down Expand Up @@ -485,7 +485,7 @@ def _parse_requirement_line(
project_name_and_specifier = _try_parse_project_name_and_specifier_from_path(
# There may be whitespace separated markers; so we strip the trailing whitespace
# used to support those.
unquote(parsed_url.path).rstrip()
url_unquote(parsed_url.path).rstrip()
)
if project_name_and_specifier is not None:
project_name = project_name_and_specifier.project_name
Expand Down
9 changes: 6 additions & 3 deletions pex/resolve/downloads.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

from __future__ import absolute_import

import os.path
Expand All @@ -6,7 +9,7 @@
from pex import hashing
from pex.atomic_directory import atomic_directory
from pex.common import safe_mkdir, safe_mkdtemp
from pex.compatibility import unquote, urlparse
from pex.compatibility import url_unquote, urlparse
from pex.hashing import Sha256
from pex.jobs import Job, Raise, SpawnedJob, execute_parallel
from pex.pip.download_observer import DownloadObserver
Expand Down Expand Up @@ -126,7 +129,7 @@ def _download_and_fingerprint(self, url):
download_dir = safe_mkdtemp(prefix="fingerprint_artifact.", dir=downloads)

url_info = urlparse.urlparse(url)
src_file = urlparse.unquote(url_info.path)
src_file = url_unquote(url_info.path)
temp_dest = os.path.join(download_dir, os.path.basename(src_file))

if url_info.scheme == "file":
Expand Down Expand Up @@ -173,7 +176,7 @@ def download(

url_info = urlparse.urlparse(artifact.url)
if url_info.scheme == "file":
src_file = unquote(url_info.path)
src_file = url_unquote(url_info.path)
try:
shutil.copy(src_file, dest_file)
except (IOError, OSError) as e:
Expand Down
2 changes: 1 addition & 1 deletion pex/resolve/locked_resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from collections import OrderedDict, defaultdict, deque

from pex.common import pluralize
from pex.compatibility import unquote, urlparse
from pex.compatibility import url_unquote, urlparse
from pex.dist_metadata import DistMetadata, Requirement
from pex.enum import Enum
from pex.orderedset import OrderedSet
Expand Down
4 changes: 2 additions & 2 deletions pex/resolve/resolved_requirement.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import hashlib

from pex import hashing
from pex.compatibility import unquote, urlparse
from pex.compatibility import url_unquote, urlparse
from pex.dist_metadata import ProjectNameAndVersion, Requirement
from pex.hashing import HashlibHasher
from pex.pep_440 import Version
Expand Down Expand Up @@ -88,7 +88,7 @@ def parse(cls, url):
raw_url=url,
normalized_url=normalized_url,
scheme=parse_scheme(url_info.scheme) if url_info.scheme else None,
path=unquote(url_info.path),
path=url_unquote(url_info.path),
)

raw_url = attr.ib(eq=False) # type: str
Expand Down
4 changes: 2 additions & 2 deletions pex/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from pex.atomic_directory import AtomicDirectory, atomic_directory
from pex.auth import PasswordEntry
from pex.common import safe_mkdir, safe_mkdtemp
from pex.compatibility import unquote, urlparse
from pex.compatibility import url_unquote, urlparse
from pex.dist_metadata import DistMetadata, Distribution, ProjectNameAndVersion, Requirement
from pex.fingerprinted_distribution import FingerprintedDistribution
from pex.jobs import Raise, SpawnedJob, execute_parallel
Expand Down Expand Up @@ -711,7 +711,7 @@ def _resolve_direct_file_deps(
urlinfo = urlparse.urlparse(requirement.url)
if urlinfo.scheme != "file":
continue
dist_path = unquote(urlinfo.path).rstrip()
dist_path = url_unquote(urlinfo.path).rstrip()
if not os.path.exists(dist_path):
raise Unsatisfiable(
"The {wheel} wheel has a dependency on {url} which does not exist on this "
Expand Down
19 changes: 16 additions & 3 deletions tests/integration/test_issue_1730.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import pytest

from pex.compatibility import url_quote
from pex.testing import IS_PYPY, PY_VER, run_pex_command
from pex.typing import TYPE_CHECKING

Expand All @@ -28,13 +29,25 @@ def test_check_install_issue_1730(
with open(constraints, "w") as fp:
print("packaging==21.3", file=fp)

# The PyPI-hosted version of Pants 2.13.0.dev3 was deleted to make space available; so we use
# the Pants S3 bucket instead.
pants_hosted_version = "2.12.0.dev3+git552439fc"
find_links = (
"https://binaries.pantsbuild.org/wheels/pantsbuild.pants/"
"552439fc4500284f97d09461d8f9a89df1ac1676/"
"{pants_hosted_version}/"
"index.html"
).format(pants_hosted_version=url_quote(pants_hosted_version))

pex_args = [
"--pex-root",
pex_root,
"--runtime-pex-root",
pex_root,
"--constraints",
constraints,
"-f",
find_links,
"pantsbuild.pants.testutil==2.12.0.dev3",
"--",
"-c",
Expand All @@ -45,9 +58,9 @@ def test_check_install_issue_1730(
old_result.assert_failure()
assert (
"Failed to resolve compatible distributions:\n"
"1: pantsbuild.pants.testutil==2.12.0.dev3 requires pantsbuild.pants==2.12.0.dev3 but "
"pantsbuild.pants 2.12.0.dev3 was resolved" in old_result.error
), old_result.error
"1: pantsbuild.pants.testutil=={version} requires pantsbuild.pants=={version} but "
"pantsbuild.pants {version} was resolved"
).format(version=pants_hosted_version) in old_result.error, old_result.error

new_result = run_pex_command(args=pex_args, quiet=True)
new_result.assert_success()
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ setenv =
pip23_0: _PEX_PIP_VERSION=23.0
pip23_0_1: _PEX_PIP_VERSION=23.0.1
pip23_1: _PEX_PIP_VERSION=23.1
pip23_1_1: _PEX_PIP_VERSION=23.1.1
# Python 3 (until a fix here in 3.9: https://bugs.python.org/issue13601) switched from stderr
# being unbuffered to stderr being buffered by default. This can lead to tests checking stderr
# failing to see what they expect if the stderr buffer block has not been flushed. Force stderr
Expand All @@ -66,7 +67,7 @@ whitelist_externals =
bash
git

[testenv:py{py27-subprocess,py27,py35,py36,py37,py38,py39,27,35,36,37,38,39,310,311}-{,pip20-,pip22_2-,pip22_3-,pip22_3_1-,pip23_0-,pip23_0_1-,pip23_1-}integration]
[testenv:py{py27-subprocess,py27,py35,py36,py37,py38,py39,27,35,36,37,38,39,310,311}-{,pip20-,pip22_2-,pip22_3-,pip22_3_1-,pip23_0-,pip23_0_1-,pip23_1-,pip23_1_1-}integration]
deps =
pytest-xdist==1.34.0
{[testenv]deps}
Expand Down