[pypy-svn] r33886 - in pypy/dist/pypy/tool/build: . bin

guido at codespeak.net guido at codespeak.net
Mon Oct 30 15:00:15 CET 2006


Author: guido
Date: Mon Oct 30 15:00:12 2006
New Revision: 33886

Modified:
   pypy/dist/pypy/tool/build/bin/client
   pypy/dist/pypy/tool/build/bin/startcompile
   pypy/dist/pypy/tool/build/client.py
   pypy/dist/pypy/tool/build/server.py
   pypy/dist/pypy/tool/build/systemoption.py
Log:
(cfbolz, guido)
Replaced 'config_to_dict()' with 'pypy.config.config.make_dict()', added code
to use PopenGateway instead of SshGateway on localhost. Config is now using the
new PyPy config stuff where appropriate.


Modified: pypy/dist/pypy/tool/build/bin/client
==============================================================================
--- pypy/dist/pypy/tool/build/bin/client	(original)
+++ pypy/dist/pypy/tool/build/bin/client	Mon Oct 30 15:00:12 2006
@@ -7,125 +7,51 @@
 import random
 from pypy.tool.build import config
 
-# example compile_config
-{
-    'translating': False, 
-    'objspace': {
-        'std': {
-            'withstrslice': False, 
-            'withstrdict': False, 
-            'withstrjoin': False, 
-            'oldstyle': False, 
-            'withprebuiltint': False, 
-            'prebuiltintto': 100, 
-            'prebuiltintfrom': -5, 
-            'withsmallint': False
-        }, 
-        'name': 'std', 
-        'usemodules': {
-            '_sre': True, 
-            'errno': True, 
-            '__builtin__': False, 
-            'crypt': False, 
-            'gc': True, 
-            'recparser': True, 
-            'rctime': False, 
-            'array': True, 
-            'select': False, 
-            'mmap': False, 
-            '_socket': False, 
-            'time2': False, 
-            '_stackless': False, 
-            '_pickle_support': True, 
-            '_random': False, 
-            'math': True, 
-            'fcntl': False, 
-            '_ssl': False, 
-            'wraptest': False, 
-            '_codecs': True, 
-            'symbol': True, 
-            'sys': True, 
-            'readline': False, 
-            'unicodedata': True, 
-            'thread': False, 
-            '_weakref': True, 
-            '_md5': False, 
-            'Numeric': False, 
-            'posix': False, 
-            'time': False, 
-            'marshal': True, 
-            '_demo': False
-        }, 
-        'geninterp': True, 
-        'parser': 'pypy', 
-        'uselibfile': False, 
-        'nofaking': False, 
-        'compiler': 'ast'
-    }
-}
+from py.execnet import SshGateway, PopenGateway
+from pypy.tool.build.client import init
+from pypy.config.config import to_optparse, Config
+from pypy.config import pypyoption
+
+if config.server in ['localhost', '127.0.0.1']:
+    gw = PopenGateway()
+else:
+    gw = SshGateway(config.server)
+channel = init(gw, config.system_config, path=config.path,
+                port=config.port)
 
-def info_to_options(info):
-    """temporary solution (until translate.py uses the config stuff) for
-        converting the compile_info dict to pypy translate options
-    """
-    opts = []
-    
-    d = info[0]
-    opts.append('-b %s' % (info[0].get('backend', 'C'),))
-
-    d = info[1]
-    opts.append('-O %s' % (d['objspace']['name'],))
-    opts.append('--usemodules=%s' % 
-                (','.join([k for k, v in 
-                    d['objspace']['usemodules'].items() if v]),))
-
-    return opts
-
-if __name__ == '__main__':
-    from py.execnet import SshGateway, PopenGateway
-    from pypy.tool.build.client import init
-    
-    if config.server in ['localhost', '127.0.0.1']:
-        gw = PopenGateway()
-    else:
-        gw = SshGateway(config.server)
-    channel = init(gw, config.system_config, path=config.path, 
-                    port=config.port)
-
-    print channel.receive() # welcome message
+print channel.receive() # welcome message
+try:
     try:
-        try:
-            while 1:
-                data = channel.receive()
-                if isinstance(data, str):
-                    print data
-                    continue
-                if not isinstance(data, tuple): # needs more checks here
-                    raise ValueError(
-                        'received wrong unexpected data of type %s' % (
-                                type(data),)
-                    )
-                info = data
-                # XXX we should compile here, using data dict for info
-                print 'compilation requested for info %r, now faking that' % (
-                        info,)
-                options = info_to_options(info)
-                print 'options:', options
-
-                import time; time.sleep(10)
-
-                # write the zip to the server in chunks to server
-                # XXX we're still faking this
-                zipfp = (path.packagedir / 'test/test.zip').open()
-                while True:
-                    chunk = zipfp.read(BUFSIZE)
-                    if not chunk:
-                        break
-                    channel.send(chunk)
-                channel.send(None) # tell the server we're done
-                print 'done with compilation, waiting for next'
-        except EOFError:
-            sys.exit()
-    finally:
-        channel.close()
-        gw.exit()
+        while 1:
+            data = channel.receive()
+            if isinstance(data, str):
+                continue
+            if not isinstance(data, tuple): # needs more checks here
+                raise ValueError(
+                    'received wrong unexpected data of type %s' % (
+                            type(data),)
+                )
+            sysinfo, compileinfo = data
+            # XXX we should compile here, using data dict for info
+            print 'compilation requested for info %r, now faking that' % (
+                    data,)
+            config = Config(pypyoption.pypy_optiondescription)
+            config.override(compileinfo)
+
+            # XXX compile here...
+
+            # write the zip to the server in chunks to server
+            # XXX we're still faking this
+            zipfp = (path.packagedir / 'test/test.zip').open()
+            while True:
+                chunk = zipfp.read(BUFSIZE)
+                if not chunk:
+                    break
+                channel.send(chunk)
+            channel.send(None) # tell the server we're done
+            print 'done with compilation, waiting for next'
+    except EOFError:
+        sys.exit()
+finally:
+    channel.close()
+    gw.exit()

Modified: pypy/dist/pypy/tool/build/bin/startcompile
==============================================================================
--- pypy/dist/pypy/tool/build/bin/startcompile	(original)
+++ pypy/dist/pypy/tool/build/bin/startcompile	Mon Oct 30 15:00:12 2006
@@ -7,21 +7,12 @@
 
 def parse_options(config):
     # merge system + compile options into one optionparser
-    from optparse import OptionParser, OptionGroup
+    from py.compat.optparse import OptionParser, OptionGroup
     from pypy.config.config import to_optparse
 
-    optparser = OptionParser()
-    sog = OptionGroup(optparser, 'system', 'System options')
-    system_options = to_optparse(config.system_config, 
-                                    config.system_config.getpaths())
-    [sog.add_option(o) for o in system_options.option_list[1:]]
-    optparser.add_option_group(sog)
+    optparser = to_optparse(config.system_config)
     
-    cog = OptionGroup(optparser, 'compile', 'Compile options')
-    compile_options = to_optparse(config.compile_config, 
-                                    config.compile_config.getpaths())
-    [cog.add_option(o) for o in compile_options.option_list[1:]]
-    optparser.add_option_group(cog)
+    to_optparse(config.compile_config, parser=optparser)
 
     (options, args) = optparser.parse_args()
 
@@ -57,12 +48,12 @@
 
 if __name__ == '__main__':
     from py.execnet import SshGateway, PopenGateway
-    from pypy.tool.build.server import config_to_dict
+    from pypy.config.config import make_dict
 
     optparser, options, args = parse_options(config)
 
-    sysinfo = config_to_dict(config.system_config)
-    compileinfo = config_to_dict(config.compile_config)
+    sysinfo = make_dict(config.system_config)
+    compileinfo = make_dict(config.compile_config)
 
     print 'going to start compile job with info:'
     for k, v in sysinfo.items():

Modified: pypy/dist/pypy/tool/build/client.py
==============================================================================
--- pypy/dist/pypy/tool/build/client.py	(original)
+++ pypy/dist/pypy/tool/build/client.py	Mon Oct 30 15:00:12 2006
@@ -77,11 +77,12 @@
 def init(gw, sysconfig, path=None, port=12321, testing=False):
     from pypy.tool.build import execnetconference
     from pypy.tool.build import server
+    from pypy.config.config import make_dict
     
     if path is None:
         path = []
 
-    sysinfo = server.config_to_dict(sysconfig)
+    sysinfo = make_dict(sysconfig)
     conference = execnetconference.conference(gw, port, False)
     channel = conference.remote_exec(initcode % (path, sysinfo, testing))
     return channel

Modified: pypy/dist/pypy/tool/build/server.py
==============================================================================
--- pypy/dist/pypy/tool/build/server.py	(original)
+++ pypy/dist/pypy/tool/build/server.py	Mon Oct 30 15:00:12 2006
@@ -24,18 +24,6 @@
             return False
     return True
 
-def config_to_dict(config, is_optiondescription=False):
-    from pypy.config.config import OptionDescription
-    ret = {}
-    children = config._descr._children
-    for child in children:
-        value = getattr(config, child._name)
-        if isinstance(child, OptionDescription):
-            ret[child._name] = config_to_dict(value, True)
-        else:
-            ret[child._name] = value
-    return ret
-
 class RequestStorage(object):
     """simple registry that manages information"""
     def __init__(self, info_to_path=[]):

Modified: pypy/dist/pypy/tool/build/systemoption.py
==============================================================================
--- pypy/dist/pypy/tool/build/systemoption.py	(original)
+++ pypy/dist/pypy/tool/build/systemoption.py	Mon Oct 30 15:00:12 2006
@@ -4,10 +4,10 @@
 
 import sys
 system_optiondescription = OptionDescription('system', '', [
-    ChoiceOption('maxint', 'maximum int value in bytes (32/64)', ['32', '64'],
-                    sys.maxint, '-i --maxint'),
+    IntOption('maxint', 'maximum int value', default=sys.maxint),
     ChoiceOption('byteorder', 'endianness, byte order (little/big)',
-                    sys.byteorder, ['little', 'big'], '-b --byteorder'),
-    ChoiceOption('os', 'operating system', ['win32', 'linux'], default=None),
+                 ['little', 'big'], default=sys.byteorder),
+    ChoiceOption('os', 'operating system', ['win32', 'linux2'],
+                 default=sys.platform),
 ])
 



More information about the Pypy-commit mailing list