Skip to content

Commit

Permalink
Encapsulate LockConfiguration extraction from locks.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirois committed Nov 26, 2024
1 parent cbc9fb4 commit f6fed6e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
8 changes: 1 addition & 7 deletions pex/resolve/lock_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
DownloadableArtifact,
FileArtifact,
LocalProjectArtifact,
LockConfiguration,
VCSArtifact,
)
from pex.resolve.lockfile.download_manager import DownloadedArtifact, DownloadManager
Expand Down Expand Up @@ -233,12 +232,7 @@ def create(
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,
lock_build_systems=lock.lock_build_systems,
),
lock_configuration=lock.lock_configuration(),
target=target,
package_index_configuration=PackageIndexConfiguration.create(
pip_version=pip_version,
Expand Down
16 changes: 15 additions & 1 deletion pex/resolve/lockfile/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@
from pex.pep_503 import ProjectName
from pex.pip.version import PipVersion, PipVersionValue
from pex.requirements import LocalProjectRequirement
from pex.resolve.locked_resolve import LocalProjectArtifact, LockedResolve, LockStyle, TargetSystem
from pex.resolve.locked_resolve import (
LocalProjectArtifact,
LockConfiguration,
LockedResolve,
LockStyle,
TargetSystem,
)
from pex.resolve.resolved_requirement import Pin
from pex.resolve.resolver_configuration import BuildConfiguration, ResolverVersion
from pex.sorted_tuple import SortedTuple
Expand Down Expand Up @@ -149,6 +155,14 @@ def extract_requirement(req):
local_project_requirement_mapping = attr.ib(eq=False) # type: Mapping[str, Requirement]
source = attr.ib(default=None, eq=False) # type: Optional[str]

def lock_configuration(self):
return LockConfiguration(
style=self.style,
requires_python=self.requires_python,
target_systems=self.target_systems,
lock_build_systems=self.lock_build_systems,
)

def build_configuration(self):
# type: () -> BuildConfiguration
return BuildConfiguration.create(
Expand Down
7 changes: 1 addition & 6 deletions pex/resolve/lockfile/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,12 +661,7 @@ def create(
):
# type: (...) -> LockUpdater

lock_configuration = LockConfiguration(
style=lock_file.style,
requires_python=lock_file.requires_python,
target_systems=lock_file.target_systems,
lock_build_systems=lock_file.lock_build_systems,
)
lock_configuration = lock_file.lock_configuration()
pip_configuration = PipConfiguration(
version=lock_file.pip_version,
resolver_version=lock_file.resolver_version,
Expand Down

0 comments on commit f6fed6e

Please sign in to comment.