forked from pygraphviz/pygraphviz
/
setup.py
164 lines (133 loc) · 4.71 KB
/
setup.py
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Setup script for PyGraphviz
"""
# Copyright (C) 2006-2013 by
# Aric Hagberg <aric.hagberg@gmail.com>
# Dan Schult <dschult@colgate.edu>
# Manos Renieris, http://www.cs.brown.edu/~er/
# Distributed with BSD license.
# All rights reserved, see LICENSE for details.
from __future__ import print_function
from glob import glob
import os
import sys
if os.path.exists('MANIFEST'):
os.remove('MANIFEST')
from setuptools import setup, Extension
from setup_extra import pkg_config, dotneato_config
if sys.argv[-1] == 'setup.py':
print("To install, run 'python setup.py install'")
print()
kwargs = {}
if sys.version_info[:2] < (2, 4):
print("PyGraphviz requires Python version 2.4 or later (%d.%d detected)." %
sys.version_info[:2])
sys.exit(-1)
elif sys.version_info[0] >= 3:
print('Converting code to Python 3 helped by 2to3')
kwargs['use_2to3'] = True
include_dirs = None
library_dirs = None
define_macros = []
# If the setup script couldn't find your graphviz installation you can
# specify it here by uncommenting these lines or providing your own:
# You must set both 'library_dirs' and 'include_dirs'
# Linux, generic UNIX
#library_dirs='/usr/lib/graphviz'
#include_dirs='/usr/include/graphviz'
# OSX, Linux, alternate location
#library_dirs='/usr/local/lib/graphviz'
#include_dirs='/usr/local/include/graphviz'
# OSX (Fink)
#library_dirs='/sw/lib/graphviz'
#include_dirs='/sw/include/graphviz'
# OSX (MacPorts)
#library_dirs='/opt/local/lib/graphviz'
#include_dirs='/opt/local/include/graphviz'
# Windows
# Unknown - use command line -I and -L switches to set
if sys.platform == "win32":
define_macros.append(('GVDLL', None))
else:
# Attempt to find Graphviz installation
if library_dirs is None and include_dirs is None:
print("Trying pkg-config")
include_dirs, library_dirs = pkg_config()
if library_dirs is None and include_dirs is None:
print("Trying dotneato-config")
include_dirs, library_dirs = dotneato_config()
if library_dirs is None or include_dirs is None:
print()
print("""Your Graphviz installation could not be found.)
1) You don't have Graphviz installed:
Install Graphviz (http://graphviz.org)
2) Your Graphviz package might incomplete.
Install the binary development subpackage (e.g. libgraphviz-dev or similar.)
3) You are using Windows
There are no PyGraphviz binary packages for Windows but you might be
able to build it from this source. See
http://networkx.lanl.gov/pygraphviz/reference/faq.html
If you think your installation is correct you will need to manually
change the include_dirs and library_dirs variables in setup.py to
point to the correct locations of your graphviz installation.
The current setting of library_dirs and include_dirs is:""")
print("library_dirs=%s" % library_dirs)
print("include_dirs=%s" % include_dirs)
print()
raise OSError("Error locating graphviz.")
print("library_dirs=%s" % library_dirs)
print("include_dirs=%s" % include_dirs)
if library_dirs:
library_dirs = [library_dirs]
if include_dirs:
include_dirs = [include_dirs]
# Write the version information.
sys.path.insert(0, 'pygraphviz')
import release
release.write_versionfile()
sys.path.pop(0)
packages = ["pygraphviz", "pygraphviz.tests"]
docdirbase = 'share/doc/pygraphviz-%s' % release.version
data = [
(docdirbase, glob("*.txt")),
(os.path.join(docdirbase, 'examples'), glob("examples/*.py")),
(os.path.join(docdirbase, 'examples'), glob("examples/*.dat")),
(os.path.join(docdirbase, 'examples'), glob("examples/*.dat.gz")),
]
extension_args = {}
if sys.platform != "win32":
extension_args['runtime_library_dirs'] = library_dirs
extension = [
Extension(
"pygraphviz._graphviz",
["pygraphviz/graphviz_wrap.c"],
include_dirs=include_dirs,
library_dirs=library_dirs,
libraries=["cgraph", "cdt"],
define_macros=define_macros,
**extension_args
)
]
package_data = {'': ['*.txt'], }
if __name__ == "__main__":
setup(
name=release.name,
version=release.version,
author=release.authors['Hagberg'][0],
author_email=release.authors['Hagberg'][1],
description=release.description,
keywords=release.keywords,
long_description=release.long_description,
license=release.license,
platforms=release.platforms,
url=release.url,
download_url=release.download_url,
classifiers=release.classifiers,
packages=packages,
data_files=data,
ext_modules=extension,
package_data=package_data,
**kwargs
)