Permalink
Browse files

Fixes to 'make _bin/opy.ovm'

- tokenize.py uses Python 3 print_function.  Needed because OPy does
  'import inspect' which does 'import tokenize'.  Usually we do 'from
  .pgen2 import tokenize'.
- c_module_srcs.py: can now import hashlib.  OPy uses this for
  'dis-md5', but Oil doesn't.
- atexit.py: move __future__ import so docstring isn't broken.
- starting a script to find stdlib dependencies of Oil and OPy.
  • Loading branch information...
Andy Chu
Andy Chu committed Apr 15, 2018
1 parent b09a27b commit ef5f1aefcef5de896388b37ca99176040383b3c1
Showing with 48 additions and 4 deletions.
  1. +1 −1 Python-2.7.13/Lib/atexit.py
  2. +3 −2 Python-2.7.13/Lib/tokenize.py
  3. +1 −1 build/actions.sh
  4. +11 −0 build/c_module_srcs.py
  5. +32 −0 test/stdlib.sh
@@ -1,10 +1,10 @@
from __future__ import print_function # for OPy compiler
"""
atexit.py - allow programmer to define multiple exit functions to be executed
upon normal program termination.
One public function, register, is defined.
"""
from __future__ import print_function # for OPy compiler
__all__ = ["register"]
@@ -21,6 +21,7 @@
are the same, except instead of generating tokens, tokeneater is a callback
function to which the 5 fields described above are passed as 5 arguments,
each time a new token is found."""
from __future__ import print_function # for OPy compiler
__author__ = 'Ka-Ping Yee <ping@lfw.org>'
__credits__ = ('GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, '
@@ -150,8 +151,8 @@ class StopTokenizing(Exception): pass
def printtoken(type, token, srow_scol, erow_ecol, line): # for testing
srow, scol = srow_scol
erow, ecol = erow_ecol
print "%d,%d-%d,%d:\t%s\t%s" % \
(srow, scol, erow, ecol, tok_name[type], repr(token))
print("%d,%d-%d,%d:\t%s\t%s" % \
(srow, scol, erow, ecol, tok_name[type], repr(token)))
def tokenize(readline, tokeneater=printtoken):
"""
View
@@ -183,7 +183,7 @@ join-modules() {
#
# TODO: I don't want to depend on egrep and GNU flags on the target sytems?
# Ship this file I guess.
egrep --no-filename --only-matching '^[a-zA-Z_\.]+' $static $discovered \
egrep --no-filename --only-matching '^[a-zA-Z0-9_\.]+' $static $discovered \
| sort | uniq
}
View
@@ -34,6 +34,17 @@ def main(argv):
print('Modules/mathmodule.c')
print('Modules/_math.c')
# Hm OPy needs these for hashlib in 'opy dis-md5'. OK fine.
elif mod_name == '_md5':
print('Modules/md5module.c')
print('Modules/md5.c')
elif mod_name == '_sha':
print('Modules/shamodule.c')
elif mod_name == '_sha256':
print('Modules/sha256module.c')
elif mod_name == '_sha512':
print('Modules/sha512module.c')
elif mod_name == '_io':
# This data is in setup.py and Modules/Setup.dist.
#_io -I$(srcdir)/Modules/_io _io/bufferedio.c _io/bytesio.c
View
@@ -0,0 +1,32 @@
#!/bin/bash
#
# Test stdlib dependencies
#
# Usage:
# ./stdlib.sh <function name>
set -o nounset
set -o pipefail
set -o errexit
# TODO:
# - Test under CPython (need in-tree build)
# - Under OVM? How?
# - Under byterun
# - although I won't use all of every module
# Lib/test/regrtest.py gets ImportError? How are you supposed to run this?
# - I think the out of tree build is fucking things up? You need an
# in-tree build?
oil-deps() {
grep Python _build/oil/opy-app-deps.txt
}
opy-deps() {
#make _bin/opy.ovm
grep Python _build/opy/opy-app-deps.txt
#grep Python _build/opy/app-deps-cpython.txt
}
"$@"

0 comments on commit ef5f1ae

Please sign in to comment.