py3: Switch almost all shebang lines to use `python3`.
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.
2017-08-02 23:15:16 +02:00
|
|
|
#!/usr/bin/env python3
|
2013-01-30 23:11:34 +01:00
|
|
|
|
Reuse minified JS from previous deploys
This is a big change affecting lots of areas:
* Pipeline no longer deals with JS (though it still minifies CSS)
* A new script, tools/minify-js (called from update-prod-static),
minifies JavaScripts
* A command-line argument --prev-deploy, if passed to minify-js or
update-prod-static, is used to copy minified JS from a previous
deploy (i.e., a previous git checkout), if the source files have
not changed
* update-deployment passes --prev-deploy
* Scripts are now included with the minified_js template tag, rather
than Pipeline's compressed_js
Also, as a side benefit of this commit, our Handlebars templates will
no longer be copied into prod-static/ and accessible in production.
Unminification is probably broken, but, per Zev and Trac ticket #1377,
it wasn't working perfectly before this change either.
(Based on code review, this commit has been revised to:
* Warn if git returns an error in minify-js
* Add missing output redirects in update-prod-static
* Use DEPLOY_ROOT instead of manually constructing that directory
* Use old style formatting)
(imported from commit e67722ea252756db8519d5c0bd6a421d59374185)
2013-07-03 22:42:25 +02:00
|
|
|
# Updates static files for production.
|
2020-06-11 00:54:34 +02:00
|
|
|
import os
|
Reuse minified JS from previous deploys
This is a big change affecting lots of areas:
* Pipeline no longer deals with JS (though it still minifies CSS)
* A new script, tools/minify-js (called from update-prod-static),
minifies JavaScripts
* A command-line argument --prev-deploy, if passed to minify-js or
update-prod-static, is used to copy minified JS from a previous
deploy (i.e., a previous git checkout), if the source files have
not changed
* update-deployment passes --prev-deploy
* Scripts are now included with the minified_js template tag, rather
than Pipeline's compressed_js
Also, as a side benefit of this commit, our Handlebars templates will
no longer be copied into prod-static/ and accessible in production.
Unminification is probably broken, but, per Zev and Trac ticket #1377,
it wasn't working perfectly before this change either.
(Based on code review, this commit has been revised to:
* Warn if git returns an error in minify-js
* Add missing output redirects in update-prod-static
* Use DEPLOY_ROOT instead of manually constructing that directory
* Use old style formatting)
(imported from commit e67722ea252756db8519d5c0bd6a421d59374185)
2013-07-03 22:42:25 +02:00
|
|
|
import sys
|
|
|
|
|
|
|
|
# We need settings so we can figure out where the prod-static directory is.
|
2021-02-12 08:20:45 +01:00
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
2020-01-08 00:06:39 +01:00
|
|
|
from scripts.lib.setup_path import setup_path
|
|
|
|
|
|
|
|
setup_path()
|
|
|
|
|
2021-07-03 08:22:44 +02:00
|
|
|
# check for the venv
|
|
|
|
from tools.lib import sanity_check
|
|
|
|
|
|
|
|
sanity_check.check_venv(__file__)
|
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
os.environ["DJANGO_SETTINGS_MODULE"] = "zproject.settings"
|
2022-08-26 22:20:47 +02:00
|
|
|
os.environ["ZULIP_COLLECTING_STATIC"] = "1"
|
Reuse minified JS from previous deploys
This is a big change affecting lots of areas:
* Pipeline no longer deals with JS (though it still minifies CSS)
* A new script, tools/minify-js (called from update-prod-static),
minifies JavaScripts
* A command-line argument --prev-deploy, if passed to minify-js or
update-prod-static, is used to copy minified JS from a previous
deploy (i.e., a previous git checkout), if the source files have
not changed
* update-deployment passes --prev-deploy
* Scripts are now included with the minified_js template tag, rather
than Pipeline's compressed_js
Also, as a side benefit of this commit, our Handlebars templates will
no longer be copied into prod-static/ and accessible in production.
Unminification is probably broken, but, per Zev and Trac ticket #1377,
it wasn't working perfectly before this change either.
(Based on code review, this commit has been revised to:
* Warn if git returns an error in minify-js
* Add missing output redirects in update-prod-static
* Use DEPLOY_ROOT instead of manually constructing that directory
* Use old style formatting)
(imported from commit e67722ea252756db8519d5c0bd6a421d59374185)
2013-07-03 22:42:25 +02:00
|
|
|
from django.conf import settings
|
|
|
|
|
2020-06-11 00:54:34 +02:00
|
|
|
from scripts.lib.node_cache import setup_node_modules
|
2021-07-19 06:29:28 +02:00
|
|
|
from scripts.lib.zulip_tools import assert_not_running_as_root, run
|
|
|
|
|
|
|
|
assert_not_running_as_root()
|
|
|
|
|
2017-02-07 20:49:12 +01:00
|
|
|
|
Reuse minified JS from previous deploys
This is a big change affecting lots of areas:
* Pipeline no longer deals with JS (though it still minifies CSS)
* A new script, tools/minify-js (called from update-prod-static),
minifies JavaScripts
* A command-line argument --prev-deploy, if passed to minify-js or
update-prod-static, is used to copy minified JS from a previous
deploy (i.e., a previous git checkout), if the source files have
not changed
* update-deployment passes --prev-deploy
* Scripts are now included with the minified_js template tag, rather
than Pipeline's compressed_js
Also, as a side benefit of this commit, our Handlebars templates will
no longer be copied into prod-static/ and accessible in production.
Unminification is probably broken, but, per Zev and Trac ticket #1377,
it wasn't working perfectly before this change either.
(Based on code review, this commit has been revised to:
* Warn if git returns an error in minify-js
* Add missing output redirects in update-prod-static
* Use DEPLOY_ROOT instead of manually constructing that directory
* Use old style formatting)
(imported from commit e67722ea252756db8519d5c0bd6a421d59374185)
2013-07-03 22:42:25 +02:00
|
|
|
os.chdir(settings.DEPLOY_ROOT)
|
2013-01-30 23:11:34 +01:00
|
|
|
|
2015-10-26 17:16:26 +01:00
|
|
|
# Install node packages
|
2020-04-24 22:24:11 +02:00
|
|
|
setup_node_modules(production=True)
|
2015-10-26 17:16:26 +01:00
|
|
|
|
2017-01-28 21:12:01 +01:00
|
|
|
# Build emoji
|
2021-02-12 08:20:45 +01:00
|
|
|
run(["./tools/setup/emoji/build_emoji"])
|
2017-01-28 21:12:01 +01:00
|
|
|
|
2017-09-16 14:30:57 +02:00
|
|
|
# Inline CSS in emails
|
2021-02-12 08:20:45 +01:00
|
|
|
run(["./scripts/setup/inline_email_css.py"])
|
2017-09-16 14:30:57 +02:00
|
|
|
|
2017-09-17 02:14:56 +02:00
|
|
|
# Copy over static files from the zulip_bots package
|
2021-02-12 08:20:45 +01:00
|
|
|
run(["./tools/setup/generate_zulip_bots_static_files.py"])
|
2017-09-17 02:14:56 +02:00
|
|
|
|
2022-02-08 00:13:33 +01:00
|
|
|
# Build pygments data
|
2021-02-12 08:20:45 +01:00
|
|
|
run(["./tools/setup/build_pygments_data"])
|
2017-04-26 09:32:46 +02:00
|
|
|
|
2022-02-24 21:15:43 +01:00
|
|
|
# Build time zone data
|
2021-02-12 08:20:45 +01:00
|
|
|
run(["./tools/setup/build_timezone_values"])
|
2020-09-29 22:20:46 +02:00
|
|
|
|
2019-06-29 10:26:57 +02:00
|
|
|
# Create webpack bundle
|
2021-02-12 08:20:45 +01:00
|
|
|
run(["./tools/webpack", "--quiet"])
|
2013-01-30 23:11:34 +01:00
|
|
|
|
2017-01-07 05:09:10 +01:00
|
|
|
# Collect the files that we're going to serve; this creates prod-static/serve.
|
2021-02-12 08:19:30 +01:00
|
|
|
run(
|
|
|
|
[
|
2021-02-12 08:20:45 +01:00
|
|
|
"./manage.py",
|
|
|
|
"collectstatic",
|
|
|
|
"--no-default-ignore",
|
|
|
|
"-v0",
|
|
|
|
"--noinput",
|
|
|
|
"--ignore=assets",
|
|
|
|
"--ignore=emoji-styles",
|
|
|
|
"--ignore=html",
|
|
|
|
"--ignore=js",
|
|
|
|
"--ignore=styles",
|
|
|
|
"--ignore=templates",
|
2021-02-12 08:19:30 +01:00
|
|
|
]
|
|
|
|
)
|
2018-06-01 01:45:18 +02:00
|
|
|
|
2016-05-02 10:20:00 +02:00
|
|
|
# Compile translation strings to generate `.mo` files.
|
2021-02-12 08:20:45 +01:00
|
|
|
run(["./manage.py", "compilemessages", "-v0"])
|
2016-05-02 10:20:00 +02:00
|
|
|
|
2018-06-01 01:45:18 +02:00
|
|
|
# Needed if PRODUCTION
|
2021-02-12 08:20:45 +01:00
|
|
|
os.makedirs("prod-static", exist_ok=True)
|