From 2ae0b40cd875c1f87330533b3ff7801951ddb5ea Mon Sep 17 00:00:00 2001 From: hartsantler Date: Fri, 12 Sep 2014 03:14:23 -0700 Subject: [PATCH 01/58] forked PythonJS and started Gython. updated readme, added gython.py build script. --- README.md | 382 +++--------------------------------------------------- gython.py | 4 + 2 files changed, 19 insertions(+), 367 deletions(-) create mode 100755 gython.py diff --git a/README.md b/README.md index db3e43f..3169577 100644 --- a/README.md +++ b/README.md @@ -1,117 +1,29 @@ Introduction ------------ -PythonJS is a transpiler written in Python that converts a python like language into fast -JavaScript. It also includes experimental backends that translate to: Dart, Lua, CoffeeScript, and Go. - -[Syntax Documentation](https://github.com/PythonJS/PythonJS/blob/master/doc/syntax.md) - - -Go backend ----------- -The Go backend uses a fully typed subset of Python, mixed with extra syntax inspired by Golang to output Go programs that can be compiled to native executeables, or translated to JavaScript using GopherJS. +Gython is a transpiler written in Python that converts a python like language into Go. [Syntax Documentation](https://github.com/PythonJS/PythonJS/blob/master/doc/go_syntax.md) Getting Started =============== -PythonJS can be run with regular Python, or fully self-hosted within -NodeJS using Empythoned. - -To get started, you have two options: -1. install NodeJS, python-js package, and write a build script. -2. or install Python2 and use translator.py from this repo directly. - - -1. Installing NodeJS Package -------------- -You can quickly get started with the stable version of PythonJS by installing the NodeJS package, -and writing a build script in javascript to compile your python scripts to javascript. -(Python2.7 is not required) - -``` -npm install python-js -``` - -NodeJS Quick Example --------------- - -``` -var pythonjs = require('python-js'); -var pycode = "a = []; a.append('hello'); a.append('world'); print(a)"; -var jscode = pythonjs.translator.to_javascript( pycode ); -eval( pythonjs.runtime.javascript + jscode ); - -``` -Example Projects ----------------- -The example projects below, require the NodeJS python-js package. - -[https://github.com/PythonJS/pythonjs-demo-server-nodejs](https://github.com/PythonJS/pythonjs-demo-server-nodejs) - -[https://github.com/PythonJS/pypubjs](https://github.com/PythonJS/pypubjs) - - - -2. translator.py +gython.py -------------------------------------- -If you want to run the latest version of the translator, you will need to install -Python2.7 and git clone this repo. (the NodeJS package above is not required) -Then, to translate your python script, directly run the `translator.py` script in the "pythonjs" directory. You can give it a list of python files to translate at once. -It will output the translation to stdout. The default output type is JavaScript. -An html file can also be used as input, python code inside a script tag: `