Git Product home page Git Product logo

python-closure's Introduction

The Closure Compiler is a tool for reducing the size of Javascript files to make them download and run faster.

It's a Java-based tool. This package, in the spirit of the yuicompressor <http://pypi.python.org/pypi/yuicompressor/> package, provides a simple way to install and use the the Closure compiler from Python, bundling the closure.jar with the Python package.

I recommend looking at webassets for your CSS/JS compression needs.

Versions

Version YYYYMMDD of this package will bundle the corresponding version of the compiler (Closure uses the build date as the version).

If you want a new version to be uploaded, open a ticket at the Github page.

python-closure's People

Contributors

dstanek avatar helb avatar miracle2k avatar morabaraba avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

python-closure's Issues

Please update closure

There are some new releases since 20140110 (latest version in PyPI). Please consider updating it, if you have some spare time for that. Thanks.

open('README') should be open('README.rst') in setup.py

This bug applies only to the master branch, not to the PyPi package.

In a Windoze command-line session, the following error is encountered when attempting an install:

C:\Users\nwilson\Downloads\miracle2k-python-closure-cf7eeeb>setup install
Traceback (most recent call last):
  File "C:\Users\nwilson\Downloads\miracle2k-python-closure-cf7eeeb\setup.py", line 8, in <module>
    long_description=open('README').read(),
IOError: [Errno 2] No such file or directory: 'README'

This can be avoided either by renaming README.rst to README or modifying setup.py:8 to

    long_description=open('README.rst').read()

Use subprocess instead of os.execlp

os.execlp has poor support on Windows.

  1. It creates a new process. (Can't get the return code. And this messes with things like cygwin/msysgit.)
  2. It doesn't pass arguments correctly.

In my use case, os.execlp won't work on both Windows and Linux because the arguments are escaped wrongly on one or the other.

Switching to subprocess allows it to work fine on both.

Here is what I'm using:

import sys
import subprocess
from pkg_resources import resource_filename


def get_jar_filename():
    """Return the full path to the Closure Compiler Java archive."""
    return resource_filename(__name__, "closure.jar")


def main():
    return subprocess.call(['java', '-jar', get_jar_filename()] + sys.argv[1:])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.