File: presetup.py

package info (click to toggle)
pypy3 7.0.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 111,848 kB
  • sloc: python: 1,291,746; ansic: 74,281; asm: 5,187; cpp: 3,017; sh: 2,533; makefile: 544; xml: 243; lisp: 45; csh: 21; awk: 4
file content (45 lines) | stat: -rw-r--r-- 1,293 bytes parent folder | download | duplicates (6)
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

""" A distutils-patching tool that allows testing CPython extensions without
building pypy-c.

Run python <this file> setup.py build in your project directory

You can import resulting .so with py.py --allworkingmodules
"""

import sys, os
dn = os.path.dirname
rootdir = dn(dn(dn(dn(__file__))))
sys.path.insert(0, rootdir)
from rpython.tool.udir import udir
pypydir = os.path.join(rootdir, 'pypy')
f = open(os.path.join(str(udir), 'pyconfig.h'), "w")
f.write("\n")
f.close()
sys.path.insert(0, os.getcwd())
from distutils import sysconfig

from pypy.tool.pytest.objspace import gettestobjspace
from pypy.module.cpyext.api import build_bridge
from pypy.module.imp.importing import get_so_extension

usemodules = ['cpyext', 'thread']
if sys.platform == 'win32':
    usemodules.append('_winreg') # necessary in distutils
space = gettestobjspace(usemodules=usemodules)

inc_paths = str(udir)

def get_python_inc(plat_specific=0, prefix=None):
    if plat_specific:
        return str(udir)
    return os.path.join(os.path.dirname(__file__), 'include')

def patch_distutils():
    sysconfig.get_python_inc = get_python_inc
    sysconfig.get_config_vars()['SO'] = get_so_extension(space)

patch_distutils()

del sys.argv[0]
execfile(sys.argv[0], {'__file__': sys.argv[0], '__name__': '__main__'})