Skip to content

Commit

Permalink
Merge branch 'main' into feature/base-prefix-config
Browse files Browse the repository at this point in the history
  • Loading branch information
uranusjr authored Nov 25, 2022
2 parents 81d6053 + 1ab22ee commit 8d34a11
Show file tree
Hide file tree
Showing 17 changed files with 36 additions and 57 deletions.
2 changes: 1 addition & 1 deletion NEWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Bug Fixes
- Ensure that the candidate ``pip`` executable exists, when checking for a new version of pip. (`#11309 <https://github.com/pypa/pip/issues/11309>`_)
- Ignore distributions with invalid ``Name`` in metadata instead of crashing, when
using the ``importlib.metadata`` backend. (`#11352 <https://github.com/pypa/pip/issues/11352>`_)
- Raise RequirementsFileParseError when parsing malformed requirements options that can't be sucessfully parsed by shlex. (`#11491 <https://github.com/pypa/pip/issues/11491>`_)
- Raise RequirementsFileParseError when parsing malformed requirements options that can't be successfully parsed by shlex. (`#11491 <https://github.com/pypa/pip/issues/11491>`_)
- Fix build environment isolation on some system Pythons. (`#6264 <https://github.com/pypa/pip/issues/6264>`_)

Vendored Libraries
Expand Down
6 changes: 3 additions & 3 deletions docs/html/cli/pip_download.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Examples
#. Download a package and all of its dependencies with OSX specific interpreter constraints.
This forces OSX 10.10 or lower compatibility. Since OSX deps are forward compatible,
this will also match ``macosx-10_9_x86_64``, ``macosx-10_8_x86_64``, ``macosx-10_8_intel``,
this will also match ``macosx_10_9_x86_64``, ``macosx_10_8_x86_64``, ``macosx_10_8_intel``,
etc.
It will also match deps with platform ``any``. Also force the interpreter version to ``27``
(or more generic, i.e. ``2``) and implementation to ``cp`` (or more generic, i.e. ``py``).
Expand All @@ -92,7 +92,7 @@ Examples
python -m pip download \
--only-binary=:all: \
--platform macosx-10_10_x86_64 \
--platform macosx_10_10_x86_64 \
--python-version 27 \
--implementation cp \
SomePackage
Expand All @@ -103,7 +103,7 @@ Examples
py -m pip download ^
--only-binary=:all: ^
--platform macosx-10_10_x86_64 ^
--platform macosx_10_10_x86_64 ^
--python-version 27 ^
--implementation cp ^
SomePackage
Expand Down
2 changes: 1 addition & 1 deletion docs/html/development/release-process.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ to need extra work before being released, the release manager always has the
option to back out the partial change prior to a release. The PR can then be
reworked and resubmitted for the next release.

Vendoring updates will be picked up fron the ``main`` branch, as for any other
Vendoring updates will be picked up from the ``main`` branch, as for any other
update. Ideally, vendoring updates should be merged between releases, just like
any other change. If there are outstanding updates to vendored packages, the
release manager *may* at their discretion choose to do a vendoring update
Expand Down
2 changes: 1 addition & 1 deletion docs/html/reference/installation-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ package with the following properties:
```

- `requested`: `true` if the requirement was explicitly provided by the user, either
directely via a command line argument or indirectly via a requirements file. `false`
directly via a command line argument or indirectly via a requirements file. `false`
if the requirement was installed as a dependency of another requirement.

- `requested_extras`: extras requested by the user. This field is only present when the
Expand Down
1 change: 1 addition & 0 deletions news/11598.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use the "venv" scheme if available to obtain prefixed lib paths.
Empty file.
Empty file.
8 changes: 6 additions & 2 deletions src/pip/_internal/build_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@

from pip import __file__ as pip_location
from pip._internal.cli.spinners import open_spinner
from pip._internal.locations import get_platlib, get_prefixed_libs, get_purelib
from pip._internal.locations import (
get_isolated_environment_lib_paths,
get_platlib,
get_purelib,
)
from pip._internal.metadata import get_default_environment, get_environment
from pip._internal.utils.subprocess import call_subprocess
from pip._internal.utils.temp_dir import TempDirectory, tempdir_kinds
Expand All @@ -37,7 +41,7 @@ def __init__(self, path: str) -> None:
"nt" if os.name == "nt" else "posix_prefix",
vars={"base": path, "platbase": path},
)["scripts"]
self.lib_dirs = get_prefixed_libs(path)
self.lib_dirs = get_isolated_environment_lib_paths(path)


def get_runnable_pip() -> str:
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/index/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def _get_index_content(link: Link, *, session: PipSession) -> Optional["IndexCon
if not url.endswith("/"):
url += "/"
# TODO: In the future, it would be nice if pip supported PEP 691
# style respones in the file:// URLs, however there's no
# style responses in the file:// URLs, however there's no
# standard file extension for application/vnd.pypi.simple.v1+json
# so we'll need to come up with something on our own.
url = urllib.parse.urljoin(url, "index.html")
Expand Down
8 changes: 4 additions & 4 deletions src/pip/_internal/locations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"get_bin_user",
"get_major_minor_version",
"get_platlib",
"get_prefixed_libs",
"get_isolated_environment_lib_paths",
"get_purelib",
"get_scheme",
"get_src_prefix",
Expand Down Expand Up @@ -482,13 +482,13 @@ def _looks_like_apple_library(path: str) -> bool:
return path == f"/Library/Python/{get_major_minor_version()}/site-packages"


def get_prefixed_libs(prefix: str) -> List[str]:
def get_isolated_environment_lib_paths(prefix: str) -> List[str]:
"""Return the lib locations under ``prefix``."""
new_pure, new_plat = _sysconfig.get_prefixed_libs(prefix)
new_pure, new_plat = _sysconfig.get_isolated_environment_lib_paths(prefix)
if _USE_SYSCONFIG:
return _deduplicated(new_pure, new_plat)

old_pure, old_plat = _distutils.get_prefixed_libs(prefix)
old_pure, old_plat = _distutils.get_isolated_environment_lib_paths(prefix)
old_lib_paths = _deduplicated(old_pure, old_plat)

# Apple's Python (shipped with Xcode and Command Line Tools) hard-code
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/locations/_distutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def get_platlib() -> str:
return get_python_lib(plat_specific=True)


def get_prefixed_libs(prefix: str) -> Tuple[str, str]:
def get_isolated_environment_lib_paths(prefix: str) -> Tuple[str, str]:
return (
get_python_lib(plat_specific=False, prefix=prefix),
get_python_lib(plat_specific=True, prefix=prefix),
Expand Down
8 changes: 6 additions & 2 deletions src/pip/_internal/locations/_sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ def get_platlib() -> str:
return sysconfig.get_paths()["platlib"]


def get_prefixed_libs(prefix: str) -> typing.Tuple[str, str]:
paths = sysconfig.get_paths(vars={"base": prefix, "platbase": prefix})
def get_isolated_environment_lib_paths(prefix: str) -> typing.Tuple[str, str]:
vars = {"base": prefix, "platbase": prefix}
if "venv" in sysconfig.get_scheme_names():
paths = sysconfig.get_paths(vars=vars, scheme="venv")
else:
paths = sysconfig.get_paths(vars=vars)
return (paths["purelib"], paths["platlib"])
4 changes: 2 additions & 2 deletions src/pip/_internal/network/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def save_auth_info(self, url: str, username: str, password: str) -> None:
return self._set_password(url, username, password)

def _get_password(self, service_name: str, username: str) -> Optional[str]:
"""Mirror the implemenation of keyring.get_password using cli"""
"""Mirror the implementation of keyring.get_password using cli"""
if self.keyring is None:
return None

Expand All @@ -131,7 +131,7 @@ def _get_password(self, service_name: str, username: str) -> Optional[str]:
return res.stdout.decode("utf-8").strip("\n")

def _set_password(self, service_name: str, username: str, password: str) -> None:
"""Mirror the implemenation of keyring.set_password using cli"""
"""Mirror the implementation of keyring.set_password using cli"""
if self.keyring is None:
return None

Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/vcs/bazaar.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def update(self, dest: str, url: HiddenText, rev_options: RevOptions) -> None:

@classmethod
def get_url_rev_and_auth(cls, url: str) -> Tuple[str, Optional[str], AuthInfo]:
# hotfix the URL scheme after removing bzr+ from bzr+ssh:// readd it
# hotfix the URL scheme after removing bzr+ from bzr+ssh:// re-add it
url, rev, user_pass = super().get_url_rev_and_auth(url)
if url.startswith("ssh://"):
url = "bzr+" + url
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/vcs/subversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def get_netloc_and_auth(

@classmethod
def get_url_rev_and_auth(cls, url: str) -> Tuple[str, Optional[str], AuthInfo]:
# hotfix the URL scheme after removing svn+ from svn+ssh:// readd it
# hotfix the URL scheme after removing svn+ from svn+ssh:// re-add it
url, rev, user_pass = super().get_url_rev_and_auth(url)
if url.startswith("ssh://"):
url = "svn+" + url
Expand Down
38 changes: 4 additions & 34 deletions tests/functional/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -1145,39 +1145,6 @@ def main(): pass
assert "--no-warn-script-location" not in result.stderr, str(result)


def _change_root(new_root: str, pathname: str) -> str:
"""
Adapted from distutils.
Return 'pathname' with 'new_root' prepended. If 'pathname' is
relative, this is equivalent to "os.path.join(new_root,pathname)".
Otherwise, it requires making 'pathname' relative and then joining the
two, which is tricky on DOS/Windows and Mac OS.
"""
try:
from distutils.util import change_root
except ImportError:
pass
else:
return change_root(new_root, pathname)

if os.name == "posix":
if not os.path.isabs(pathname):
return os.path.join(new_root, pathname)
else:
return os.path.join(new_root, pathname[1:])

elif os.name == "nt":
drive, path = os.path.splitdrive(pathname)
if path[0] == "\\":
path = path[1:]
return os.path.join(new_root, path)

else:
# distutils raise DistutilsPlatformError here
raise RuntimeError(f"nothing known about platform '{os.name}'")


@pytest.mark.usefixtures("with_wheel")
def test_install_package_with_root(script: PipTestEnvironment, data: TestData) -> None:
"""
Expand All @@ -1196,8 +1163,11 @@ def test_install_package_with_root(script: PipTestEnvironment, data: TestData) -
normal_install_path = os.fspath(
script.base_path / script.site_packages / "simple-1.0.dist-info"
)
# use a function borrowed from distutils
# to change the root exactly how the --root option does it
from pip._internal.locations.base import change_root

root_path = _change_root(os.path.join(script.scratch, "root"), normal_install_path)
root_path = change_root(os.path.join(script.scratch, "root"), normal_install_path)
result.did_create(root_path)

# Should show find-links location in output
Expand Down
6 changes: 3 additions & 3 deletions tests/functional/test_install_vcs_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def _make_version_pkg_url(
Return a "git+file://" URL to the version_pkg test package.
Args:
path: a tests.lib.path.Path object pointing to a Git repository
path: a pathlib.Path object pointing to a Git repository
containing the version_pkg package.
rev: an optional revision to install like a branch name, tag, or SHA.
"""
Expand All @@ -101,7 +101,7 @@ def _install_version_pkg_only(
the version).
Args:
path: a tests.lib.path.Path object pointing to a Git repository
path: a pathlib.Path object pointing to a Git repository
containing the package.
rev: an optional revision to install like a branch name or tag.
"""
Expand All @@ -122,7 +122,7 @@ def _install_version_pkg(
installed.
Args:
path: a tests.lib.path.Path object pointing to a Git repository
path: a pathlib.Path object pointing to a Git repository
containing the package.
rev: an optional revision to install like a branch name or tag.
"""
Expand Down

0 comments on commit 8d34a11

Please sign in to comment.