Skip to content

Commit fa36b40

Browse files
authored
Fix sdist tar extraction filtering for old Pythons. (#2992)
Fixes #2991
1 parent 561c730 commit fa36b40

File tree

4 files changed

+59
-10
lines changed

4 files changed

+59
-10
lines changed

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Release Notes
22

3+
## 2.68.1
4+
5+
This release fixes a regression extracting sdists on some Pythons older than 3.12.
6+
7+
* Fix sdist tar extraction filtering for old Pythons. (#2992)
8+
39
## 2.68.0
410

511
This release adds support for `--project` pointing to local project sdist or wheel paths in addition

pex/sdist.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def _get_filtered_attrs(
6767
# + `os.path.realpath` -> `_realpath` to deal with `strict` parameter.
6868
# + `os.path.commonpath` -> `pex.compatibility.commonpath`
6969
# + `mode = None` guarded by `sys.version_info[:2] >= (3, 12)` with commentary.
70+
# + `{uid,gid,uname,gname} = None` guarded by `sys.version_info[:2] >= (3, 12)` with commentary.
7071

7172
new_attrs = {} # type: Dict[str, Any]
7273
name = member.name
@@ -113,15 +114,20 @@ def _get_filtered_attrs(
113114
if mode != member.mode:
114115
new_attrs["mode"] = mode
115116
if for_data:
116-
# Ignore ownership for 'data'
117-
if member.uid is not None:
118-
new_attrs["uid"] = None
119-
if member.gid is not None:
120-
new_attrs["gid"] = None
121-
if member.uname is not None:
122-
new_attrs["uname"] = None
123-
if member.gname is not None:
124-
new_attrs["gname"] = None
117+
if sys.version_info[:2] >= (3, 12):
118+
# Ignore ownership for 'data'
119+
if member.uid is not None:
120+
new_attrs["uid"] = None
121+
if member.gid is not None:
122+
new_attrs["gid"] = None
123+
if member.uname is not None:
124+
new_attrs["uname"] = None
125+
if member.gname is not None:
126+
new_attrs["gname"] = None
127+
else:
128+
# Retain uid/gid/uname/gname since older Pythons do not support None.
129+
pass
130+
125131
# Check link destination for 'data'
126132
if member.islnk() or member.issym():
127133
if os.path.isabs(member.linkname):

pex/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Copyright 2015 Pex project contributors.
22
# Licensed under the Apache License, Version 2.0 (see LICENSE).
33

4-
__version__ = "2.68.0"
4+
__version__ = "2.68.1"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright 2025 Pex project contributors.
2+
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3+
4+
from __future__ import absolute_import
5+
6+
import subprocess
7+
8+
from testing.docker import skip_unless_docker
9+
from testing.pytest_utils.tmp import Tempdir
10+
11+
12+
@skip_unless_docker
13+
def test_sdist_extraction(
14+
tmpdir, # type: Tempdir
15+
pex_project_dir, # type: str
16+
):
17+
# type: (...) -> None
18+
19+
assert (
20+
b"/root/.cache/pex/installed_wheels/2/"
21+
b"f0e26292130d3efebe48e40b10c5f9e79911ad507ccd2f02aea5793dea67abc0/"
22+
b"pymongo-3.11.4-cp311-cp311-linux_x86_64.whl/pymongo/__init__.py\n"
23+
) == subprocess.check_output(
24+
args=[
25+
"docker",
26+
"run",
27+
"--rm",
28+
"-v",
29+
"{code}:/code".format(code=pex_project_dir),
30+
"-w",
31+
"/code",
32+
"python:3.11.2-slim-bullseye",
33+
"bash",
34+
"-c",
35+
"python -mpex pymongo==3.11.4 -- -c 'import pymongo; print(pymongo.__file__)'",
36+
]
37+
)

0 commit comments

Comments
 (0)