File: setup_extra.py

package info (click to toggle)
python-pygraphviz 1.3~rc2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 612 kB
  • ctags: 972
  • sloc: ansic: 4,964; python: 2,458; makefile: 125
file content (76 lines) | stat: -rw-r--r-- 2,710 bytes parent folder | download
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
72
73
74
75
76
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Setup helpers for PyGraphviz.
"""
#    Copyright (C) 2006-2010 by 
#    Aric Hagberg <hagberg@lanl.gov>
#    Dan Schult <dschult@colgate.edu>
#    Manos Renieris, http://www.cs.brown.edu/~er/
#    Distributed with BSD license.     
#    All rights reserved, see LICENSE for details.
import os

def pkg_config():
    # attempt to find graphviz installation with pkg-config
    # should work with modern versions of graphviz
    try:
        import subprocess as S
    except ImportError:
        print("""-- Missing subprocess package:
        Install subprocess from
        http://effbot.org/downloads/#subprocess
        or set the graphviz paths manually as described below.""")

    library_path=None
    include_path=None
    try:
        output,err = \
                   S.Popen('pkg-config --libs-only-L libcgraph',
                           shell=True, stdin=S.PIPE, stdout=S.PIPE,
                           close_fds=True).communicate()
        if output:
            library_path=output.strip()[2:]
        output,err = \
                   S.Popen('pkg-config --cflags-only-I libcgraph',
                           shell=True, stdin=S.PIPE, stdout=S.PIPE,
                           close_fds=True).communicate()
        if output:
            include_path=output.strip()[2:]
    except:
        print("Failed to find pkg-config")
    return include_path,library_path

def dotneato_config():
    # find graphviz configuration with dotneato-config
    # works with older versions of graphviz
    # attempt to find graphviz installation with pkg-config
    # should work with modern versions of graphviz
    try:
        import subprocess as S
    except ImportError:
        print("""-- Missing subprocess package:
        Install subprocess from
        http://effbot.org/downloads/#subprocess
        or set the graphviz paths manually as described below.""")
    library_path=None
    include_path=None
    try:
        output = S.Popen(['dotneato-config','--ldflags','--cflags'],
                         stdout=S.PIPE).communicate()[0]
        if output:
            include_path,library_path=output.split()
            library_path=library_path.strip()[2:]
            include_path=include_path.strip()[2:]
        else:
            output = S.Popen(['dotneato-config','--libs','--cflags'],
                         stdout=S.PIPE).communicate()[0]
            if output:
                include_path,library_path=output.split('\n',1)
                library_path=library_path.strip()[2:]
                include_path=include_path.strip()[2:]
    except:
        print("Failed to find dotneato-config")
    return include_path,library_path