Skip to content

Commit bd2b13d

Browse files
authored
Exclude in-repo python from pexes (#218)
* add test * Handle it * version
1 parent c538303 commit bd2b13d

File tree

5 files changed

+31
-1
lines changed

5 files changed

+31
-1
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Version 1.10.1
2+
--------------
3+
* Exclude in-repo interpreters from collection for pexes during remote execution (#218)
4+
15
Version 1.10.0
26
--------------
37
* Support in-repo interpreters for tests & add a default shebang (#194)

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.10.0
1+
1.10.1

build_defs/python.build_defs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ def python_library(name:str, srcs:list=[], resources:list=[], deps:list=[], visi
5252
cmd = ' && '.join([compile_cmd, 'rm -f $SRCS_SRCS', cmd])
5353
else:
5454
cmd = ' && '.join([compile_cmd, cmd])
55+
if looks_like_build_label(interpreter) and ('|' in interpreter):
56+
before, _, _ = interpreter.partition('|')
57+
cmd += f' --exclude_tools="$(location {before})"'
5558
# Pre-zip the files for later collection by python_binary.
5659
zip_rule = build_rule(
5760
name=name,

test/BUILD

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,8 @@ python_test(
180180
name = "ci_test",
181181
srcs = ["ci_test.py"],
182182
)
183+
184+
python_test(
185+
name = "interpreter_not_included_test",
186+
srcs = ["interpreter_not_included_test.py"],
187+
)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import sys
2+
import unittest
3+
import zipfile
4+
5+
6+
class InterpreterNotIncludedTest(unittest.TestCase):
7+
8+
def test_interpreter_is_not_included(self):
9+
"""Test that we don't include the interpreter as a tool."""
10+
zf = zipfile.ZipFile(sys.argv[0])
11+
names = [name for name in zf.namelist() if "third_party/cpython/lib" in name]
12+
self.assertFalse(names)
13+
14+
def test_arcat_is_not_included(self):
15+
"""Test that arcat isn't included either."""
16+
zf = zipfile.ZipFile(sys.argv[0])
17+
names = [name for name in zf.namelist() if "arcat" in name]
18+
self.assertFalse(names)

0 commit comments

Comments
 (0)