Debian Codegraph @

my_build_ext.py

raw symbols SCIP
1 # this code has been taken from gevent's setup.py file. it provides a
2 # build_ext command that puts .so/.pyd files in-place (like "setup.py
3 # build_ext -i"). it uses symlinks if possible and will rebuild when
4 # changing the python version (unlike "setup.py build_ext -i")
5
6 import sys, os, shutil
7
8 from distutils.command.build_ext import build_ext as _build_ext
9
10
11 def symlink_or_copy(src, dst):
12 if hasattr(os, 'symlink'):
13 try:
14 os.symlink(src, dst)
15 return
16 except OSError: # symbolic link privilege not held??
17 pass
18 except NotImplementedError: # running on XP/'CreateSymbolicLinkW not found'
19 pass
20
21 shutil.copyfile(src, dst)
22
23
24 class build_ext(_build_ext):
25 def build_extension(self, ext):
26 self.inplace = 0
27 _build_ext.build_extension(self, ext)
28 filename = self.get_ext_filename(ext.name)
29 build_path = os.path.abspath(os.path.join(self.build_lib, filename))
30 src_path = os.path.abspath(filename)
31 if build_path != src_path:
32 try:
33 os.unlink(src_path)
34 except OSError:
35 pass
36
37 if self.verbose:
38 sys.stderr.write('Linking %s to %s\n' % (build_path, src_path))
39
40 symlink_or_copy(build_path, src_path)