Skip to content

Commit 6ed2c90

Browse files
tgamblintldahlgren
authored andcommitted
externals: avoid importing requests in jsonschema
Spack doesn't need `requests`, and neither does `jsonschema`, but `jsonschema` tries to import it, and it'll succeed if `requests` is on your machine (which is likely, given how popular it is). This commit removes the import to improve Spack's startup time a bit. On a mac with SSD, the import of requests is ~28% of Spack's startup time when run as `spack --print-shell-vars sh,modules` (.069 / .25 seconds), which is what `setup-env.sh` runs. On a Linux cluster where Python is mounted from NFS, this reduces `setup-env.sh` source time from ~1s to .75s. Note: This issue will be eliminated if we upgrade to a newer `jsonschema` (we'd need to drop Python 2.6 for that). See python-jsonschema/jsonschema#388.
1 parent 34b4a46 commit 6ed2c90

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

lib/spack/external/jsonschema/validators.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
import json
55
import numbers
66

7-
try:
8-
import requests
9-
except ImportError:
10-
requests = None
7+
requests = None
118

129
from jsonschema import _utils, _validators
1310
from jsonschema.compat import (

0 commit comments

Comments
 (0)