Author: Matti Picus <[email protected]>
Branch: msvc14
Changeset: r93715:cbe8d91c8cc5
Date: 2018-01-29 19:02 +0200
http://bitbucket.org/pypy/pypy/changeset/cbe8d91c8cc5/
Log: add externals and vsver to MSvcPlatform, add external build
dependencies repo
diff --git a/get_externals.py b/get_externals.py
new file mode 100644
--- /dev/null
+++ b/get_externals.py
@@ -0,0 +1,66 @@
+'''Get external dependencies for building PyPy
+they will end up in the platform.host().basepath, something like
repo-root/external
+'''
+
+from __future__ import print_function
+
+import argparse
+import os
+import zipfile
+from subprocess import Popen, PIPE
+from rpython.translator.platform import host
+
+def runcmd(cmd, verbose):
+ stdout = stderr = ''
+ report = False
+ try:
+ p = Popen(cmd, stdout=PIPE, stderr=PIPE)
+ stdout, stderr = p.communicate()
+ if p.wait() != 0 or verbose:
+ report = True
+ except Exception as e:
+ stderr = str(e) + '\n' + stderr
+ report = True
+ if report:
+ print('running "%s" returned\n%s\n%s' % (cmd, stdout, stderr))
+ if stderr:
+ raise RuntimeError(stderr)
+
+def checkout_repo(dest='externals', org='pypy', branch='default',
verbose=False):
+ url = 'https://bitbucket.org/{}/externals'.format(org)
+ if not os.path.exists(dest):
+ cmd = ['hg','clone',url,dest]
+ runcmd(cmd, verbose)
+ cmd = ['hg','-R', dest, 'update',branch]
+ runcmd(cmd, verbose)
+
+def extract_zip(externals_dir, zip_path):
+ with zipfile.ZipFile(os.fspath(zip_path)) as zf:
+ zf.extractall(os.fspath(externals_dir))
+ return externals_dir / zf.namelist()[0].split('/')[0]
+
+def parse_args():
+ p = argparse.ArgumentParser()
+ p.add_argument('-v', '--verbose', action='store_true')
+ p.add_argument('-O', '--organization',
+ help='Organization owning the deps repos', default='pypy')
+ p.add_argument('-e', '--externals', default=host.externals,
+ help='directory in which to store dependencies',
+ )
+ p.add_argument('-b', '--branch', default=host.external_branch,
+ help='branch to check out',
+ )
+ return p.parse_args()
+
+
+def main():
+ args = parse_args()
+ checkout_repo(
+ dest=args.externals,
+ org=args.organization,
+ branch=args.branch,
+ verbose=args.verbose,
+ )
+
+if __name__ == '__main__':
+ main()
diff --git a/rpython/translator/platform/__init__.py
b/rpython/translator/platform/__init__.py
--- a/rpython/translator/platform/__init__.py
+++ b/rpython/translator/platform/__init__.py
@@ -37,7 +37,10 @@
class Platform(object):
name = "abstract platform"
c_environ = None
-
+ # which branch to check out in get_external.py
+ externals_branch='default'
+ # where to put the externals, as an absolute path
+ externals = str(py.path.local(__file__).parts()[-5] / 'externals')
relevant_environ = ()
log_errors = True
diff --git a/rpython/translator/platform/windows.py
b/rpython/translator/platform/windows.py
--- a/rpython/translator/platform/windows.py
+++ b/rpython/translator/platform/windows.py
@@ -101,7 +101,7 @@
for vsver in vcvers:
env = _get_msvc_env(vsver, x64flag)
if env is not None:
- return env
+ return env, vsver
log.error("Could not find a Microsoft Compiler")
# Assume that the compiler is already part of the environment
@@ -129,7 +129,6 @@
return f
return None
-
class MsvcPlatform(Platform):
name = "msvc"
so_ext = 'dll'
@@ -152,9 +151,14 @@
def __init__(self, cc=None, x64=False):
self.x64 = x64
if cc is None:
- msvc_compiler_environ = find_msvc_env(x64)
+ msvc_compiler_environ, self.vsver = find_msvc_env(x64)
Platform.__init__(self, 'cl.exe')
if msvc_compiler_environ:
+ if x64:
+ self.external_branch = 'win34_%d' % self.vsver
+ else:
+ self.external_branch = 'win32_%d' % self.vsver
+ patch_env(msvc_compiler_environ, self.externals)
self.c_environ = os.environ.copy()
self.c_environ.update(msvc_compiler_environ)
else:
@@ -509,6 +513,15 @@
self._handle_error(returncode, stdout, stderr, path.join('make'))
+# These are the external libraries, created and maintained by get_externals.py
+# The buildbot runs get_externals before building
+def patch_env(env, externals = Platform.externals):
+ #print 'adding %s to PATH, INCLUDE, LIB' % basepath
+ env['PATH'] = externals + r'\bin;' + env.get('PATH', '')
+ env['INCLUDE'] = externals + r'\include;' + env.get('INCLUDE', '')
+ env['LIB'] = externals + r'\lib;' + env.get('LIB', '')
+ return None
+
class WinDefinition(posix.Definition):
def write(self, f):
def write_list(prefix, lst):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit