annotate python/install.py @ 694:ebca6d85213a

File "/usr/lib/python3/dist-packages/IPython/config/__init__.py", line 16, in <module> from .application import * File "/usr/lib/python3/dist-packages/IPython/config/application.py", line 31, in <module> from IPython.config.configurable import SingletonConfigurable File "/usr/lib/python3/dist-packages/IPython/config/configurable.py", line 33, in <module> from IPython.utils.text import indent, wrap_paragraphs File "/usr/lib/python3/dist-packages/IPython/utils/text.py", line 28, in <module> from IPython.external.path import path File "/usr/lib/python3/dist-packages/IPython/external/path/__init__.py", line 2, in <module> from path import * File "/home/jhammel/python/path.py", line 25 print root(path) ^
author Jeff Hammel <k0scist@gmail.com>
date Wed, 09 Jul 2014 16:26:49 -0700
parents e4746a046446
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
123
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 def install_hg(sources):
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2 """
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 - sources : dict of hg sources to install: {'package': 'http://hg...'}
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4 """
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5 try:
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6 from subprocess import check_call as call
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7 except:
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 from subprocess import call
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10 # see if you can find site-packages
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11 import site
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12 site_dir = os.path.abspath(os.path.dirname(site.__file__))
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13 site_packages = os.path.join(site_dir, 'site-packages')
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
14 if not (os.path.exists(site_packages) and os.path.isdir(site_packages)):
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
15 raise IOError("Cannot find site-packages directory")
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
16
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
17 # figure out what you need to install
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
18 missing = set()
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
19 for source in sources:
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
20 try:
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
21 __import__(source)
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
22 except ImportError:
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
23 missing.add(source)
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
24
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
25 # install it
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
26 for source in missing:
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
27 call(['hg', 'clone', sources[source],
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
28 os.path.join(site_packages, source)])
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
29
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
30 ### install unpackaged dependencies
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
31 if set(['install', 'develop']).intersection(sys.argv[1:]):
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
32 try:
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
33 install_hg(source)
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
34 except:
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
35 print 'Please make sure the source is installed:'
e4746a046446 adding install script for inclusion in setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
36 print source