File: getnightly.py

package info (click to toggle)
pypy3 7.3.11%2Bdfsg-2%2Bdeb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 201,024 kB
  • sloc: python: 1,950,308; ansic: 517,580; sh: 21,417; asm: 14,419; cpp: 4,263; makefile: 4,228; objc: 761; xml: 530; exp: 499; javascript: 314; pascal: 244; lisp: 45; csh: 11; awk: 4
file content (69 lines) | stat: -rwxr-xr-x 1,825 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python
from __future__ import print_function
import sys
import os
import subprocess
import tempfile

TAR_OPTIONS = '-x -v --strip-components=2'
TAR = 'tar {options} -f {tarfile} {files}'

def untar(tarfile, files):
    cmd = TAR.format(options=TAR_OPTIONS, tarfile=tarfile, files=files)
    os.system(cmd)

if sys.platform.startswith('linux'):
    arch = 'linux'
    cmd = 'wget "%s"'
    TAR_OPTIONS += ' --wildcards'
    binfiles = "'*/bin/pypy3*' '*/bin/libpypy3-c.so*'"
    if os.uname()[-1].startswith('arm'):
        arch += '-armhf-raspbian'
elif sys.platform.startswith('darwin'):
    arch = 'osx'
    cmd = 'curl -O "%s"'
    binfiles = "'*/bin/pypy3'"
else:
    print('Cannot determine the platform, please update this script')
    sys.exit(1)

if sys.maxsize == 2**63 - 1:
    arch += '64'

branch = subprocess.check_output(['hg', 'branch']).strip().decode('utf-8')
if branch == 'default':
    branch = 'trunk'

if '--nojit' in sys.argv:
    kind = 'nojit'
else:
    kind = 'jit'

filename = 'pypy-c-%s-latest-%s.tar.bz2' % (kind, arch)
url = 'http://buildbot.pypy.org/nightly/%s/%s' % (branch, filename)
tmp = tempfile.mkdtemp()
pypy_latest = os.path.join(tmp, filename)
olddir = os.getcwd()
mydir = os.chdir(tmp)
print('Downloading pypy to', tmp)
if os.system(cmd % url) != 0:
    sys.exit(1)

mydir = os.path.dirname(__file__)
print('Extracting pypy binary')
os.chdir(mydir)
untar(pypy_latest, binfiles)
include_dir = os.path.join(mydir, '..', '..', 'include')
lib_dir = os.path.join(mydir, '..', 'lib')
if os.path.isdir(include_dir):
    os.chdir(include_dir)
    untar(pypy_latest, '*/include/*')
else:
    print('WARNING: could not find the include/ dir')
os.chdir(olddir)
if not os.path.exists(lib_dir):
    os.mkdir(lib_dir)
os.chdir(lib_dir)
untar(pypy_latest, '*/lib/*')
os.chdir(olddir)