Skip to content

Commit 0d220da

Browse files
committed
Perform pip install as part of bootstrap.py
Also, install pip packages in local `out/python_deps` directory instead of installing system wide. This means that only python scripts that explicitly add `out/python_deps` to their python path will be able use the packages, and in particular it means that the emscripten compiler itself won't end up implicitly/accidentally depending on them.
1 parent 93cdde9 commit 0d220da

File tree

3 files changed

+13
-64
lines changed

3 files changed

+13
-64
lines changed

.circleci/config.yml

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ commands:
170170
name: clear cache
171171
command: |
172172
./emcc --clear-cache
173-
- pip-install
174173
- run: apt-get install -q -y ninja-build
175174
- run:
176175
name: embuilder build ALL
@@ -216,12 +215,8 @@ commands:
216215
# Must be absolute path or relative path from working_directory
217216
at: ~/
218217
- checkout
219-
- run:
220-
name: submodule update
221-
command: git submodule update --init
222218
- emsdk-env
223219
- bootstrap
224-
- pip-install
225220
- when:
226221
# We only set EMTEST_RETRY_FLAKY on pull requests. When we run
227222
# normal CI jobs on branches like main we still want to be able to
@@ -339,9 +334,6 @@ commands:
339334
at: ~/
340335
- checkout
341336
- remove-linux-binaries
342-
- run:
343-
name: submodule update
344-
command: git submodule update --init
345337
run-tests-firefox:
346338
description: "Runs emscripten tests under firefox"
347339
parameters:
@@ -791,10 +783,6 @@ jobs:
791783
executor: linux-python
792784
steps:
793785
- checkout
794-
- run:
795-
name: submodule update
796-
command: git submodule update --init
797-
- pip-install
798786
- install-emsdk
799787
- run:
800788
name: install jsc
@@ -816,10 +804,6 @@ jobs:
816804
executor: linux-python
817805
steps:
818806
- checkout
819-
- run:
820-
name: submodule update
821-
command: git submodule update --init
822-
- pip-install
823807
- install-emsdk
824808
- run:
825809
name: install spidermonkey
@@ -846,10 +830,6 @@ jobs:
846830
EMTEST_SKIP_V8: "1"
847831
steps:
848832
- checkout
849-
- run:
850-
name: submodule update
851-
command: git submodule update --init
852-
- pip-install
853833
- install-emsdk
854834
# `install-node-version` only changes the NODE_JS_TEST (the version of
855835
# node used to run test), not NODE_JS (the version of node used to run the
@@ -989,10 +969,6 @@ jobs:
989969
EMTEST_LACKS_WEBGPU: "1"
990970
steps:
991971
- checkout
992-
- run:
993-
name: submodule update
994-
command: git submodule update --init
995-
- pip-install
996972
- install-emsdk
997973
- run-tests-chrome:
998974
title: "browser"
@@ -1082,10 +1058,6 @@ jobs:
10821058
executor: focal
10831059
steps:
10841060
- checkout
1085-
- run:
1086-
name: submodule update
1087-
command: git submodule update --init
1088-
- pip-install
10891061
- install-emsdk
10901062
- run-tests-firefox:
10911063
title: "browser64"
@@ -1114,8 +1086,6 @@ jobs:
11141086
name: Add python to bash path
11151087
command: echo "export PATH=\"$PATH:/c/Python27amd64/\"" >> $BASH_ENV
11161088
- install-emsdk
1117-
- pip-install:
1118-
python: "$EMSDK_PYTHON"
11191089
- run-tests-firefox-windows:
11201090
title: "browser on firefox on windows"
11211091
# skip browser.test_glbook, as it requires mingw32-make, which is not
@@ -1178,8 +1148,6 @@ jobs:
11781148
# note we do *not* build all libraries and freeze the cache; as we run
11791149
# only limited tests here, it's more efficient to build on demand
11801150
- install-emsdk
1181-
- pip-install:
1182-
python: "$EMSDK_PYTHON"
11831151
- run-tests:
11841152
title: "crossplatform tests"
11851153
test_targets: "--crossplatform-only"
@@ -1207,8 +1175,6 @@ jobs:
12071175
- setup-macos
12081176
- install-emsdk
12091177
- freeze-cache
1210-
# TODO: We can't currently do pip install here since numpy and other packages
1211-
# are currently missing arm64 macos binaries.
12121178
- run-tests:
12131179
title: "crossplatform tests"
12141180
test_targets: "--crossplatform-only"

bootstrap.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
'test/third_party/googletest',
4040
'test/third_party/wasi-test-suite',
4141
], ['git', 'submodule', 'update', '--init']),
42+
('pip3 install', [
43+
'requirements-dev.txt',
44+
], [sys.executable, '-m', 'pip', 'install', '--target', 'out/python_deps', '-r', 'requirements-dev.txt']),
4245
]
4346

4447

test/test_sockets.py

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,9 @@
2525

2626
npm_checked = False
2727

28-
EMTEST_SKIP_PYTHON_DEV_PACKAGES = int(os.getenv('EMTEST_SKIP_PYTHON_DEV_PACKAGES', '0'))
2928
EMTEST_SKIP_NODE_DEV_PACKAGES = int(os.getenv('EMTEST_SKIP_NODE_DEV_PACKAGES', '0'))
3029

3130

32-
def requires_python_dev_packages(func):
33-
assert callable(func)
34-
35-
@common.wraps(func)
36-
def decorated(self, *args, **kwargs):
37-
if EMTEST_SKIP_PYTHON_DEV_PACKAGES:
38-
return self.skipTest('python websockify based tests are disabled by EMTEST_SKIP_PYTHON_DEV_PACKAGES=1')
39-
return func(self, *args, **kwargs)
40-
41-
return decorated
42-
43-
4431
def clean_processes(processes):
4532
for p in processes:
4633
if getattr(p, 'exitcode', None) is None and getattr(p, 'returncode', None) is None:
@@ -57,6 +44,15 @@ def clean_processes(processes):
5744
pass
5845

5946

47+
def import_websockify():
48+
sys.path.append(path_from_root('out/python_deps'))
49+
try:
50+
import websockify # type: ignore
51+
return websockify
52+
except ModuleNotFoundError:
53+
raise Exception('Unable to import module websockify. Run "./bootstrap" (or "python3 -m pip -r requirements-dev.txt --target out/python_deps" to install') from None
54+
55+
6056
class WebsockifyServerHarness:
6157
def __init__(self, filename, args, listen_port, do_server_check=True):
6258
self.processes = []
@@ -77,10 +73,7 @@ def __enter__(self):
7773
process = Popen([os.path.abspath('server')])
7874
self.processes.append(process)
7975

80-
try:
81-
import websockify # type: ignore
82-
except ModuleNotFoundError:
83-
raise Exception('Unable to import module websockify. Run "python3 -m pip install websockify" or set environment variable EMTEST_SKIP_PYTHON_DEV_PACKAGES=1 to skip this test.') from None
76+
websockify = import_websockify()
8477

8578
# start the websocket proxy
8679
print('running websockify on %d, forward to tcp %d' % (self.listen_port, self.target_port), file=sys.stderr)
@@ -202,8 +195,6 @@ def setUpClass(cls):
202195
def test_sockets_echo(self, harness_class, port, args):
203196
if harness_class == WebsockifyServerHarness and common.EMTEST_LACKS_NATIVE_CLANG:
204197
self.skipTest('requires native clang')
205-
if harness_class == WebsockifyServerHarness and EMTEST_SKIP_PYTHON_DEV_PACKAGES:
206-
self.skipTest('requires python websockify and EMTEST_SKIP_PYTHON_DEV_PACKAGES=1')
207198
if harness_class == CompiledServerHarness and EMTEST_SKIP_NODE_DEV_PACKAGES:
208199
self.skipTest('requires node ws and EMTEST_SKIP_NODE_DEV_PACKAGES=1')
209200

@@ -230,8 +221,6 @@ def test_sdl2_sockets_echo(self):
230221
def test_sockets_async_echo(self, harness_class, port, args):
231222
if harness_class == WebsockifyServerHarness and common.EMTEST_LACKS_NATIVE_CLANG:
232223
self.skipTest('requires native clang')
233-
if harness_class == WebsockifyServerHarness and EMTEST_SKIP_PYTHON_DEV_PACKAGES:
234-
self.skipTest('requires python websockify and EMTEST_SKIP_PYTHON_DEV_PACKAGES=1')
235224
if harness_class == CompiledServerHarness and EMTEST_SKIP_NODE_DEV_PACKAGES:
236225
self.skipTest('requires node ws and EMTEST_SKIP_NODE_DEV_PACKAGES=1')
237226

@@ -252,8 +241,6 @@ def test_sockets_async_bad_port(self):
252241
def test_sockets_echo_bigdata(self, harness_class, port, args):
253242
if harness_class == WebsockifyServerHarness and common.EMTEST_LACKS_NATIVE_CLANG:
254243
self.skipTest('requires native clang')
255-
if harness_class == WebsockifyServerHarness and EMTEST_SKIP_PYTHON_DEV_PACKAGES:
256-
self.skipTest('requires python websockify and EMTEST_SKIP_PYTHON_DEV_PACKAGES=1')
257244
if harness_class == CompiledServerHarness and EMTEST_SKIP_NODE_DEV_PACKAGES:
258245
self.skipTest('requires node ws and EMTEST_SKIP_NODE_DEV_PACKAGES=1')
259246
sockets_include = '-I' + test_file('sockets')
@@ -271,7 +258,6 @@ def test_sockets_echo_bigdata(self, harness_class, port, args):
271258
self.btest_exit('test_sockets_echo_bigdata.c', cflags=[sockets_include, '-DSOCKK=%d' % harness.listen_port] + args)
272259

273260
@no_windows('This test is Unix-specific.')
274-
@requires_python_dev_packages
275261
@requires_dev_dependency('ws')
276262
def test_sockets_partial(self):
277263
for harness in [
@@ -282,7 +268,6 @@ def test_sockets_partial(self):
282268
self.btest_exit('sockets/test_sockets_partial_client.c', assert_returncode=165, cflags=['-DSOCKK=%d' % harness.listen_port])
283269

284270
@no_windows('This test is Unix-specific.')
285-
@requires_python_dev_packages
286271
@requires_dev_dependency('ws')
287272
def test_sockets_select_server_down(self):
288273
for harness in [
@@ -293,7 +278,6 @@ def test_sockets_select_server_down(self):
293278
self.btest_exit('sockets/test_sockets_select_server_down_client.c', cflags=['-DSOCKK=%d' % harness.listen_port])
294279

295280
@no_windows('This test is Unix-specific.')
296-
@requires_python_dev_packages
297281
@requires_dev_dependency('ws')
298282
def test_sockets_select_server_closes_connection_rw(self):
299283
for harness in [
@@ -326,8 +310,6 @@ def test_enet(self):
326310
def test_nodejs_sockets_echo(self, harness_class, port, args):
327311
if harness_class == WebsockifyServerHarness and common.EMTEST_LACKS_NATIVE_CLANG:
328312
self.skipTest('requires native clang')
329-
if harness_class == WebsockifyServerHarness and EMTEST_SKIP_PYTHON_DEV_PACKAGES:
330-
self.skipTest('requires python websockify and EMTEST_SKIP_PYTHON_DEV_PACKAGES=1')
331313
if harness_class == CompiledServerHarness and EMTEST_SKIP_NODE_DEV_PACKAGES:
332314
self.skipTest('requires node ws and EMTEST_SKIP_NODE_DEV_PACKAGES=1')
333315

@@ -340,7 +322,6 @@ def test_nodejs_sockets_connect_failure(self):
340322
self.do_runf('sockets/test_sockets_echo_client.c', r'connect failed: (Connection refused|Host is unreachable)', regex=True, cflags=['-DSOCKK=666'], assert_returncode=NON_ZERO)
341323

342324
@requires_native_clang
343-
@requires_python_dev_packages
344325
def test_nodejs_sockets_echo_subprotocol(self):
345326
# Test against a Websockified server with compile time configured WebSocket subprotocol. We use a Websockified
346327
# server because as long as the subprotocol list contains binary it will configure itself to accept binary
@@ -353,7 +334,6 @@ def test_nodejs_sockets_echo_subprotocol(self):
353334
self.assertContained(['connect: ws://127.0.0.1:59168, base64,binary', 'connect: ws://127.0.0.1:59168/, base64,binary'], out)
354335

355336
@requires_native_clang
356-
@requires_python_dev_packages
357337
def test_nodejs_sockets_echo_subprotocol_runtime(self):
358338
# Test against a Websockified server with runtime WebSocket configuration. We specify both url and subprotocol.
359339
# In this test we have *deliberately* used the wrong port '-DSOCKK=12345' to configure the echo_client.c, so

0 commit comments

Comments
 (0)