10000 Merge pull request #52 from cwrowley/conda-build · rubencabrera/python-control@15fd5c1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 15fd5c1

Browse files
committed
Merge pull request python-control#52 from cwrowley/conda-build
Add conda build recipe and improve version numbering
2 parents 9671fe3 + 5ff196c commit 15fd5c1

File tree

9 files changed

+235
-295
lines changed

9 files changed

+235
-295
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ build/
33
dist/
44
.ropeproject/
55
MANIFEST
6-
control/version.py
6+
control/_version.py
7+
__conda_*.txt
8+
record.txt
79
build.log
810
*.egg-info/
911
.coverage

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ python:
88
before_install:
99
- export DISPLAY=:99.0
1010
- sh -e /etc/init.d/xvfb start
11-
- sudo apt-get update --fix-missing -qq
12-
- sudo apt-get install gfortran liblapack-dev
1311
# use miniconda to install numpy/scipy, to avoid lengthy build from source
1412
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
1513
wget http://repo.continuum.io/miniconda/Miniconda-3.4.2-Linux-x86_64.sh -O miniconda.sh;
@@ -21,13 +19,16 @@ before_install:
2119
- hash -r
2220
- conda config --set always_yes yes --set changeps1 no
2321
- conda update -q conda
22+
- conda install --yes python=$TRAVIS_PYTHON_VERSION conda-build pip coverage
23+
- conda config --add channels http://conda.binstar.org/cwrowley
2424
- conda info -a
2525

2626
# Install packages
2727
install:
28-
- conda install --yes python=$TRAVIS_PYTHON_VERSION coverage nose numpy scipy matplotlib pip
28+
- conda build conda-recipe
29+
- conda install control --use-local
30+
- conda install slycot
2931
- pip install coveralls
30-
- pip install slycot
3132

3233
# command to run tests
3334
script:

README.rst

Lines changed: 71 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,96 @@
1-
Python Control System Library
2-
=============================
3-
41
.. image:: https://travis-ci.org/python-control/python-control.svg?branch=master
5-
:target: https://travis-ci.org/python-control/python-control
2+
:target: https://travis-ci.org/python-control/python-control
63
.. image:: https://coveralls.io/repos/python-control/python-control/badge.png
7-
:target: https://coveralls.io/r/python-control/python-control
4+
:target: https://coveralls.io/r/python-control/python-control
5+
6+
Python Control Systems Library
7+
==============================
8+
9+
The Python Control Systems Library is a Python module that implements basic
10+
operations for analysis and design of feedback control systems.
11+
12+
Features
13+
--------
14+
15+
- Linear input/output systems in state-space and frequency domain
16+
- Block diagram algebra: serial, parallel, and feedback interconnections
17+
- Time response: initial, step, impulse
18+
- Frequency response: Bode and Nyquist plots
19+
- Control analysis: stability, reachability, observability, stability margins
20+
- Control design: eigenvalue placement, linear quadratic regulator
21+
- Estimator design: linear quadratic estimator (Kalman filter)
22+
23+
24+
Links
25+
=====
26+
27+
- Project home page: http://python-control.sourceforge.net
28+
- Source code repository: https://github.com/python-control/python-control
29+
- Documentation: http://python-control.readthedocs.org/
30+
- Issue tracker: https://github.com/python-control/python-control/issues
31+
- Mailing list: http://sourceforge.net/p/python-control/mailman/
32+
33+
34+
Dependencies
35+
============
836

9-
RMM, 23 May 09
37+
The package requires numpy, scipy, and matplotlib. In addition, some routines
38+
use a module called slycot, that is a Python wrapper around some FORTRAN
39+
routines. Many parts of python-control will work without slycot, but some
40+
functionality is limited or absent, and installation of slycot is recommended
41+
(see below). Note that in order to install slycot, you will need a FORTRAN
42+
compiler on your machine. The Slycot wrapper can be found at:
1043

11-
This directory contains the source code for the Python Control Systems
12-
Library (python-control). This package provides a library of standard
13-
control system algorithms in the python programming environment.
44+
https://github.com/jgoppert/Slycot
1445

1546
Installation
16-
------------
47+
============
48+
49+
The package may be installed using pip or distutils.
50+
51+
Pip
52+
---
53+
54+
To install using pip::
1755

18-
Using pip
19-
~~~~~~~~~~~
56+
pip install slycot # optional
57+
pip install control
2058

21-
Pip is a python packaging system. It can be installed on debian based
22-
linux distros with the command::
59+
Distutils
60+
---------
2361

24-
sudo apt-get install pip
62+
To install in your home directory, use::
2563

26-
Pip can then be used to install python-control::
64+
python setup.py install --user
2765

28-
sudo pip install control
66+
To install for all users (on Linux or Mac OS)::
2967

68+
python setup.py build
69+
sudo python setup.py install
3070

31-
From Source
32-
~~~~~~~~~~~
3371

34-
Standard python package installation::
72+
Development
73+
===========
3574

36-
python setup.py install
75+
Code
76+
----
3777

38-
To see if things are working, you can run the script
39-
examples/secord-matlab.py (using ipython -pylab). It should generate a step
40-
response, Bode plot and Nyquist plot for a simple second order linear
41-
system.
78+
You can check out the latest version of the source code with the command::
79+
80+
git clone https://github.com/python-control/python-control.git
4281

4382
Testing
4483
-------
4584

46-
You can also run a set of unit tests to make sure that everything is working
85+
You can run a set of unit tests to make sure that everything is working
4786
correctly. After installation, run::
4887

49-
python runtests.py
50-
51-
Slycot
52-
------
53-
54-
Routines from the Slycot wrapper are used for providing the
55-
functionality of several routines for state-space, transfer functions
56-
and robust control. Many parts of python-control will still work
57-
without slycot, but some functionality is limited or absent, and
58-
installation of Slycot is definitely recommended. The Slycot wrapper
59-
can be found at:
88+
python setup.py test
6089

61-
https://github.com/jgoppert/Slycot
90+
Contributing
91+
------------
6292

63-
and can be installed with::
93+
Your contributions are welcome! Simply fork the GitHub repository and send a
94+
`pull request`_.
6495

65-
sudo pip install slycot
96+
.. _pull request: https://github.com/python-control/python-control/pulls

conda-recipe/bld.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cd %RECIPE_DIR%\..
2+
%PYTHON% make_version.py
3+
%PYTHON% setup.py install --single-version-externally-managed --record=record.txt

conda-recipe/meta.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package:
2+
name: control
3+
4+
build:
5+
script:
6+
- cd $RECIPE_DIR/..
7+
- $PYTHON make_version.py
8+
- $PYTHON setup.py install --single-version-externally-managed --record=record.txt
9+
10+
requirements:
11+
build:
12+
- python
13+
- nose
14+
15+
run:
16+
- python
17+
- numpy
18+
- scipy
19+
- matplotlib
20+
21+
test:
22+
imports:
23+
- control
24+
25+
about:
26+
home: http://python-control.sourceforge.net
27+
license: BSD License
28+
summary: 'Python control systems library'
29+
30+
# See
31+
# http://docs.continuum.io/conda/build.html for
32+
# more information about meta.yaml

control/__init__.py

Lines changed: 47 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -56,65 +56,56 @@
5656
lqe linear quadratic estimator
5757
"""
5858

59-
try:
60-
__CONTROL_SETUP__
61-
except NameError:
62-
__CONTROL_SETUP__ = False
63-
64-
if __CONTROL_SETUP__:
65-
import sys as _sys
66-
_sys.stderr.write('Running from control source directory.\n')
67-
del _sys
68-
else:
59+
# Import functions from within the control system library
60+
# Should probably only import the exact functions we use...
61+
from .bdalg import series, parallel, negate, feedback
62+
from .delay import pade
63+
from .dtime import sample_system
64+
from .freqplot import bode_plot, nyquist_plot, gangof4_plot
65+
from .freqplot import bode, nyquist, gangof4
66+
from .lti import issiso, timebase, timebaseEqual, isdtime, isctime
67+
from .margins import stability_margins, phase_crossover_frequencies
68+
from .mateqn import lyap, dlyap, care, dare
69+
from .modelsimp import hsvd, modred, balred, era, markov
70+
from .nichols import nichols_plot, nichols
71+
from .phaseplot import phase_plot, box_grid
72+
from .rlocus import root_locus
73+
from .statefbk import place, lqr, ctrb, obsv, gram, acker
74+
from .statesp import StateSpace
75+
from .timeresp import forced_response, initial_response, step_response, \
76+
impulse_response
77+
from .xferfcn import TransferFunction
78+
from .ctrlutil import unwrap, issys
79+
from .frdata import FRD
80+
from .canonical import canonical_form, reachable_form
6981

70-
# Import functions from within the control system library
71-
# Should probably only import the exact functions we use...
72-
from .bdalg import series, parallel, negate, feedback
73-
from .delay import pade
74-
from .dtime import sample_system
75-
from .freqplot import bode_plot, nyquist_plot, gangof4_plot
76-
from .freqplot import bode, nyquist, gangof4
77-
from .lti import issiso, timebase, timebaseEqual, isdtime, isctime
78-
from .margins import stability_margins, phase_crossover_frequencies
79-
from .mateqn import lyap, dlyap, care, dare
80-
from .modelsimp import hsvd, modred, balred, era, markov
81-
from .nichols import nichols_plot, nichols
82-
from .phaseplot import phase_plot, box_grid
83-
from .rlocus import root_locus
84-
from .statefbk import place, lqr, ctrb, obsv, gram, acker
85-
from .statesp import StateSpace
86-
from .timeresp import forced_response, initial_response, step_response, \
87-
impulse_response
88-
from .xferfcn import TransferFunction
89-
from .ctrlutil import unwrap, issys
90-
from .frdata import FRD
91-
from .canonical import canonical_form, reachable_form
82+
# Exceptions
83+
from .exception import *
9284

93-
# Exceptions
94-
from .exception import *
95-
96-
# Version information
97-
from control.version import full_version as __version__
98-
from control.version import git_revision as __git_revision__
85+
# Version information
86+
try:
87+
from ._version import __version__, __commit__
88+
except ImportError:
89+
__version__ = "dev"
9990

100-
# Import some of the more common (and benign) MATLAB shortcuts
101-
# By default, don't import conflicting commands here
102-
#! TODO (RMM, 4 Nov 2012): remove MATLAB dependencies from __init__.py
103-
#!
104-
#! Eventually, all functionality should be in modules *other* than matlab.
105-
#! This will allow inclusion of the matlab module to set up a different set
106-
#! of defaults from the main package. At that point, the matlab module will
107-
#! allow provide compatibility with MATLAB but no package functionality.
108-
#!
109-
from .matlab import ss, tf, ss2tf, tf2ss, drss
110-
from .matlab import pole, zero, evalfr, freqresp, dcgain
111-
from .matlab import nichols, rlocus, margin
112-
# bode and nyquist come directly from freqplot.py
113-
from .matlab import step, impulse, initial, lsim
114-
from .matlab import ssdata, tfdata
91+
# Import some of the more common (and benign) MATLAB shortcuts
92+
# By default, don't import conflicting commands here
93+
#! TODO (RMM, 4 Nov 2012): remove MATLAB dependencies from __init__.py
94+
#!
95+
#! Eventually, all functionality should be in modules *other* than matlab.
96+
#! This will allow inclusion of the matlab module to set up a different set
97+
#! of defaults from the main package. At that point, the matlab module will
98+
#! allow provide compatibility with MATLAB but no package functionality.
99+
#!
100+
from .matlab import ss, tf, ss2tf, tf2ss, drss
101+
from .matlab import pole, zero, evalfr, freqresp, dcgain
102+
from .matlab import nichols, rlocus, margin
103+
# bode and nyquist come directly from freqplot.py
104+
from .matlab import step, impulse, initial, lsim
105+
from .matlab import ssdata, tfdata
115106

116107
# The following is to use Numpy's testing framework
117108
# Tests go under directory tests/, benchmarks under directory benchmarks/
118-
from numpy.testing import Tester
119-
test = Tester().test
120-
bench = Tester().bench
109+
from numpy.testing import Tester
110+
test = Tester().test
111+
bench = Tester().bench

control/tests/freqresp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
systf = tf(sys)
4141
tfMIMO = tf(sysMIMO)
4242

43-
print systf.pole()
43+
print(systf.pole())
4444
#print tfMIMO.pole() # - should throw not implemented exception
4545
#print tfMIMO.zero() # - should throw not implemented exception
4646

make_version.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
from subprocess import check_output
2+
import os
3+
4+
def main():
5+
cmd = 'git describe --always --long'
6+
output = check_output(cmd.split()).decode('utf-8').strip().split('-')
7+
if len(output) == 3:
8+
version, build, commit = output
9+
else:
10+
raise Exception("Could not git describe, (got %s)" % output)
11+
12+
print("Version: %s" % version)
13+
print("Build: %s" % build)
14+
print("Commit: %s\n" % commit)
15+
16+
filename = "control/_version.py"
17+
print("Writing %s" % filename)
18+
with open(filename, 'w') as fd:
19+
if build == '0':
20+
fd.write('__version__ = "%s"\n' % (version))
21+
else:
22+
fd.write('__version__ = "%s.post%s"\n' % (version, build))
23+
fd.write('__commit__ = "%s"\n' % (commit))
24+
25+
# Write files for conda version number
26+
SRC_DIR = os.environ.get('SRC_DIR', '.')
27+
conda_version_path = os.path.join(SRC_DIR, '__conda_version__.txt')
28+
print("Writing %s" % conda_version_path)
29+
with open(conda_version_path, 'w') as conda_version:
30+
conda_version.write(version)
31+
32+
conda_buildnum_path = os.path.join(SRC_DIR, '__conda_buildnum__.txt')
33+
print("Writing %s" % conda_buildnum_path)
34+
35+
with open(conda_buildnum_path, 'w') as conda_buildnum:
36+
conda_buildnum.write(build)
37+
38+
39+
if __name__ == '__main__':
40+
main()

0 commit comments

Comments
 (0)
0