Skip to content

Commit

Permalink
dependency updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bbengfort committed Mar 11, 2016
1 parent 3467699 commit 69fe3c6
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 43 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ docs/_build/
# PyBuilder
target/

fixtures
fixtures/*
!fixtures/*.tgz
!fixtures/*.zip
venv
conf/tribe.yaml
.ipynb_checkpoints
25 changes: 3 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,30 +65,11 @@ To work with this code, you'll need to do a few things to set up your environmen

Note, this may take a little while, but if you already have `matplotlib` and `pygraphviz` installed already, you should have little trouble.

5. Add the `tribe` module to the Python path for easy import
5. Test everything is working:

There are a variety of ways to accomplish this, you could set the `$PYTHONPATH` environment variable, you could edit the `scripts/tribe-admin.py` file to modify the `sys.path` at runtime; choose your favorite approach. Mine is to use `.pth` files as below:
$ python tribe-admin.py --help

First, find out the location of your Python cite packages with the following command:

$ python -c 'from distutils.sysconfig import get_python_lib; print get_python_lib();'

This is such a useful command, that I have it aliased in my .profile. Once you know this directory, create a .pth file with the current working directory in it as follows:

$ echo $(pwd) > tribe.pth
$ mv tribe.pth /path/to/site/packages/

Then simply move the .pth file to the location that was specified in the first command. Open up a new terminal window, and cd into your home directory. Open up a python iterpreter and type in `import tribe` - this should work with no errors.

5. (Optional) Add a symlink to the `scripts/tribe-admin.py` script to your `$PATH`.

The simplest way to deal with this is to create a directory, `$HOME/bin` then add that directory to your `$PATH` using your bash profile. Of course, there are a variety of ways to do this as well, you could add the `scripts` directory to your `$PATH`, symlink that directory to `/usr/local/bin` or a similar place on Windows. Whatever you're most comfortable with is fine.

6. Test everything is working:

$ scripts/tribe-admin.py --help

You should see a help screen printed out (if you have import errors, see step 5, if you have a non executable error, make sure that you chmod tribe-admin.py to be executable).
You should see a help screen printed out.


<!-- References -->
Expand Down
53 changes: 37 additions & 16 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
PyYAML==3.11
confire==0.2.0
coverage==3.7.1
decorator==3.4.0
matplotlib==1.4.2
mock==1.0.1
networkx==1.9.1
nose==1.3.4
numpy==1.9.1
pygraphviz==1.2
pyparsing==2.0.3
python-dateutil==2.2
## Graphs and Network Analysis
networkx==1.11
python-louvain==0.3
pytz==2014.9
six==1.8.0
unicodecsv==0.9.4
wsgiref==0.1.2

## Visualization
matplotlib==1.5.1
#pygraphviz==1.3.1

## Utilities
confire==0.2.0
python-dateutil==2.5.0
unicodecsv==0.14.1

## Other Dependencies
# networkX Dependencies
decorator==4.0.9
# confire Dependencies
PyYAML==3.11
six==1.10.0
# matplotlib Dependencies
numpy==1.10.4
pytz==2015.7
cycler==0.10.0
pyparsing==2.1.0

## Testing (uncomment for development)
#nose==1.3.7
#mock==1.3.0
#coverage==4.0.3
#funcsigs==0.4
#pbr==1.8.1

## Packaging Requirements
#Python==2.7.10
#pip==8.1.0
#wheel==0.29.0
#setuptools==20.2.2
#wsgiref==0.1.2
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Copyright (C) 2016 District Data Labs
# For license information, see LICENSE.txt and NOTICE.md
#
# ID: setup.py [] benjamin@bengfort.com $
# ID: setup.py [0d8dccc] benjamin@bengfort.com $

"""
Setup script for installing tribe.
Expand Down
2 changes: 1 addition & 1 deletion tribe/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def plot(self, *args, **kwargs):

try:
import pylab
except ImportError:
except (ImportError, RuntimeError):
raise ValueError("The plot function requires matplotlib.")

if len(args) == 0:
Expand Down
2 changes: 1 addition & 1 deletion tribe/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Copyright (C) 2016 District Data Labs
# For license information, see LICENSE.txt
#
# ID: version.py [] benjamin@bengfort.com $
# ID: version.py [3467699] benjamin@bengfort.com $

"""
Stores version information such that it can be read by setuptools.
Expand Down
24 changes: 23 additions & 1 deletion tribe/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,31 @@

import math
import networkx as nx
import matplotlib.pyplot as plt
from operator import itemgetter
from functools import wraps

try:
import matplotlib.pyplot as plt
except (ImportError, RuntimeError):
import warnings
plt = None

def configure(func):
"""
Configures visualization environment.
"""
@wraps(func)
def wrapper(*args, **kwargs):
if plt is None:
warnings.warn("matplotlib is not installed or you are using a virtualenv!")
return None
return func(*args, **kwargs)

return wrapper

@configure
def show_simple_network(nodes=12, prob=0.2, hot=False):

G = nx.erdos_renyi_graph(nodes, prob)
pos = nx.spring_layout(G)
nx.draw_networkx_nodes(G, pos, node_color='#0080C9', node_size=500, linewidths=1.0)
Expand All @@ -37,6 +58,7 @@ def show_simple_network(nodes=12, prob=0.2, hot=False):

return G

@configure
def draw_social_network(G, path="graph.png", **kwargs):

# A = nx.to_agraph(G)
Expand Down

0 comments on commit 69fe3c6

Please sign in to comment.