Commit 75e486ce authored by Antonio Cuni's avatar Antonio Cuni

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
parent f2ca8f37
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.
......@@ -167,7 +167,7 @@ class build_ext (Command):
# 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:
......
......@@ -13,12 +13,7 @@ python_build = False
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,
......
......@@ -45,11 +45,9 @@ ADDR = lltype.Signed
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_decl.h').write("/* Will be filled later */")
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 @@ def setup_library(space):
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)
......
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 @@ class TestConversion(BaseApiTest):
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')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment