Author: Maciej Fijalkowski <[email protected]>
Branch: remove-array-smm
Changeset: r64031:fa05eb32023c
Date: 2013-05-13 17:36 +0200
http://bitbucket.org/pypy/pypy/changeset/fa05eb32023c/
Log: merge default
diff --git a/pypy/goal/targetpypystandalone.py
b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -2,6 +2,7 @@
import os, sys
+import pypy
from pypy.interpreter import gateway
from pypy.interpreter.error import OperationError
from pypy.tool.ann_override import PyPyAnnotatorPolicy
@@ -80,6 +81,24 @@
from rpython.rlib.entrypoint import entrypoint
from rpython.rtyper.lltypesystem import rffi
+ @entrypoint('main', [rffi.CCHARP], c_name='pypy_setup_home')
+ def pypy_setup_home(ll_home):
+ from pypy.module.sys.initpath import pypy_find_stdlib
+ if ll_home:
+ home = rffi.charp2str(ll_home)
+ else:
+ home = pypydir
+ pypy_find_stdlib(space, home)
+ space.startup()
+ # import site
+ try:
+ import_ = space.getattr(space.getbuiltinmodule('__builtin__'),
+ space.wrap('__import__'))
+ space.call_function(import_, space.wrap('site'))
+ return 0
+ except OperationError:
+ return 1
+
@entrypoint('main', [rffi.CCHARP], c_name='pypy_execute_source')
def pypy_execute_source(ll_source):
source = rffi.charp2str(ll_source)
@@ -101,7 +120,8 @@
return 1
return 0
- return entry_point, _pypy_execute_source # for tests
+ return entry_point, {'pypy_execute_source': pypy_execute_source,
+ 'pypy_setup_home': pypy_setup_home}
def call_finish(space):
space.finish()
diff --git a/pypy/interpreter/test/test_targetpypy.py
b/pypy/interpreter/test/test_targetpypy.py
--- a/pypy/interpreter/test/test_targetpypy.py
+++ b/pypy/interpreter/test/test_targetpypy.py
@@ -1,5 +1,6 @@
from pypy.goal.targetpypystandalone import get_entry_point, create_entry_point
from pypy.config.pypyoption import get_pypy_config
+from rpython.rtyper.lltypesystem import rffi, lltype
class TestTargetPyPy(object):
def test_run(self):
@@ -8,11 +9,20 @@
entry_point(['pypy-c' , '-S', '-c', 'print 3'])
def test_exeucte_source(space):
- _, execute_source = create_entry_point(space, None)
- execute_source("import sys; sys.modules['xyz'] = 3")
+ _, d = create_entry_point(space, None)
+ execute_source = d['pypy_execute_source']
+ lls = rffi.str2charp("import sys; sys.modules['xyz'] = 3")
+ execute_source(lls)
+ lltype.free(lls, flavor='raw')
x = space.int_w(space.getitem(space.getattr(space.builtin_modules['sys'],
space.wrap('modules')),
space.wrap('xyz')))
assert x == 3
- execute_source("sys")
+ lls = rffi.str2charp("sys")
+ execute_source(lls)
+ lltype.free(lls, flavor='raw')
# did not crash - the same globals
+ pypy_setup_home = d['pypy_setup_home']
+ lls = rffi.str2charp(__file__)
+ pypy_setup_home(lls)
+ lltype.free(lls, flavor='raw')
diff --git a/rpython/rlib/entrypoint.py b/rpython/rlib/entrypoint.py
--- a/rpython/rlib/entrypoint.py
+++ b/rpython/rlib/entrypoint.py
@@ -29,6 +29,7 @@
if not we_are_translated():
import traceback
traceback.print_exc()
+ raise
else:
print str(e)
pypy_debug_catch_fatal_exception()
diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py
--- a/rpython/translator/c/genc.py
+++ b/rpython/translator/c/genc.py
@@ -703,6 +703,8 @@
print >> f, '/***********************************************************/'
print >> f, '/*** Structure definitions ***/'
print >> f
+ print >> f, "#ifndef _PYPY_STRUCTDEF_H"
+ print >> f, "#define _PYPY_STRUCTDEF_H"
for node in structdeflist:
if hasattr(node, 'forward_decl'):
if node.forward_decl:
@@ -713,14 +715,18 @@
for node in structdeflist:
for line in node.definition():
print >> f, line
+ print >> f, "#endif"
def gen_forwarddecl(f, database):
print >> f, '/***********************************************************/'
print >> f, '/*** Forward declarations ***/'
print >> f
+ print >> f, "#ifndef _PYPY_FORWARDDECL_H"
+ print >> f, "#define _PYPY_FORWARDDECL_H"
for node in database.globalcontainers():
for line in node.forward_declaration():
print >> f, line
+ print >> f, "#endif"
def gen_preimpl(f, database):
if database.translator is None or database.translator.rtyper is None:
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit