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 pex3 lock subset. #2684

Merged
merged 3 commits into from
Feb 15, 2025
Merged

Fix pex3 lock subset. #2684

merged 3 commits into from
Feb 15, 2025

Conversation

jsirois
Copy link
Member

@jsirois jsirois commented Feb 14, 2025

Lock subsetting could crash previously. Also fix
pex3 lock {create,sync,update} --elide-unused-requires-dist, which
would not crash, but would fail to elide some dists.

Fixes #2683

Lock subsetting could crash previously. Also fix
`pex3 lock {create,sync,update} --elide-unused-requires-dist`, which
would not crash, but would fail to elide some dists.

Fixes pex-tool#2683
Comment on lines +55 to +92
python_full_versions = (
list(iter_compatible_versions(requires_python)) if requires_python else []
)
python_versions = OrderedSet(
python_full_version[:2] for python_full_version in python_full_versions
)

os_names = []
platform_systems = []
sys_platforms = []
for target_system in target_systems:
if target_system is TargetSystem.LINUX:
os_names.append("posix")
platform_systems.append("Linux")
sys_platforms.append("linux")
sys_platforms.append("linux2")
elif target_system is TargetSystem.MAC:
os_names.append("posix")
platform_systems.append("Darwin")
sys_platforms.append("darwin")
elif target_system is TargetSystem.WINDOWS:
os_names.append("nt")
platform_systems.append("Windows")
sys_platforms.append("win32")

return cls(
extras=frozenset(ProjectName(extra) for extra in (extras or [""])),
os_names=frozenset(os_names),
platform_systems=frozenset(platform_systems),
sys_platforms=frozenset(sys_platforms),
python_versions=frozenset(
Version(".".join(map(str, python_version))) for python_version in python_versions
),
python_full_versions=frozenset(
Version(".".join(map(str, python_full_version)))
for python_full_version in python_full_versions
),
)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This expansion from extras to include os_names, platform_systems, sys_platforms, python_versions and python_full_versions plugs the holes for --style universal locks where these markers are faked. As noted here: #2647 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@huonw I just added you FYI since you reviewed the initial feature add. Although it does not appear Pants uses this yet, a Pants user has done so on their own uncovering this huge hole. I'm going to proceed with a release to get @lecardozo the fix.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the FYI! And for fixing the bugs!

@jsirois jsirois merged commit 6ab5393 into pex-tool:main Feb 15, 2025
24 checks passed
@jsirois jsirois deleted the issues/2683 branch February 15, 2025 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants