summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-07-16 17:49:02 -0400
committerTim Graham <timograham@gmail.com>2015-07-17 13:22:34 -0400
commitadffff79a36f7de30f438915c492e475e17025f6 (patch)
tree78a170f47f64977ccdb2678e97ce5e356d5c2495
parent28ee511b7e58edb6c0e4fcf3412dd40c6f60eb33 (diff)
Allowed installing closure with pip for admin JavaScript compression.
-rw-r--r--django/contrib/admin/bin/compress.py9
-rw-r--r--docs/internals/contributing/writing-code/javascript.txt14
2 files changed, 16 insertions, 7 deletions
diff --git a/django/contrib/admin/bin/compress.py b/django/contrib/admin/bin/compress.py
index 7ae7ed8f10..d2a70ee812 100644
--- a/django/contrib/admin/bin/compress.py
+++ b/django/contrib/admin/bin/compress.py
@@ -4,6 +4,13 @@ import os
import subprocess
import sys
+try:
+ import closure
+except ImportError:
+ closure_compiler = None
+else:
+ closure_compiler = os.path.join(os.path.dirname(closure.__file__), 'closure.jar')
+
js_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'static', 'admin', 'js')
@@ -21,7 +28,7 @@ Compiler library and Java version 6 or later."""
action="store_false", dest="verbose")
options = parser.parse_args()
- compiler = os.path.expanduser(options.compiler)
+ compiler = closure_compiler if closure_compiler else os.path.expanduser(options.compiler)
if not os.path.exists(compiler):
sys.exit(
"Google Closure compiler jar file %s not found. Please use the -c "
diff --git a/docs/internals/contributing/writing-code/javascript.txt b/docs/internals/contributing/writing-code/javascript.txt
index f1d6e44d16..a3b34c564e 100644
--- a/docs/internals/contributing/writing-code/javascript.txt
+++ b/docs/internals/contributing/writing-code/javascript.txt
@@ -45,15 +45,17 @@ Compressing JavaScript
To simplify the process of providing optimized JavaScript code, Django
includes a handy Python script which should be used to create a "minified"
-version. To run it::
+version. To run it:
- python django/contrib/admin/bin/compress.py
+.. code-block:: console
+
+ $ pip install closure
+ $ python django/contrib/admin/bin/compress.py
Behind the scenes, ``compress.py`` is a front-end for Google's
-`Closure Compiler`_ which is written in Java. However, the Closure Compiler
-library is not bundled with Django directly, so those wishing to contribute
-complete JavaScript patches will need to download and install the library
-independently. The Closure Compiler library requires `Java`_ 7 or higher.
+`Closure Compiler`_ which is written in Java. The Closure Compiler library is
+not bundled with Django, but you can install it using pip as done above. The
+Closure Compiler library requires `Java`_ 7 or higher.
Please don't forget to run ``compress.py`` and include the ``diff`` of the
minified scripts when submitting patches for Django's JavaScript.