File: build_cexe.py

package info (click to toggle)
obitools 1.2.13%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,652 kB
  • sloc: python: 18,199; ansic: 1,542; makefile: 98
file content (71 lines) | stat: -rw-r--r-- 2,386 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
70
71
'''
Created on 20 oct. 2012

@author: coissac
'''

from obidistutils.command.build_ctools import build_ctools
from distutils.errors import DistutilsSetupError


class build_cexe(build_ctools):

    description = "build C/C++ executable distributed with Python extensions"


    def initialize_options(self):
        build_ctools.initialize_options(self)
        self.built_files = None


    def finalize_options(self):
        # This might be confusing: both build-cexe and build-temp default
        # to build-temp as defined by the "build" command.  This is because
        # I think that C libraries are really just temporary build
        # by-products, at least from the point of view of building Python
        # extensions -- but I want to keep my options open.

        build_cexe_dir = self.build_cexe
        build_ctools.finalize_options(self)

        if build_cexe_dir is None:
            self.build_cexe=None
            
        self.set_undefined_options('build',
                                   ('build_scripts',  'build_cexe'))

        self.set_undefined_options('build_files',
                                   ('files',  'built_files'))
                   
        self.executables = self.distribution.executables

        if self.executables:
            self.check_executable_list(self.executables)
                            

        # XXX same as for build_ext -- what about 'self.define' and
        # 'self.undef' ?

    def substitute_sources(self,exe_name,sources):
        """
        Substitutes source file name starting by an @ by the actual
        name of the built file (see --> build_files)
        """
        sources = list(sources)
        for i in range(len(sources)):
            print(exe_name,sources[i], end=' ')
            if sources[i][0]=='@':
                try:
                    filename = self.built_files[sources[i][1:]]
                except KeyError:
                    raise DistutilsSetupError(('The %s filename declared in the source '
                         'files of the program %s have not been '
                         'built by the installation process') % (sources[i],
                                                                 exe_name))
                sources[i]=filename
                print("changed to ",filename)
            else:
                print(" ok")

        return sources