mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
This causes `upgrade-zulip-from-git`, as well as a no-option run of `tools/build-release-tarball`, to produce a Zulip install running Python 3, rather than Python 2. In particular this means that the virtualenv we create, in which all application code runs, is Python 3. One shebang line, on `zulip-ec2-configure-interfaces`, explicitly keeps Python 2, and at least one external ops script, `wal-e`, also still runs on Python 2. See discussion on the respective previous commits that made those explicit. There may also be some other third-party scripts we use, outside of this source tree and running outside our virtualenv, that still run on Python 2.
34 lines
1.4 KiB
Python
Executable File
34 lines
1.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
from __future__ import absolute_import
|
|
from __future__ import print_function
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
|
from scripts.lib.node_cache import generate_sha1sum_node_modules
|
|
|
|
NODE_MODULES_CACHE_PATH = "/srv/zulip-npm-cache"
|
|
if "--travis" in sys.argv:
|
|
NODE_MODULES_CACHE_PATH = os.path.join(os.environ["HOME"], "zulip-npm-cache")
|
|
try:
|
|
subprocess.check_output([os.path.join(NODE_MODULES_CACHE_PATH, "yarn/bin/yarn"), '--version'])
|
|
except OSError:
|
|
print('yarn not found. Most probably we are running static-analysis and '
|
|
'hence yarn is not installed. Exiting without cleaning npm cache.')
|
|
sys.exit(0)
|
|
|
|
sha1sum = generate_sha1sum_node_modules()
|
|
current_cache_dir_base = os.path.join(NODE_MODULES_CACHE_PATH, sha1sum)
|
|
current_success_stamp = os.path.join(current_cache_dir_base, '.success-stamp')
|
|
|
|
print("Current cache stamp at %s" % (current_success_stamp,))
|
|
|
|
for cache_dir_base in os.listdir(NODE_MODULES_CACHE_PATH):
|
|
node_modules_dir = os.path.join(NODE_MODULES_CACHE_PATH, cache_dir_base)
|
|
if node_modules_dir == current_cache_dir_base and os.path.exists(current_success_stamp):
|
|
print("Keeping used node_modules cache dir %s" % (node_modules_dir,))
|
|
else:
|
|
print("Cleaning unused node_modules cache dir %s" % (node_modules_dir,))
|
|
subprocess.check_call(["sudo", "rm", "-rf", node_modules_dir])
|