Permalink
Browse files

Update OPy README with the shell commands I use.

A lot of the commands there had "rotted".
  • Loading branch information...
Andy Chu
Andy Chu committed Apr 8, 2018
1 parent 94749be commit a89200459d7b7f8dbc0ba1885c0c1365c912c3ed
Showing with 62 additions and 45 deletions.
  1. +55 −22 opy/README.md
  2. +7 −1 scripts/opy.sh → opy/demo.sh
  3. +0 −22 opy/test.sh
View
@@ -1,29 +1,67 @@
OPy Compiler
============
OPy Compiler and Byterun
========================
Getting started / smoke test:
The OPy compiler is a Python bytecode compiler written in Python. See
[Building Oil with the OPy Bytecode Compiler][oil-with-opy]. It's currently
used to translate Python source code in Oil to `.pyc` files.
./build.sh grammar
./run.sh parse-test
./run.sh compile-hello2 # prints hello world
./run.sh compile-hello3 # no __future__ print_function
The `byterun/` directory is a fork of [byterun][]. It's an experiment for
learning what it will take to write a minimal interpreter for Oil. It can
curretly run all the Oil unit tests, but isn't otherwise used.
Compiling Oil:
[oil-with-opy]: http://www.oilshell.org/blog/2018/03/04.html
./build.sh oil-repo # makes _tmp/osh-opy and _tmp/osh-ccompile
[byterun]: http://aosabook.org/en/500L/a-python-interpreter-written-in-python.html
Testing:
Getting started
---------------
./test.sh unit # Run Oil unit tests
Start with https://github.com/oilshell/oil/wiki/Contributing . This is
necessary to build the `py27.grammar` file and so forth.
Test the binary:
Then:
./test.sh osh-help
./test.sh osh-version
./test.sh spec smoke
./test.sh spec all # Failures due to $0
$ ./smoke.sh opy-hello2 # basic test of compiler and runtime
OPy Divergences from CPython
Compile Oil with the OPy compiler:
$ ./build.sh oil-repo # makes _tmp/osh-opy and _tmp/osh-ccompile
Run Oil unit tests, compiled with OPy, under CPython:
$ ./test.sh oil-unit
Run Oil unit tests, compiled with OPy, under byterun (OPyPy):
$ ./test.sh oil-unit-byterun # Run Oil unit tests, compiled with OPy, under CPython
Another way I test it like this:
$ testdata/regex_compile.py # run with CPython
$ ../bin/opyc run testdata/regex_compile.py
(TODO: these should be gold tests)
Demo: speed difference between OSH under CPython and OSH under byterun/OPyPy:
./demo.sh opypy-speed
TODO:
- Spec tests
- ./test.sh spec all # Some failures due to $0
OPy Compiler Regtest
--------------------
This uses golden data in `_regtest/`.
./regtest.sh compile # note: different files than 'build.sh oil-repo'
./regtest.sh verify-golden
OPy Compiler Divergences from CPython
----------------------------
### Lexer
@@ -48,8 +86,3 @@ OPy Divergences from CPython
histogram using `opy/misc/inspect_pyc`.
- The OPy bytecode is bigger than the CPython bytecode! Why is that?
### Other
OSH tests don't run under byterun. I probably don't care.
./test.sh unit '' byterun
@@ -7,12 +7,18 @@ set -o nounset
set -o pipefail
set -o errexit
readonly THIS_DIR=$(cd $(dirname $0) && pwd)
# Show the difference between OSH running under CPython and OSH running under
# byterun.
opypy-demo() {
opypy-speed() {
pushd $THIS_DIR/..
local prog='for i in $(seq 10); do echo $i; done'
time bin/osh -c "$prog"
time bin/opypy-osh -c "$prog"
popd
}
"$@"
View
@@ -12,32 +12,10 @@ readonly OPYC=$THIS_DIR/../bin/opyc
source $THIS_DIR/common.sh
osh-opy() {
_tmp/oil-opy/bin/osh "$@"
}
oil-opy() {
_tmp/oil-opy/bin/oil "$@"
}
osh-help() {
osh-opy --help
}
# TODO: Add compiled with "OPy".
# How will it know? You can have a special function bin/oil.py:
# def __GetCompilerName__():
# return "CPython"
#
# If the function name is opy stub, then Opy ret
#
# Or __COMPILER_NAME__ = "CPython"
# The OPy compiler can rewrite this to "OPy".
osh-version() {
osh-opy --version
}
# TODO:
# - Run with oil.ovm{,-dbg}

0 comments on commit a892004

Please sign in to comment.