File: SConscript

package info (click to toggle)
rmlint 2.10.2-0.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,180 kB
  • sloc: ansic: 15,671; python: 9,312; sh: 474; xml: 111; makefile: 72
file content (62 lines) | stat: -rw-r--r-- 1,695 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/env python
# encoding: utf-8

import os


Import('env')


def which(program):
    def is_exe(fpath):
        return os.path.isfile(fpath) and os.access(fpath, os.X_OK)

    fpath, fname = os.path.split(program)
    if fpath:
        if is_exe(program):
            return program
    else:
        for path in os.environ["PATH"].split(os.pathsep):
            path = path.strip('"')
            exe_file = os.path.join(path, program)
            if is_exe(exe_file):
                return exe_file

    return None


if 'install' in COMMAND_LINE_TARGETS and GetOption('with_gui'):
    if not which('python3'):
        print('!! Unable to find python3 executable.')
        print('!! Will build no GUI.')
    else:
        py_install = env.Command(
            'always.install',
            ['setup.py'],
            'cd gui && python3 setup.py install --prefix {} --record .files.txt'.format(
                GetOption('prefix')
            )
        )
        env.Alias('install', py_install)


if 'uninstall' in COMMAND_LINE_TARGETS and GetOption('with_gui'):
    def uninstall_python_module(**kwargs):
        try:
            with open('gui/.files.txt') as handle:
                for path in handle:
                    path = path.strip()
                    try:
                        os.remove(path)
                    except OSError as err:
                        print('Unable to delete', path, ':', err)
        except OSError as err:
            print('Could not open .files.txt: ', err)


    env.Alias('uninstall',
        env.Command(
            'gui/.files.txt', '',
            Action(uninstall_python_module , "Uninstalling recorded files...")
        )
    )