Commits

Alex Gaynor  committed e797f76 Merge

merged upstream

  • Participants
  • Parent commits 781d223, cee23d5

Comments (0)

Files changed (14)

File lib_pypy/_pypy_testcapi.py

     # set link options
     output_filename = modulename + _get_c_extension_suffix()
     if sys.platform == 'win32':
-        # XXX libpypy-c.lib is currently not installed automatically
-        library = os.path.join(thisdir, '..', 'include', 'libpypy-c')
+        # XXX pyconfig.h uses a pragma to link to the import library,
+        #     which is currently python27.lib
+        library = os.path.join(thisdir, '..', 'include', 'python27')
         if not os.path.exists(library + '.lib'):
-            #For a nightly build
-            library = os.path.join(thisdir, '..', 'include', 'python27')
-        if not os.path.exists(library + '.lib'):
-            # For a local translation
-            library = os.path.join(thisdir, '..', 'pypy', 'goal', 'libpypy-c')
+            # For a local translation or nightly build
+            library = os.path.join(thisdir, '..', 'pypy', 'goal', 'python27')
+        assert os.path.exists(library + '.lib'),'Could not find import library "%s"' % library
         libraries = [library, 'oleaut32']
         extra_ldargs = ['/MANIFEST',  # needed for VC10
                         '/EXPORT:init' + modulename]

File pypy/doc/whatsnew-head.rst

 
 .. branch: voidtype_strformat
 Better support for record numpy arrays
+
+.. branch: osx-eci-frameworks-makefile
+OSX: Ensure frameworks end up in Makefile when specified in External compilation info
+

File pypy/module/_cffi_backend/cdataobj.py

     def get_array_length(self):
         return self.length
 
+    def _sizeof(self):
+        from pypy.module._cffi_backend.ctypeptr import W_CTypePtrOrArray
+        ctype = self.ctype
+        assert isinstance(ctype, W_CTypePtrOrArray)
+        return self.length * ctype.ctitem.size
+
 
 class W_CDataHandle(W_CData):
     _attrs_ = ['w_keepalive']

File pypy/module/_cffi_backend/test/_backend_test_c.py

     py.test.raises(TypeError, "p + cast(new_primitive_type('int'), 42)")
     py.test.raises(TypeError, "p - cast(new_primitive_type('int'), 42)")
 
+def test_sizeof_sliced_array():
+    BInt = new_primitive_type("int")
+    BArray = new_array_type(new_pointer_type(BInt), 10)
+    p = newp(BArray, None)
+    assert sizeof(p[2:9]) == 7 * sizeof(BInt)
+
 
 def test_version():
     # this test is here mostly for PyPy

File rpython/config/translationoption.py

 import sys
+import os
 from rpython.config.config import OptionDescription, BoolOption, IntOption, ArbitraryOption, FloatOption
 from rpython.config.config import ChoiceOption, StrOption, Config
 from rpython.config.config import ConfigError
 
 IS_64_BITS = sys.maxint > 2147483647
 
+MAINDIR = os.path.dirname(os.path.dirname(__file__))
+CACHE_DIR = os.path.realpath(os.path.join(MAINDIR, '_cache'))
+
 PLATFORMS = [
     'maemo',
     'host',

File rpython/conftest.py

 pytest_plugins = 'rpython.tool.pytest.expecttest'
 
 cdir = realpath(join(dirname(__file__), 'translator', 'c'))
-cache_dir = realpath(join(dirname(__file__), '_cache'))
 option = None
 
 def braindead_deindent(self):

File rpython/rlib/test/test_rstacklet.py

             h = self.sthread.new(switchbackonce_callback,
                                  rffi.cast(llmemory.Address, 321))
             # 'h' ignored
-            if (i % 5000) == 2500:
-                rgc.collect()
+            if (i % 2000) == 1000:
+                rgc.collect()  # This should run in < 1.5GB virtual memory
 
     def any_alive(self):
         for task in self.tasks:

File rpython/tool/gcc_cache.py

-from rpython.translator.platform import CompilationError
-from rpython.conftest import cache_dir
 from hashlib import md5
 import py, os
 
-cache_dir_root = py.path.local(cache_dir).ensure(dir=1)
-
 def cache_file_path(c_files, eci, cachename):
     "Builds a filename to cache compilation data"
     # Import 'platform' every time, the compiler may have been changed
     from rpython.translator.platform import platform
-    cache_dir = cache_dir_root.join(cachename).ensure(dir=1)
+    from rpython.config.translationoption import CACHE_DIR
+    cache_root = py.path.local(CACHE_DIR).ensure(dir=1)
+    cache_dir = cache_root.join(cachename).ensure(dir=1)
     filecontents = [c_file.read() for c_file in c_files]
     key = repr((filecontents, eci, platform.key()))
     hash = md5(key).hexdigest()

File rpython/tool/test/test_gcc_cache.py

 import sys
-from rpython.tool.gcc_cache import *
+import cStringIO
+import py
 from rpython.tool.udir import udir
-import md5, cStringIO
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
+from rpython.translator.platform import CompilationError
+from rpython.tool.gcc_cache import (
+    cache_file_path, build_executable_cache, try_compile_cache)
 
 localudir = udir.join('test_gcc_cache').ensure(dir=1)
 
     finally:
         sys.stderr = oldstderr
     assert 'ERROR' not in capture.getvalue().upper()
-    

File rpython/translator/driver.py

         return py.path.local(newexename)
 
     def create_exe(self):
-        """ Copy the compiled executable into translator/goal
+        """ Copy the compiled executable into current directory, which is
+            pypy/goal on nightly builds
         """
         if self.exe_name is not None:
             exename = self.c_entryp
                 shutil.copy(str(soname), str(newsoname))
                 self.log.info("copied: %s" % (newsoname,))
                 if sys.platform == 'win32':
-                    shutil.copyfile(str(soname.new(ext='lib')),
-                                    str(newsoname.new(ext='lib')))
+                    # the import library is named python27.lib, according
+                    # to the pragma in pyconfig.h
+                    libname = str(newsoname.dirpath().join('python27.lib'))
+                    shutil.copyfile(str(soname.new(ext='lib')), libname)
+                    self.log.info("copied: %s" % (libname,))
             self.c_entryp = newexename
         self.log.info('usession directory: %s' % (udir,))
         self.log.info("created: %s" % (self.c_entryp,))

File rpython/translator/goal/translate.py

 
 import os
 import sys
-from rpython.conftest import cache_dir
-
 import py
-# clean up early rpython/_cache
-try:
-    py.path.local(cache_dir).remove()
-except Exception:
-    pass
-
 from rpython.config.config import (to_optparse, OptionDescription, BoolOption,
     ArbitraryOption, StrOption, IntOption, Config, ChoiceOption, OptHelpFormatter)
 from rpython.config.translationoption import (get_combined_translation_config,
-    set_opt_level, OPT_LEVELS, DEFAULT_OPT_LEVEL, set_platform)
+    set_opt_level, OPT_LEVELS, DEFAULT_OPT_LEVEL, set_platform, CACHE_DIR)
+
+# clean up early rpython/_cache
+try:
+    py.path.local(CACHE_DIR).remove()
+except Exception:
+    pass
 
 
 GOALS = [

File rpython/translator/test/test_driver.py

 import py
-
+import os
 from rpython.translator.driver import TranslationDriver
+from rpython.tool.udir import udir 
 
 def test_ctr():
     td = TranslationDriver()
                 'compile_c', 'pyjitpl']
 
     assert set(td.exposed) == set(expected)
+
+
+def test_create_exe():
+    if not os.name == 'nt':
+        py.test.skip('Windows only test')
+
+    dst_name = udir.join('dst/pypy.exe')
+    src_name = udir.join('src/dydy2.exe')
+    dll_name = udir.join('src/pypy.dll')
+    lib_name = udir.join('src/pypy.lib')
+    src_name.ensure()
+    src_name.write('exe')
+    dll_name.ensure()
+    dll_name.write('dll')
+    lib_name.ensure()
+    lib_name.write('lib')
+    dst_name.ensure()
+
+    class CBuilder(object):
+        shared_library_name = dll_name 
+
+    td = TranslationDriver(exe_name=str(dst_name))
+    td.c_entryp = str(src_name)
+    td.cbuilder = CBuilder()
+    td.create_exe()
+    assert dst_name.read() == 'exe'
+    assert dst_name.new(ext='dll').read() == 'dll'
+    assert dst_name.new(purebasename='python27',ext='lib').read() == 'lib'
+
+

File testrunner/runner.py

             else:
                 msg = "Killed by %s." % getsignalname(-exitcode)
             extralog = "! %s\n %s\n" % (test, msg)
+        else:
+            extralog = "  (somefailed=True in %s)\n" % (test,)
     else:
         failure = False
     return failure, extralog
         done += 1
         failure = failure or somefailed
 
-        heading = "__ %s [%d done in total] " % (testname, done)
+        heading = "__ %s [%d done in total, somefailed=%s] " % (
+            testname, done, somefailed)
         
         out.write(heading + (79-len(heading))*'_'+'\n')
 

File testrunner/test/test_runner.py

 
         failure, extralog = runner.interpret_exitcode(1, "test_foo", "F Foo\n")
         assert failure
-        assert extralog == ""
+        assert extralog == "  (somefailed=True in test_foo)\n"
 
         failure, extralog = runner.interpret_exitcode(2, "test_foo")
         assert failure