[pypy-svn] r79139 - in pypy/release/1.4.x: . lib-python/modified-2.5.2/distutils pypy pypy/config pypy/doc/config pypy/jit/metainterp/optimizeopt pypy/module/array/benchmark pypy/module/array/test pypy/module/cpyext pypy/module/cpyext/test pypy/module/imp pypy/module/imp/test pypy/rlib pypy/rlib/test
fijal at codespeak.net
fijal at codespeak.net
Tue Nov 16 10:31:40 CET 2010
Author: fijal
Date: Tue Nov 16 10:31:37 2010
New Revision: 79139
Added:
pypy/release/1.4.x/pypy/doc/config/objspace.soabi.txt
- copied unchanged from r79138, pypy/trunk/pypy/doc/config/objspace.soabi.txt
Modified:
pypy/release/1.4.x/ (props changed)
pypy/release/1.4.x/lib-python/modified-2.5.2/distutils/sysconfig_pypy.py
pypy/release/1.4.x/pypy/ (props changed)
pypy/release/1.4.x/pypy/config/pypyoption.py
pypy/release/1.4.x/pypy/jit/metainterp/optimizeopt/optimizer.py (props changed)
pypy/release/1.4.x/pypy/module/array/benchmark/Makefile (props changed)
pypy/release/1.4.x/pypy/module/array/benchmark/intimg.c (props changed)
pypy/release/1.4.x/pypy/module/array/benchmark/intimgtst.c (props changed)
pypy/release/1.4.x/pypy/module/array/benchmark/intimgtst.py (props changed)
pypy/release/1.4.x/pypy/module/array/benchmark/loop.c (props changed)
pypy/release/1.4.x/pypy/module/array/benchmark/sum.c (props changed)
pypy/release/1.4.x/pypy/module/array/benchmark/sumtst.c (props changed)
pypy/release/1.4.x/pypy/module/array/benchmark/sumtst.py (props changed)
pypy/release/1.4.x/pypy/module/array/test/test_array_old.py (props changed)
pypy/release/1.4.x/pypy/module/cpyext/presetup.py
pypy/release/1.4.x/pypy/module/cpyext/test/test_cpyext.py
pypy/release/1.4.x/pypy/module/imp/importing.py
pypy/release/1.4.x/pypy/module/imp/interp_imp.py
pypy/release/1.4.x/pypy/module/imp/test/test_app.py
pypy/release/1.4.x/pypy/module/imp/test/test_import.py
pypy/release/1.4.x/pypy/rlib/rerased.py (props changed)
pypy/release/1.4.x/pypy/rlib/test/test_rerased.py (props changed)
Log:
merge PEP 3149 work into release
Modified: pypy/release/1.4.x/lib-python/modified-2.5.2/distutils/sysconfig_pypy.py
==============================================================================
--- pypy/release/1.4.x/lib-python/modified-2.5.2/distutils/sysconfig_pypy.py (original)
+++ pypy/release/1.4.x/lib-python/modified-2.5.2/distutils/sysconfig_pypy.py Tue Nov 16 10:31:37 2010
@@ -3,6 +3,7 @@
import sys
import os
+import imp
from distutils.errors import DistutilsPlatformError
@@ -47,11 +48,17 @@
_config_vars = None
+def _get_so_extension():
+ for ext, mod, typ in imp.get_suffixes():
+ if typ == imp.C_EXTENSION:
+ return ext
+
def _init_posix():
"""Initialize the module as appropriate for POSIX systems."""
g = {}
g['EXE'] = ""
- g['SO'] = ".so"
+ g['SO'] = _get_so_extension() or ".so"
+ g['SOABI'] = g['SO'].rsplit('.')[0]
global _config_vars
_config_vars = g
@@ -61,7 +68,8 @@
"""Initialize the module as appropriate for NT"""
g = {}
g['EXE'] = ".exe"
- g['SO'] = ".pyd"
+ g['SO'] = _get_so_extension() or ".pyd"
+ g['SOABI'] = g['SO'].rsplit('.')[0]
global _config_vars
_config_vars = g
Modified: pypy/release/1.4.x/pypy/config/pypyoption.py
==============================================================================
--- pypy/release/1.4.x/pypy/config/pypyoption.py (original)
+++ pypy/release/1.4.x/pypy/config/pypyoption.py Tue Nov 16 10:31:37 2010
@@ -164,6 +164,11 @@
default=False,
requires=[("objspace.usepycfiles", True)]),
+ StrOption("soabi",
+ "Tag to differentiate extension modules built for different Python interpreters",
+ cmdline="--soabi",
+ default=None),
+
BoolOption("honor__builtins__",
"Honor the __builtins__ key of a module dictionary",
default=False),
Modified: pypy/release/1.4.x/pypy/module/cpyext/presetup.py
==============================================================================
--- pypy/release/1.4.x/pypy/module/cpyext/presetup.py (original)
+++ pypy/release/1.4.x/pypy/module/cpyext/presetup.py Tue Nov 16 10:31:37 2010
@@ -21,6 +21,8 @@
from pypy.conftest import gettestobjspace
from pypy.module.cpyext.api import build_bridge
+from pypy.module.imp.importing import get_so_extension
+
usemodules = ['cpyext', 'thread']
if sys.platform == 'win32':
usemodules.append('_winreg') # necessary in distutils
@@ -35,6 +37,7 @@
def patch_distutils():
sysconfig.get_python_inc = get_python_inc
+ sysconfig.get_config_vars()['SO'] = get_so_extension(space)
patch_distutils()
Modified: pypy/release/1.4.x/pypy/module/cpyext/test/test_cpyext.py
==============================================================================
--- pypy/release/1.4.x/pypy/module/cpyext/test/test_cpyext.py (original)
+++ pypy/release/1.4.x/pypy/module/cpyext/test/test_cpyext.py Tue Nov 16 10:31:37 2010
@@ -42,7 +42,7 @@
raises(ImportError, cpyext.load_module, "missing.file", "foo")
raises(ImportError, cpyext.load_module, self.libc, "invalid.function")
-def compile_module(modname, **kwds):
+def compile_module(space, modname, **kwds):
"""
Build an extension module and return the filename of the resulting native
code file.
@@ -65,10 +65,8 @@
[], eci,
outputfilename=str(dirname/modname),
standalone=False)
- if sys.platform == 'win32':
- pydname = soname.new(purebasename=modname, ext='.pyd')
- else:
- pydname = soname.new(purebasename=modname, ext='.so')
+ from pypy.module.imp.importing import get_so_extension
+ pydname = soname.new(purebasename=modname, ext=get_so_extension(space))
soname.rename(pydname)
return str(pydname)
@@ -153,7 +151,7 @@
kwds["link_files"] = [str(api_library + '.so')]
if sys.platform == 'linux2':
kwds["compile_extra"]=["-Werror=implicit-function-declaration"]
- return compile_module(name, **kwds)
+ return compile_module(self.space, name, **kwds)
def import_module(self, name, init=None, body='', load_it=True, filename=None):
Modified: pypy/release/1.4.x/pypy/module/imp/importing.py
==============================================================================
--- pypy/release/1.4.x/pypy/module/imp/importing.py (original)
+++ pypy/release/1.4.x/pypy/module/imp/importing.py Tue Nov 16 10:31:37 2010
@@ -12,7 +12,7 @@
from pypy.rlib import streamio, jit
from pypy.rlib.streamio import StreamErrors
from pypy.rlib.rarithmetic import intmask
-from pypy.rlib.objectmodel import we_are_translated
+from pypy.rlib.objectmodel import we_are_translated, specialize
SEARCH_ERROR = 0
PY_SOURCE = 1
@@ -25,10 +25,26 @@
# PY_CODERESOURCE = 8
IMP_HOOK = 9
-if sys.platform.startswith('win'):
- so_extension = ".pyd"
+if sys.platform == 'win32':
+ SO = ".pyd"
else:
- so_extension = ".so"
+ SO = ".so"
+DEFAULT_SOABI = 'pypy-14'
+
+ at specialize.memo()
+def get_so_extension(space):
+ if space.config.objspace.soabi is not None:
+ soabi = space.config.objspace.soabi
+ else:
+ soabi = DEFAULT_SOABI
+
+ if not soabi:
+ return SO
+
+ if not space.config.translating:
+ soabi += 'i'
+
+ return '.' + soabi + SO
def find_modtype(space, filepart):
"""Check which kind of module to import for the given filepart,
@@ -53,6 +69,7 @@
return PY_COMPILED, ".pyc", "rb"
if space.config.objspace.usemodules.cpyext:
+ so_extension = get_so_extension(space)
pydfile = filepart + so_extension
if os.path.exists(pydfile) and case_ok(pydfile):
return C_EXTENSION, so_extension, "rb"
Modified: pypy/release/1.4.x/pypy/module/imp/interp_imp.py
==============================================================================
--- pypy/release/1.4.x/pypy/module/imp/interp_imp.py (original)
+++ pypy/release/1.4.x/pypy/module/imp/interp_imp.py Tue Nov 16 10:31:37 2010
@@ -8,10 +8,16 @@
def get_suffixes(space):
w = space.wrap
- return space.newlist([
+ suffixes_w = []
+ if space.config.objspace.usemodules.cpyext:
+ suffixes_w.append(
+ space.newtuple([w(importing.get_so_extension(space)),
+ w('rb'), w(importing.C_EXTENSION)]))
+ suffixes_w.extend([
space.newtuple([w('.py'), w('U'), w(importing.PY_SOURCE)]),
space.newtuple([w('.pyc'), w('rb'), w(importing.PY_COMPILED)]),
])
+ return space.newlist(suffixes_w)
def get_magic(space):
x = importing.get_pyc_magic(space)
Modified: pypy/release/1.4.x/pypy/module/imp/test/test_app.py
==============================================================================
--- pypy/release/1.4.x/pypy/module/imp/test/test_app.py (original)
+++ pypy/release/1.4.x/pypy/module/imp/test/test_app.py Tue Nov 16 10:31:37 2010
@@ -47,6 +47,9 @@
elif mode == self.imp.PY_COMPILED:
assert suffix in ('.pyc', '.pyo')
assert type == 'rb'
+ elif mode == self.imp.C_EXTENSION:
+ assert suffix.endswith(('.pyd', '.so'))
+ assert type == 'rb'
def test_obscure_functions(self):
Modified: pypy/release/1.4.x/pypy/module/imp/test/test_import.py
==============================================================================
--- pypy/release/1.4.x/pypy/module/imp/test/test_import.py (original)
+++ pypy/release/1.4.x/pypy/module/imp/test/test_import.py Tue Nov 16 10:31:37 2010
@@ -473,6 +473,17 @@
except ImportError:
pass
+class TestAbi:
+ def test_abi_tag(self):
+ space1 = gettestobjspace(soabi='TEST')
+ space2 = gettestobjspace(soabi='')
+ if sys.platform == 'win32':
+ assert importing.get_so_extension(space1) == '.TESTi.pyd'
+ assert importing.get_so_extension(space2) == '.pyd'
+ else:
+ assert importing.get_so_extension(space1) == '.TESTi.so'
+ assert importing.get_so_extension(space2) == '.so'
+
def _getlong(data):
x = marshal.dumps(data)
return x[-4:]
More information about the Pypy-commit
mailing list