[pypy-svn] r75683 - in pypy/trunk: include lib-python/modified-2.5.2/distutils lib-python/modified-2.5.2/distutils/command pypy/_interfaces pypy/module/cpyext pypy/module/cpyext/test

antocuni at codespeak.net antocuni at codespeak.net
Wed Jun 30 16:51:14 CEST 2010


Author: antocuni
Date: Wed Jun 30 16:51:13 2010
New Revision: 75683

Added:
   pypy/trunk/include/   (props changed)
   pypy/trunk/include/README
Removed:
   pypy/trunk/pypy/_interfaces/
Modified:
   pypy/trunk/lib-python/modified-2.5.2/distutils/command/build_ext.py
   pypy/trunk/lib-python/modified-2.5.2/distutils/sysconfig_pypy.py
   pypy/trunk/pypy/module/cpyext/api.py
   pypy/trunk/pypy/module/cpyext/test/test_api.py
Log:
create a directory trunk/include to contains all the headers file. They are
automatically copied there from cpyext/include during translation. The
generated pypy_decl.h and pypy_macros.h are also put there, instead of the
now-gone pypy/_interfaces.

The goal is to have the svn checkout as similar as possible as release
tarballs and virtualenvs, which have an include/ dir at the top



Added: pypy/trunk/include/README
==============================================================================
--- (empty file)
+++ pypy/trunk/include/README	Wed Jun 30 16:51:13 2010
@@ -0,0 +1,7 @@
+This directory contains all the include files needed to build cpython
+extensions with PyPy.  Note that these are just copies of the original headers
+that are in pypy/module/cpyext/include: they are automatically copied from
+there during translation.
+
+Moreover, pypy_decl.h and pypy_macros.h are automatically generated, also
+during translation.

Modified: pypy/trunk/lib-python/modified-2.5.2/distutils/command/build_ext.py
==============================================================================
--- pypy/trunk/lib-python/modified-2.5.2/distutils/command/build_ext.py	(original)
+++ pypy/trunk/lib-python/modified-2.5.2/distutils/command/build_ext.py	Wed Jun 30 16:51:13 2010
@@ -167,7 +167,7 @@
         # for Release and Debug builds.
         # also Python's library directory must be appended to library_dirs
         if os.name == 'nt':
-            self.library_dirs.append(os.path.join(sys.prefix, 'pypy', '_interfaces'))
+            self.library_dirs.append(os.path.join(sys.prefix, 'include'))
             if self.debug:
                 self.build_temp = os.path.join(self.build_temp, "Debug")
             else:

Modified: pypy/trunk/lib-python/modified-2.5.2/distutils/sysconfig_pypy.py
==============================================================================
--- pypy/trunk/lib-python/modified-2.5.2/distutils/sysconfig_pypy.py	(original)
+++ pypy/trunk/lib-python/modified-2.5.2/distutils/sysconfig_pypy.py	Wed Jun 30 16:51:13 2010
@@ -13,12 +13,7 @@
 
 def get_python_inc(plat_specific=0, prefix=None):
     from os.path import join as j
-    cand = j(sys.prefix, 'include')
-    if os.path.exists(cand):
-        return cand
-    if plat_specific:
-        return j(sys.prefix, "pypy", "_interfaces")
-    return j(sys.prefix, 'pypy', 'module', 'cpyext', 'include')
+    return j(sys.prefix, 'include')
 
 def get_python_version():
     """Return a string containing the major and minor Python version,

Modified: pypy/trunk/pypy/module/cpyext/api.py
==============================================================================
--- pypy/trunk/pypy/module/cpyext/api.py	(original)
+++ pypy/trunk/pypy/module/cpyext/api.py	Wed Jun 30 16:51:13 2010
@@ -45,11 +45,9 @@
 pypydir = py.path.local(autopath.pypydir)
 include_dir = pypydir / 'module' / 'cpyext' / 'include'
 source_dir = pypydir / 'module' / 'cpyext' / 'src'
-interfaces_dir = pypydir / "_interfaces"
 include_dirs = [
     include_dir,
     udir,
-    interfaces_dir,
     ]
 
 class CConfig:
@@ -100,9 +98,16 @@
 udir.join('pypy_macros.h').write("/* Will be filled later */")
 globals().update(rffi_platform.configure(CConfig_constants))
 
-def copy_header_files():
+def copy_header_files(dstdir):
+    assert dstdir.check(dir=True)
+    headers = include_dir.listdir('*.h') + include_dir.listdir('*.inl')
     for name in ("pypy_decl.h", "pypy_macros.h"):
-        udir.join(name).copy(interfaces_dir / name)
+        headers.append(udir.join(name))
+    for header in headers:
+        header.copy(dstdir)
+        target = dstdir.join(header.basename)
+        target.chmod(0444) # make the file read-only, to make sure that nobody
+                           # edits it by mistake
 
 _NOT_SPECIFIED = object()
 CANNOT_FAIL = object()
@@ -881,7 +886,8 @@
         deco(func.get_wrapper(space))
 
     setup_init_functions(eci)
-    copy_header_files()
+    trunk_include = pypydir.dirpath() / 'include'
+    copy_header_files(trunk_include)
 
 initfunctype = lltype.Ptr(lltype.FuncType([], lltype.Void))
 @unwrap_spec(ObjSpace, str, str)

Modified: pypy/trunk/pypy/module/cpyext/test/test_api.py
==============================================================================
--- pypy/trunk/pypy/module/cpyext/test/test_api.py	(original)
+++ pypy/trunk/pypy/module/cpyext/test/test_api.py	Wed Jun 30 16:51:13 2010
@@ -1,3 +1,4 @@
+import py
 from pypy.conftest import gettestobjspace
 from pypy.rpython.lltypesystem import rffi, lltype
 from pypy.interpreter.baseobjspace import W_Root
@@ -68,3 +69,13 @@
         api.PyPy_GetWrapped(space.w_None)
         api.PyPy_GetReference(space.w_None)
 
+
+def test_copy_header_files(tmpdir):
+    api.copy_header_files(tmpdir)
+    def check(name):
+        f = tmpdir.join(name)
+        assert f.check(file=True)
+        py.test.raises(py.error.EACCES, "f.open('w')") # check that it's not writable
+    check('Python.h')
+    check('modsupport.inl')
+    check('pypy_decl.h')



More information about the Pypy-commit mailing list