|
1 | | -#!/usr/bin/env python |
2 | | -descr = """Python Control Systems Library |
| 1 | +from setuptools import setup, find_packages |
3 | 2 |
|
4 | | -The Python Control Systems Library, python-control, |
5 | | -is a python module that implements basic operations |
6 | | -for analysis and design of feedback control systems. |
| 3 | +ver = {} |
| 4 | +try: |
| 5 | + with open('control/_version.py') as fd: |
| 6 | + exec(fd.read(), ver) |
| 7 | + version = ver.get('__version__', 'dev') |
| 8 | +except IOError: |
| 9 | + version = 'dev' |
7 | 10 |
|
8 | | -Features: |
9 | | -Linear input/output systems in state space and frequency domain |
10 | | -Block diagram algebra: serial, parallel and feedback interconnections |
11 | | -Time response: initial, step, impulse |
12 | | -Frequency response: Bode and Nyquist plots |
13 | | -Control analysis: stability, reachability, observability, stability margins |
14 | | -Control design: eigenvalue placement, linear quadratic regulator |
15 | | -Estimator design: linear quadratic estimator (Kalman filter) |
| 11 | +with open('README.rst') as fp: |
| 12 | + long_description = fp.read() |
16 | 13 |
|
17 | | -""" |
18 | | - |
19 | | -MAJOR = 0 |
20 | | -MINOR = 6 |
21 | | -MICRO = 5 |
22 | | -ISRELEASED = True |
23 | | -DISTNAME = 'control' |
24 | | -DESCRIPTION = 'Python control systems library' |
25 | | -LONG_DESCRIPTION = descr |
26 | | -AUTHOR = 'Richard Murray' |
27 | | -AUTHOR_EMAIL = 'murray@cds.caltech.edu' |
28 | | -MAINTAINER = AUTHOR |
29 | | -MAINTAINER_EMAIL = AUTHOR_EMAIL |
30 | | -URL = 'http://python-control.sourceforge.net' |
31 | | -LICENSE = 'BSD' |
32 | | -DOWNLOAD_URL = URL |
33 | | -PACKAGE_NAME = 'control' |
34 | | -EXTRA_INFO = dict( |
35 | | - install_requires=['numpy', 'scipy', 'matplotlib'], |
36 | | - tests_require=['scipy', 'matplotlib', 'nose'] |
37 | | -) |
38 | | - |
39 | | -VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO) |
40 | | - |
41 | | -import os |
42 | | -import sys |
43 | | -import subprocess |
44 | | - |
45 | | - |
46 | | -CLASSIFIERS = """\ |
| 14 | +CLASSIFIERS = """ |
47 | 15 | Development Status :: 3 - Alpha |
48 | 16 | Intended Audience :: Science/Research |
49 | 17 | Intended Audience :: Developers |
50 | 18 | License :: OSI Approved :: BSD License |
51 | | -Programming Language :: Python |
| 19 | +Programming Language :: Python :: 2 |
| 20 | +Programming Language :: Python :: 2.7 |
52 | 21 | Programming Language :: Python :: 3 |
| 22 | +Programming Language :: Python :: 3.3 |
| 23 | +Programming Language :: Python :: 3.4 |
53 | 24 | Topic :: Software Development |
54 | 25 | Topic :: Scientific/Engineering |
55 | 26 | Operating System :: Microsoft :: Windows |
|
58 | 29 | Operating System :: MacOS |
59 | 30 | """ |
60 | 31 |
|
61 | | - |
62 | | -# Return the git revision as a string |
63 | | -def git_version(): |
64 | | - def _minimal_ext_cmd(cmd): |
65 | | - # construct minimal environment |
66 | | - env = {} |
67 | | - for k in ['SYSTEMROOT', 'PATH']: |
68 | | - v = os.environ.get(k) |
69 | | - if v is not None: |
70 | | - env[k] = v |
71 | | - # LANGUAGE is used on win32 |
72 | | - env['LANGUAGE'] = 'C' |
73 | | - env['LANG'] = 'C' |
74 | | - env['LC_ALL'] = 'C' |
75 | | - out = subprocess.Popen( |
76 | | - cmd, |
77 | | - stdout=subprocess.PIPE, |
78 | | - env=env).communicate()[0] |
79 | | - return out |
80 | | - |
81 | | - try: |
82 | | - out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD']) |
83 | | - GIT_REVISION = out.strip().decode('ascii') |
84 | | - except OSError: |
85 | | - GIT_REVISION = "Unknown" |
86 | | - |
87 | | - return GIT_REVISION |
88 | | - |
89 | | - |
90 | | -def get_version_info(): |
91 | | - # Adding the git rev number needs to be done inside write_version_py(), |
92 | | - # otherwise the import of package.version messes up |
93 | | - # the build under Python 3. |
94 | | - FULLVERSION = VERSION |
95 | | - if os.path.exists('.git'): |
96 | | - GIT_REVISION = git_version() |
97 | | - elif os.path.exists('control/version.py'): |
98 | | - # must be a source distribution, use existing version file |
99 | | - try: |
100 | | - from control.version import git_revision as GIT_REVISION |
101 | | - except ImportError: |
102 | | - raise ImportError("Unable to import git_revision. Try removing " |
103 | | - "control/version.py and the build directory " |
104 | | - "before building.") |
105 | | - else: |
106 | | - GIT_REVISION = "Unknown" |
107 | | - |
108 | | - if not ISRELEASED: |
109 | | - FULLVERSION += '.dev-' + GIT_REVISION[:7] |
110 | | - |
111 | | - return FULLVERSION, GIT_REVISION |
112 | | - |
113 | | - |
114 | | -def write_version_py(filename='control/version.py'): |
115 | | - cnt = """ |
116 | | -# THIS FILE IS GENERATED FROM SETUP.PY |
117 | | -short_version = '%(version)s' |
118 | | -version = '%(version)s' |
119 | | -full_version = '%(full_version)s' |
120 | | -git_revision = '%(git_revision)s' |
121 | | -release = %(isrelease)s |
122 | | -
|
123 | | -if not release: |
124 | | - version = full_version |
125 | | -""" |
126 | | - FULLVERSION, GIT_REVISION = get_version_info() |
127 | | - |
128 | | - a = open(filename, 'w') |
129 | | - try: |
130 | | - a.write(cnt % {'version': VERSION, |
131 | | - 'full_version': FULLVERSION, |
132 | | - 'git_revision': GIT_REVISION, |
133 | | - 'isrelease': str(ISRELEASED)}) |
134 | | - finally: |
135 | | - a.close() |
136 | | - |
137 | | -def configuration(parent_package='',top_path=None): |
138 | | - from numpy.distutils.misc_util import Configuration |
139 | | - |
140 | | - config = Configuration(None, parent_package, top_path) |
141 | | - config.set_options(ignore_setup_xxx_py=True, |
142 | | - assume_default_configuration=True, |
143 | | - delegate_options_to_subpackages=True, |
144 | | - quiet=True) |
145 | | - |
146 | | - config.add_subpackage(PACKAGE_NAME) |
147 | | - |
148 | | - config.get_version(PACKAGE_NAME + '/version.py') # sets config.version |
149 | | - |
150 | | - return config |
151 | | - |
152 | | -def setup_package(): |
153 | | - src_path = os.path.dirname(os.path.abspath(sys.argv[0])) |
154 | | - old_path = os.getcwd() |
155 | | - os.chdir(src_path) |
156 | | - sys.path.insert(0, src_path) |
157 | | - |
158 | | - # Rewrite the version file everytime |
159 | | - write_version_py() |
160 | | - |
161 | | - metadata = dict( |
162 | | - name=DISTNAME, |
163 | | - author=AUTHOR, |
164 | | - author_email=AUTHOR_EMAIL, |
165 | | - maintainer=MAINTAINER, |
166 | | - maintainer_email=MAINTAINER_EMAIL, |
167 | | - description=DESCRIPTION, |
168 | | - license=LICENSE, |
169 | | - url=URL, |
170 | | - download_url=DOWNLOAD_URL, |
171 | | - long_description=LONG_DESCRIPTION, |
172 | | - classifiers=[_f for _f in CLASSIFIERS.split('\n') if _f], |
173 | | - platforms=["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"], |
174 | | - install_requires=['numpy', 'scipy'], |
175 | | - tests_require=['nose'], |
176 | | - test_suite='nose.collector', |
177 | | - packages=[PACKAGE_NAME], |
178 | | - ) |
179 | | - |
180 | | - # Run build |
181 | | - if len(sys.argv) >= 2 and ('--help' in sys.argv[1:] or |
182 | | - sys.argv[1] in ('--help-commands', 'egg_info', '--version', |
183 | | - 'clean', 'test')): |
184 | | - # Use setuptools for these commands (they don't work well or at all |
185 | | - # with distutils). For normal builds use distutils. |
186 | | - try: |
187 | | - from setuptools import setup |
188 | | - except ImportError: |
189 | | - from distutils.core import setup |
190 | | - |
191 | | - FULLVERSION, GIT_REVISION = get_version_info() |
192 | | - metadata['version'] = FULLVERSION |
193 | | - else: |
194 | | - if len(sys.argv) >= 2 and sys.argv[1] == 'bdist_wheel': |
195 | | - # bdist_wheel needs setuptools |
196 | | - import setuptools |
197 | | - from numpy.distutils.core import setup |
198 | | - cwd = os.path.abspath(os.path.dirname(__file__)) |
199 | | - metadata['configuration'] = configuration |
200 | | - |
201 | | - try: |
202 | | - setup(**metadata) |
203 | | - finally: |
204 | | - del sys.path[0] |
205 | | - os.chdir(old_path) |
206 | | - return |
207 | | - |
208 | | -if __name__ == '__main__': |
209 | | - setup_package() |
| 32 | +setup( |
| 33 | + name='control', |
| 34 | + version=version, |
| 35 | + author='Richard Murray', |
| 36 | + author_email='murray@cds.caltech.edu', |
| 37 | + url='http://python-control.sourceforge.net', |
| 38 | + description='Python control systems library', |
| 39 | + long_description=long_description, |
| 40 | + packages=find_packages(), |
| 41 | + classifiers=[f for f in CLASSIFIERS.split('\n') if f], |
| 42 | + install_requires=['numpy', |
| 43 | + 'scipy', |
| 44 | + 'matplotlib'], |
| 45 | + tests_require=['scipy', |
| 46 | + 'matplotlib', |
| 47 | + 'nose'], |
| 48 | + test_suite = 'nose.collector', |
| 49 | +) |
0 commit comments