Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install pwt.recipe.closurebuilder

How to install pwt.recipe.closurebuilder

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install pwt.recipe.closurebuilder
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.9.8 Available View build log
0.9.7 Available View build log
0.9.6 Available View build log
0.9.5 Available View build log
0.9.4 Available View build log
0.9.3 Available View build log
0.9.2 Available View build log
0.9.1 Available View build log
Windows (64-bit)
0.9.8 Available View build log
0.9.7 Available View build log
0.9.6 Available View build log
0.9.5 Available View build log
0.9.4 Available View build log
0.9.3 Available View build log
0.9.2 Available View build log
0.9.1 Available View build log
Mac OS X (10.5+)
0.9.8 Available View build log
0.9.7 Available View build log
0.9.6 Available View build log
0.9.5 Available View build log
0.9.4 Available View build log
0.9.3 Available View build log
0.9.2 Available View build log
0.9.1 Available View build log
Linux (32-bit)
0.9.8 Available View build log
0.9.7 Available View build log
0.9.6 Available View build log
0.9.5 Available View build log
0.9.4 Available View build log
0.9.3 Available View build log
0.9.2 Available View build log
0.9.1 Available View build log
Linux (64-bit)
0.9.8 Available View build log
0.9.7 Available View build log
0.9.6 Available View build log
0.9.5 Available View build log
0.9.4 Available View build log
0.9.3 Available View build log
0.9.2 Available View build log
0.9.1 Available View build log
 
Dependencies
Depended by
Imports
Lastest release
version 0.9.8 on Oct 26th, 2011

This is a simple wrapper around the closurebuilder tools from the Closure project from Google.

Dependencies

Setup some JavaScript files.

>>> import os.path
>>> os.mkdir(os.path.join(sample_buildout, 'js'))
>>> write('js/a.js', '''
... goog.provide('pwt.provideA');
...
... goog.require('pwt.provideB');
... ''')
>>> write('js/b.js', '''
... goog.provide('pwt.provideB');
... ''')
>>> mkdir('js/goog')
>>> write('js/goog/base.js', open(os.path.join(os.path.dirname(__file__), "goog/base.js")).read())
roots

Generate a dependency file specifing where all your JavaScript files are located within your project.

>>> write('buildout.cfg', '''
... [buildout]
... parts = deps.js
...
... [deps.js]
... recipe = pwt.recipe.closurebuilder:dependency
... output = %(dir)s/deps.js
... roots = %(dir)s/js
... ''' %{'dir': sample_buildout})
>>> print system(buildout)
Installing deps.js.
<BLANKLINE>
>>> cat('deps.js')
// This file was autogenerated by buildout[deps.js].
// Please do not edit.
goog.addDependency('a.js', ['pwt.provideA'], ['pwt.provideB']);
goog.addDependency('b.js', ['pwt.provideB'], []);
goog.addDependency('goog/base.js', ['goog'], []);
roots with prefix

Generate a dependency file specifing where all your JavaScript files are located within your project. Sometimes files are served under different namespaces, then we use the root_with_prefix option.

>>> write('buildout.cfg', '''
... [buildout]
... parts = deps.js
...
... [deps.js]
... recipe = pwt.recipe.closurebuilder:dependency
... output = %(dir)s/deps.js
... root_with_prefix = %(dir)s/js /media
... ''' %{'dir': sample_buildout})
>>> print system(buildout)
Uninstalling deps.js.
Installing deps.js.
<BLANKLINE>
>>> cat('deps.js')
// This file was autogenerated by buildout[deps.js].
// Please do not edit.
goog.addDependency('/media/a.js', ['pwt.provideA'], ['pwt.provideB']);
goog.addDependency('/media/b.js', ['pwt.provideB'], []);
goog.addDependency('/media/goog/base.js', ['goog'], []);

Compile

Using the information above, generate a small minimized version of your JavaScript application.

>>> write('buildout.cfg', '''
... [buildout]
... parts = deps.js compiled.js
...
... [deps.js]
... recipe = pwt.recipe.closurebuilder:dependency
... output = %(dir)s/d1.js
... roots = %(dir)s/js
...
... [compiled.js]
... recipe = pwt.recipe.closurebuilder:compile
... dependency = deps.js
... output = %(dir)s
... inputs = %(dir)s/js/a.js
... ''' %{'dir': sample_buildout})
>>> output = system(buildout)
>>> output == '''root: Compiling with the following command: java -jar %(jar)s --js %(dir)s/js/goog/base.js --js %(dir)s/js/b.js --js %(dir)s/js/a.js
... Uninstalling deps.js.
... Installing deps.js.
... Installing compiled.js.
... ''' %{'jar': os.path.join(os.path.dirname(__file__), 'compiler-1111.jar'),
...       'dir': sample_buildout}
True
>>> ls(sample_buildout)
-  .installed.cfg
-  0fb0e24aea59f6281f3c615ffe650823.js
d  bin
-  buildout.cfg
-  d1.js
d  develop-eggs
d  eggs
d  js
d  parts

We can also specify extra files that might not have goog.provide declarations in them so won't be picked up by the depswriter recipe.

>>> write('js/c.js', '''
... alert('c');
... ''')
>>> write('buildout.cfg', '''
... [buildout]
... parts = deps.js compiled.js
...
... [deps.js]
... recipe = pwt.recipe.closurebuilder:dependency
... output = %(dir)s/d1.js
... roots = %(dir)s/js
...
... [compiled.js]
... recipe = pwt.recipe.closurebuilder:compile
... dependency = deps.js
... output = %(dir)s
... inputs = %(dir)s/js/a.js
... extra_js = js/c.js
... ''' %{'dir': sample_buildout})
>>> output = system(buildout)
>>> output == '''root: Compiling with the following command: java -jar %(jar)s --js js/c.js --js %(dir)s/js/goog/base.js --js %(dir)s/js/b.js --js %(dir)s/js/a.js
... Uninstalling compiled.js.
... Updating deps.js.
... Installing compiled.js.
... ''' %{'jar': os.path.join(os.path.dirname(__file__), 'compiler-1111.jar'),
...       'dir': sample_buildout}
True
>>> ls(sample_buildout)
-  .installed.cfg
-  b68ab8e7a5aa2b2787d35e9b762fb191.js
d  bin
-  buildout.cfg
-  d1.js
d  develop-eggs
d  eggs
d  js
d  parts

Subscribe to package updates

Last updated Oct 26th, 2011

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.