My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions

Issue 128 attachment: shedskinpypyext.diff (4.1 KB)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
diff --git a/shedskin/cpp.py b/shedskin/cpp.py
index 3c8fc7a..979505c 100644
--- a/shedskin/cpp.py
+++ b/shedskin/cpp.py
@@ -16,6 +16,13 @@ from distutils import sysconfig
from shared import *
import extmod

+_PYPYTPL = """
+#ifdef __ISPYPY
+%s
+#endif
+"""
+_PYPYOPEN, _PYPYCLOSE = (_PYPYTPL % 'extern "C" {', _PYPYTPL % '}')
+
# --- code generation visitor; use type information
class generateVisitor(ASTVisitor):
def __init__(self, module):
@@ -282,8 +289,10 @@ class generateVisitor(ASTVisitor):
self.visitFunction(func.node, declare=True)
print >>self.out

+ print >>self.out, _PYPYOPEN
if getgx().extension_module:
extmod.pyinit_func(self)
+ print >>self.out, _PYPYCLOSE

for n in self.module.mod_path:
print >>self.out, '} // module namespace'
@@ -2879,21 +2888,29 @@ def upgrade_variables():
def generate_code():
ident = getgx().main_module.ident

+ ispypy = hasattr(sys, 'pypy_version_info')
+
if sys.platform == 'win32':
pyver = '%d%d' % sys.version_info[:2]
prefix = sysconfig.get_config_var('prefix').replace('\\', '/')
else:
pyver = sysconfig.get_config_var('VERSION')
- includes = '-I' + sysconfig.get_python_inc() + ' ' + \
- '-I' + sysconfig.get_python_inc(plat_specific=True)
+ pyver = pyver or sysconfig.get_python_version()
+ includes = '-I' + sysconfig.get_python_inc() + ' '
+ if not ispypy:
+ includes += '-I' + sysconfig.get_python_inc(plat_specific=True)
if sys.platform == 'darwin':
ldflags = sysconfig.get_config_var('BASECFLAGS')
else:
- ldflags = sysconfig.get_config_var('LIBS') + ' ' + \
- sysconfig.get_config_var('SYSLIBS') + ' ' + \
- '-lpython'+pyver
+ ldflags = (sysconfig.get_config_var('LIBS') or '') + ' '
+ ldflags += (sysconfig.get_config_var('SYSLIBS') or '') + ' '
+ if not ispypy:
+ ldflags += '-lpython'+pyver
+
if not sysconfig.get_config_var('Py_ENABLE_SHARED'):
- ldflags += ' -L' + sysconfig.get_config_var('LIBPL')
+ libpl = sysconfig.get_config_var('LIBPL')
+ if libpl:
+ ldflags += ' -L' + sysconfig.get_config_var('LIBPL')

if getgx().extension_module:
if sys.platform == 'win32': ident += '.pyd'
@@ -2968,6 +2985,7 @@ def generate_code():
if not getgx().assertions: line += ' -D__SS_NOASSERT'
if getgx().fast_hash: line += ' -D__SS_FASTHASH'
if getgx().longlong: line += ' -D__SS_LONG'
+ if ispypy: line += ' -D__ISPYPY'
if getgx().extension_module:
if getgx().msvc: line += ' /DLL /LIBPATH:%s/libs /LIBPATH:python%s' % (prefix, pyver)
elif sys.platform == 'win32': line += ' -I%s/include -D__SS_BIND' % prefix
diff --git a/shedskin/infer.py b/shedskin/infer.py
index dfa24bf..c13a706 100644
--- a/shedskin/infer.py
+++ b/shedskin/infer.py
@@ -863,7 +863,10 @@ def merge_simple_types(types):
return frozenset(merge)

def analyze(source, testing=False):
- gc.set_threshold(23456, 10, 10)
+ try:
+ gc.set_threshold(23456, 10, 10)
+ except AttributeError:
+ print "Tweaking GC not supported."

if testing:
setgx(newgx())
diff --git a/shedskin/lib/builtin.cpp b/shedskin/lib/builtin.cpp
index f2846d2..d8f5fc5 100644
--- a/shedskin/lib/builtin.cpp
+++ b/shedskin/lib/builtin.cpp
@@ -33,7 +33,9 @@ dict<void *, void *> *__ss_proxy;
void __init() {
GC_INIT();
#ifdef __SS_BIND
+#ifndef __ISPYPY
Py_Initialize();
+#endif
__ss_proxy = new dict<void *, void *>();
#endif

diff --git a/shedskin/lib/builtin.hpp b/shedskin/lib/builtin.hpp
index bf3163e..3cd64f2 100644
--- a/shedskin/lib/builtin.hpp
+++ b/shedskin/lib/builtin.hpp
@@ -3,7 +3,11 @@

#ifdef __SS_BIND
#include <Python.h>
-#endif
+
+#ifdef __ISPYPY
+#include "setobject.h" /* Copy from CPython, likely broken sets using this.*/
+#endif // __ISPYPY
+#endif // __SS_BIND

#include <gc/gc_allocator.h>
#include <gc/gc_cpp.h>
Powered by Google Project Hosting