Skip to content

Commit 11b6d5d

Browse files
authored
Do not include ptex in --scie eager scies. (#2717)
This saves ~5MB for eager scies targeting 64 bit systems.
1 parent b16741e commit 11b6d5d

File tree

4 files changed

+57
-17
lines changed

4 files changed

+57
-17
lines changed

CHANGES.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Release Notes
22

3+
## 2.33.4
4+
5+
This release fixes PEX scies to exclude a ptex binary for `--scie eager` scies saving ~5MB on scies
6+
targeting 64 bit systems.
7+
8+
* Do not include `ptex` in `--scie eager` scies. (#2717)
9+
310
## 2.33.3
411

512
This release fixes Pex Zip64 support such that PEX zips do not use Zip64 extensions unless needed.

pex/scie/science.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -212,18 +212,20 @@ def create_cmd(named_entry_point):
212212

213213
lift = {
214214
"name": name,
215-
"ptex": {
216-
"id": Filenames.PTEX.name,
217-
"version": PTEX_VERSION,
218-
"argv1": "{scie.env.PEX_BOOTSTRAP_URLS={scie.lift}}",
219-
},
220215
"scie_jump": {"version": SCIE_JUMP_VERSION},
221216
"files": [
222217
{"name": Filenames.CONFIGURE_BINDING.name},
223218
dict(name=pex_name, is_executable=True, **({"key": pex_key} if pex_key else {})),
224219
],
225220
} # type: Dict[str, Any]
226221

222+
if configuration.options.style is ScieStyle.LAZY:
223+
lift["ptex"] = {
224+
"id": Filenames.PTEX.name,
225+
"version": PTEX_VERSION,
226+
"argv1": "{scie.env.PEX_BOOTSTRAP_URLS={scie.lift}}",
227+
}
228+
227229
configure_binding = {
228230
"env": {
229231
"remove_exact": ["PATH"],

pex/version.py

+1-1
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.33.3"
4+
__version__ = "2.33.4"

tests/integration/scie/test_pex_scie.py

+42-11
Original file line numberDiff line numberDiff line change
@@ -1192,15 +1192,46 @@ def test_scie_split_contents(tmpdir):
11921192
split_dir = tmpdir.join("split")
11931193
subprocess.check_call(args=[scie, split_dir], env=make_env(SCIE="split"))
11941194

1195-
# TODO(John Sirois): When the 1.6.0 scie-jump is released, replace this check with:
1196-
# + Add is_exe(...) check.
1197-
# + Change is_script(...) check below to check_executable=True.
1198-
# + Execute the split PEX directly instead of via sys.executable below.
1199-
with open(os.path.join(split_dir, "lift.json")) as fp:
1200-
assert {file["name"]: file for file in json.load(fp)["scie"]["lift"]["files"]}[
1201-
"cowsay.pex"
1202-
]["executable"]
1203-
12041195
split_pex = os.path.join(split_dir, "cowsay.pex")
1205-
assert is_script(split_pex, check_executable=False)
1206-
assert b"| Moo! |" in subprocess.check_output(args=[sys.executable, split_pex, "Moo!"])
1196+
assert is_exe(split_pex)
1197+
assert is_script(split_pex)
1198+
assert b"| Moo! |" in subprocess.check_output(args=[split_pex, "Moo!"])
1199+
1200+
1201+
@skip_if_no_provider
1202+
def test_scie_eager_no_ptex(tmpdir):
1203+
# type: (Tempdir) -> None
1204+
1205+
def assert_ptex(
1206+
expect_included, # type: bool
1207+
lazy, # type: bool
1208+
):
1209+
# type: (...) -> None
1210+
1211+
run_pex_command(
1212+
args=[
1213+
"cowsay<6",
1214+
"-c",
1215+
"cowsay",
1216+
"-o",
1217+
tmpdir.join("cowsay.pex"),
1218+
"--scie",
1219+
"lazy" if lazy else "eager",
1220+
]
1221+
).assert_success()
1222+
1223+
scie = tmpdir.join("cowsay")
1224+
assert b"| Moo! |" in subprocess.check_output(args=[scie, "Moo!"])
1225+
1226+
output = subprocess.check_output(args=[scie, "-n"], env=make_env(SCIE="split")).decode(
1227+
"utf-8"
1228+
)
1229+
assert "scie-jump" in output, output
1230+
assert "pex" in output, output
1231+
assert "lift.json" in output, output
1232+
1233+
assert (("pypy" if IS_PYPY else "cpython") in output) != lazy, output
1234+
assert ("ptex" in output) == expect_included, output
1235+
1236+
assert_ptex(expect_included=False, lazy=False)
1237+
assert_ptex(expect_included=True, lazy=True)

0 commit comments

Comments
 (0)