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

Fix lock downloads to use all lock info. #2396

Merged
merged 6 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Release Notes

## 2.3.1

This release fixes Pex to respect lock file interpreter constraints and
target systems when downloading artifacts.

* Fix lock downloads to use all lock info. (#2396)

## 2.3.0

This release introduces `pex3 lock sync` as a higher-level tool that
Expand Down
5 changes: 3 additions & 2 deletions pex/resolve/downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from pex.pip.installation import get_pip
from pex.pip.tool import PackageIndexConfiguration, Pip
from pex.resolve import locker
from pex.resolve.locked_resolve import Artifact, FileArtifact, LockConfiguration, LockStyle
from pex.resolve.locked_resolve import Artifact, FileArtifact, LockConfiguration
from pex.resolve.resolved_requirement import ArtifactURL, Fingerprint, PartialArtifact
from pex.resolve.resolvers import Resolver
from pex.result import Error
Expand Down Expand Up @@ -50,6 +50,7 @@ def get_downloads_dir(pex_root=None):
@attr.s(frozen=True)
class ArtifactDownloader(object):
resolver = attr.ib() # type: Resolver
lock_configuration = attr.ib() # type: LockConfiguration
target = attr.ib(factory=LocalInterpreter.create) # type: Target
package_index_configuration = attr.ib(
factory=PackageIndexConfiguration.create
Expand Down Expand Up @@ -113,7 +114,7 @@ def _download(
# restrictions.
download_observer = DownloadObserver(
analyzer=None,
patch_set=locker.patch(lock_configuration=LockConfiguration(style=LockStyle.UNIVERSAL)),
patch_set=locker.patch(lock_configuration=self.lock_configuration),
)
return self.pip.spawn_download_distributions(
download_dir=download_dir,
Expand Down
6 changes: 6 additions & 0 deletions pex/resolve/lock_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
DownloadableArtifact,
FileArtifact,
LocalProjectArtifact,
LockConfiguration,
VCSArtifact,
)
from pex.resolve.lockfile.download_manager import DownloadedArtifact, DownloadManager
Expand Down Expand Up @@ -281,6 +282,11 @@ def resolve_from_lock(
file_lock_style=file_lock_style,
downloader=ArtifactDownloader(
resolver=resolver,
lock_configuration=LockConfiguration(
style=lock.style,
requires_python=lock.requires_python,
target_systems=lock.target_systems,
),
target=resolved_subset.target,
package_index_configuration=PackageIndexConfiguration.create(
pip_version=pip_version,
Expand Down
1 change: 1 addition & 0 deletions pex/resolve/lockfile/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ def lock(self, downloaded):
dist_metadatas=dist_metadatas_by_target[target],
fingerprinter=ArtifactDownloader(
resolver=self.resolver,
lock_configuration=self.lock_configuration,
target=target,
package_index_configuration=self.package_index_configuration,
max_parallel_jobs=self.max_parallel_jobs,
Expand Down
2 changes: 1 addition & 1 deletion pex/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2015 Pex project contributors.
# Licensed under the Apache License, Version 2.0 (see LICENSE).

__version__ = "2.3.0"
__version__ = "2.3.1"
14 changes: 9 additions & 5 deletions testing/cli.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
# Copyright 2022 Pex project contributors.
# Licensed under the Apache License, Version 2.0 (see LICENSE).

from __future__ import absolute_import, division, print_function, unicode_literals
from __future__ import absolute_import

import subprocess
import sys

from pex.typing import TYPE_CHECKING
from pex.compatibility import to_unicode
from pex.typing import TYPE_CHECKING, cast
from testing import IntegResults

if TYPE_CHECKING:
from typing import Text # noqa
from typing import Any


def run_pex3(
*args, # type: str
**popen_kwargs # type: Any
**kwargs # type: Any
):
# type: (...) -> IntegResults

python = cast("Text", kwargs.pop("python", to_unicode(sys.executable)))
process = subprocess.Popen(
args=[sys.executable, "-mpex.cli"] + list(args),
args=[python, "-mpex.cli"] + list(args),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
**popen_kwargs
**kwargs
)
stdout, stderr = process.communicate()
return IntegResults(
Expand Down
Loading
Loading