Re: [pypy-dev] [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
Hey. Any reason why we should copy .h files during translation and can't just have them there? Cheers, fijal On Wed, Jun 30, 2010 at 8:51 AM, <antocuni@codespeak.net> wrote:
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') _______________________________________________ pypy-svn mailing list pypy-svn@codespeak.net http://codespeak.net/mailman/listinfo/pypy-svn
On 02/07/10 08:45, Maciej Fijalkowski wrote:
Hey.
Any reason why we should copy .h files during translation and can't just have them there?
I talked with Amaury and he told me that he prefers to keep all the cpyext-related files together, which I think makes sense. Moreover, we need to generate© pypy_decl.h and pypy_macros.h anyway, so we can copy the others as well while we are at it. ciao, Anto
On Fri, Jul 2, 2010 at 1:21 AM, Antonio Cuni <anto.cuni@gmail.com> wrote:
On 02/07/10 08:45, Maciej Fijalkowski wrote:
Hey.
Any reason why we should copy .h files during translation and can't just have them there?
I talked with Amaury and he told me that he prefers to keep all the cpyext-related files together, which I think makes sense. Moreover, we need to generate© pypy_decl.h and pypy_macros.h anyway, so we can copy the others as well while we are at it.
ciao, Anto
Fine by me. Can you fix test_package then? It assumes there is Python.h in include (which might not be there).
On 02/07/10 09:28, Maciej Fijalkowski wrote:
Fine by me. Can you fix test_package then? It assumes there is Python.h in include (which might not be there).
ah right... because when we run own-test translation didn't happen, so .h are not there. Ok, I'll fix it later. ciao, Anto
participants (2)
-
Antonio Cuni -
Maciej Fijalkowski