Guide to Pyjs and Pyjsdl

These notes provide instructions on the use of Pyjs with Pyjsdl, which were tested on Linux and Win7 systems.

Installation of Pyjs 0.8.1-dev is required, currently available from Pyjs Github repository. Check instruction on Pyjs Github site.

The tools required for installation are pip and git, install tools if necessary from package manager (Linux) or follow install instructions on tools Webpage (Win7).
sudo apt-get install python-pip
sudo apt-get install git

Command to install Pyjs with pip:
Linux system install:
sudo pip install git+
Linux local install:
pip install git+ –user
pip install git+

With Pyjs installed, pyjsbuild had error ‘pkg_resources.DistributionNotFound: six’, resolved after Pyjs install by upgrading Six dependency:
pip show six (upgrade version 1.3 to 1.8)
sudo pip install six –upgrade
easy_install –upgrade six

Command to show information of Pyjs installed by pip:
pip show pyjs
Linux information:
Win7 information:
Location: \python27\lib\site-packages

pyjsbuild and pyjscompressor:
Refer to these scripts with system path, instances below are in Linux.

To get HTML5 Canvas to work with IE9+, modify Pyjs as described in pyjsdl/guide.txt:
Use files in to modify or overwrite the following files:
Linux change:
Win7 change:

Use pyjsbuild to compile, check ‘pyjsbuild –help’ for command options. Use compile options -S (strict mode), -O (optimise mode), and -d (debug). Use of –dynamic-link option links JavaScript files in lib folder, decreasing size of browser specific HTML files and permitting shared lib folder with multiple demo apps. Use the -o option to build to separate output folder for different option set. To test installed Pyjs, compile an app from Pyjs examples, which can be downloaded from Pyjs Github repository. Not all examples work, but tested the following:

Helloworld App
change to folder /examples/helloworld
/local/bin/pyjsbuild -S –dynamic-link -o output

GWTCanvas App
change to folder /examples/gwtcanvas
/local/bin/pyjsbuild -S –dynamic-link -o output

Compile a Pyjsdl demo with Pyjs and Pyjsdl, download demo app and unpack. Download Pyjsdl and unpack, placing Pyjsdl folder on the path or in the demo app folder. Compile the script with the command:
/local/bin/pyjsbuild -O –dynamic-link -o output
Following build, place data folder containing images in output folder.
Tested by opening app.html in Firefox, IE, and Chrome.
To open local files, launch Chrome with the option –allow-file-access-from-files
Can use a local server, such as SimpleHTTPServer with command:
python -m SimpleHTTPServer 8000
Server root folder is where command was run, use browser at http://localhost:8000 to browse to HTML file to load.

Use pyjscompressor to compress JavaScript in output folder with command:
python /local/bin/pyjscompressor output
Pyjscompressor uses Closure Compiler, can download latest release and use:
python /local/bin/pyjscompressor output -c /compiler.jar
Pyjscompressor did not work in Pyjs build 140806, with ‘ImportError: No module named contrib.pyjscompressor’, due to missing files apparently left out during installation. Resolved by downloading Pyjs from Pyjs Github repository, and copy missing files from /pyjs/contrib/ to /local/lib/python2.7/site-packages/pyjs/contrib/ (Linux) or \python27\lib\site-packages\pyjs\contrib\ (Win7).

Following compilation with pyjsbuild and optional compression with pyjscompressor, the output folder containing the app can be deployed to a Web server.

This entry was posted in Programming and tagged , , , , . Bookmark the permalink. Trackbacks are closed, but you can post a comment.

Post a Comment

Your email is never published nor shared. Required fields are marked *

You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>