Show More
@@ -1,107 +1,110 b'' | |||
|
1 | 1 | # Makefile for Sphinx documentation |
|
2 | 2 | # |
|
3 | 3 | |
|
4 | 4 | # You can set these variables from the command line. |
|
5 | 5 | SPHINXOPTS = |
|
6 | 6 | SPHINXBUILD = sphinx-build |
|
7 | 7 | PAPER = |
|
8 | 8 | SRCDIR = source |
|
9 | 9 | |
|
10 | 10 | # Internal variables. |
|
11 | 11 | PAPEROPT_a4 = -D latex_paper_size=a4 |
|
12 | 12 | PAPEROPT_letter = -D latex_paper_size=letter |
|
13 | 13 | ALLSPHINXOPTS = -d build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(SRCDIR) |
|
14 | 14 | |
|
15 | 15 | .PHONY: help clean html web pickle htmlhelp latex changes linkcheck api |
|
16 | 16 | |
|
17 | 17 | default: html |
|
18 | 18 | |
|
19 | 19 | help: |
|
20 | 20 | @echo "Please use \`make <target>' where <target> is one of" |
|
21 | 21 | @echo " html to make standalone HTML files" |
|
22 | 22 | @echo " pickle to make pickle files (usable by e.g. sphinx-web)" |
|
23 | 23 | @echo " htmlhelp to make HTML files and a HTML help project" |
|
24 | 24 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" |
|
25 | 25 | @echo " changes to make an overview over all changed/added/deprecated items" |
|
26 | 26 | @echo " linkcheck to check all external links for integrity" |
|
27 | 27 | @echo |
|
28 | 28 | @echo "Compound utility targets:" |
|
29 | 29 | @echo "pdf latex and then runs the PDF generation" |
|
30 | 30 | @echo "all html and pdf" |
|
31 | 31 | @echo "dist all, and then puts the results in dist/" |
|
32 | 32 | @echo "gitwash-update update git workflow from source repo" |
|
33 | 33 | |
|
34 | 34 | clean: |
|
35 | 35 | -rm -rf build/* dist/* $(SRCDIR)/api/generated |
|
36 | 36 | |
|
37 | 37 | pdf: latex |
|
38 | 38 | cd build/latex && make all-pdf |
|
39 | 39 | |
|
40 | 40 | all: html pdf |
|
41 | 41 | |
|
42 | dist: all | |
|
43 | mkdir -p dist | |
|
44 | rm -rf dist/* | |
|
45 | ln build/latex/ipython.pdf dist/ | |
|
46 | cp -al build/html dist/ | |
|
47 | @echo "Build finished. Final docs are in dist/" | |
|
42 | # For final distribution, only build HTML (our pdf is now so large as to be | |
|
43 | # unusable, takes forever to build and just bloats the downloads). We leave | |
|
44 | # them hardlinked at the top-level so users find them easily, though the | |
|
45 | # original build/html dir is left in-place (useful to reload builds while | |
|
46 | # testing). | |
|
47 | dist: html | |
|
48 | rm -rf html | |
|
49 | cp -al build/html . | |
|
50 | @echo "Build finished. Final docs are in html/" | |
|
48 | 51 | |
|
49 | 52 | html: api |
|
50 | 53 | mkdir -p build/html build/doctrees |
|
51 | 54 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html |
|
52 | 55 | @echo |
|
53 | 56 | @echo "Build finished. The HTML pages are in build/html." |
|
54 | 57 | |
|
55 | 58 | api: source/api/generated/gen.txt |
|
56 | 59 | |
|
57 | 60 | source/api/generated/gen.txt: |
|
58 | 61 | python autogen_api.py |
|
59 | 62 | @echo "Build API docs finished." |
|
60 | 63 | |
|
61 | 64 | pickle: |
|
62 | 65 | mkdir -p build/pickle build/doctrees |
|
63 | 66 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle |
|
64 | 67 | @echo |
|
65 | 68 | @echo "Build finished; now you can process the pickle files or run" |
|
66 | 69 | @echo " sphinx-web build/pickle" |
|
67 | 70 | @echo "to start the sphinx-web server." |
|
68 | 71 | |
|
69 | 72 | web: pickle |
|
70 | 73 | |
|
71 | 74 | htmlhelp: |
|
72 | 75 | mkdir -p build/htmlhelp build/doctrees |
|
73 | 76 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp |
|
74 | 77 | @echo |
|
75 | 78 | @echo "Build finished; now you can run HTML Help Workshop with the" \ |
|
76 | 79 | ".hhp project file in build/htmlhelp." |
|
77 | 80 | |
|
78 | 81 | latex: api |
|
79 | 82 | mkdir -p build/latex build/doctrees |
|
80 | 83 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex |
|
81 | 84 | @echo |
|
82 | 85 | @echo "Build finished; the LaTeX files are in build/latex." |
|
83 | 86 | @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ |
|
84 | 87 | "run these through (pdf)latex." |
|
85 | 88 | |
|
86 | 89 | changes: |
|
87 | 90 | mkdir -p build/changes build/doctrees |
|
88 | 91 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes |
|
89 | 92 | @echo |
|
90 | 93 | @echo "The overview file is in build/changes." |
|
91 | 94 | |
|
92 | 95 | linkcheck: |
|
93 | 96 | mkdir -p build/linkcheck build/doctrees |
|
94 | 97 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck |
|
95 | 98 | @echo |
|
96 | 99 | @echo "Link check complete; look for any errors in the above output " \ |
|
97 | 100 | "or in build/linkcheck/output.txt." |
|
98 | 101 | |
|
99 | 102 | gitwash-update: |
|
100 | 103 | python ../tools/gitwash_dumper.py source/development ipython |
|
101 | 104 | cd source/development/gitwash && rename 's/.rst/.txt/' *.rst |
|
102 | 105 | |
|
103 | 106 | nightly: dist |
|
104 | 107 | rsync -avH --delete dist/ ipython:www/doc/nightly |
|
105 | 108 | |
|
106 | 109 | gh-pages: html pdf |
|
107 | 110 | python gh-pages.py |
@@ -1,134 +1,133 b'' | |||
|
1 | 1 | #!python |
|
2 | 2 | """Windows-specific part of the installation""" |
|
3 | 3 | |
|
4 | 4 | import os, sys, shutil |
|
5 | 5 | pjoin = os.path.join |
|
6 | 6 | |
|
7 | 7 | # import setuptools if we can |
|
8 | 8 | try: |
|
9 | 9 | import setuptools |
|
10 | 10 | except ImportError: |
|
11 | 11 | pass |
|
12 | 12 | |
|
13 | ||
|
13 | 14 | def mkshortcut(target,description,link_file,*args,**kw): |
|
14 | 15 | """make a shortcut if it doesn't exist, and register its creation""" |
|
15 | 16 | |
|
16 | 17 | create_shortcut(target, description, link_file,*args,**kw) |
|
17 | 18 | file_created(link_file) |
|
18 | 19 | |
|
20 | ||
|
19 | 21 | def install(): |
|
20 | 22 | """Routine to be run by the win32 installer with the -install switch.""" |
|
21 | 23 | |
|
22 | 24 | from IPython.core.release import version |
|
23 | 25 | |
|
24 | 26 | # Get some system constants |
|
25 | 27 | prefix = sys.prefix |
|
26 | 28 | python = pjoin(prefix, 'python.exe') |
|
27 | 29 | pythonw = pjoin(prefix, 'pythonw.exe') |
|
28 | 30 | have_setuptools = 'setuptools' in sys.modules |
|
29 | 31 | |
|
30 | 32 | if not have_setuptools: |
|
31 | 33 | # This currently doesn't work without setuptools, |
|
32 | 34 | # so don't bother making broken links |
|
33 | 35 | return |
|
34 | 36 | |
|
35 | 37 | # Lookup path to common startmenu ... |
|
36 | 38 | ip_start_menu = pjoin(get_special_folder_path('CSIDL_COMMON_PROGRAMS'), |
|
37 | 39 | 'IPython (Py%i.%i %i bit)' % (sys.version_info[0], |
|
38 | 40 | sys.version_info[1], |
|
39 | 41 | 8*tuple.__itemsize__)) |
|
40 | 42 | # Create IPython entry ... |
|
41 | 43 | if not os.path.isdir(ip_start_menu): |
|
42 | 44 | os.mkdir(ip_start_menu) |
|
43 | 45 | directory_created(ip_start_menu) |
|
44 | 46 | |
|
45 | 47 | # Create .py and .bat files to make things available from |
|
46 | 48 | # the Windows command line. Thanks to the Twisted project |
|
47 | 49 | # for this logic! |
|
48 | 50 | programs = [ |
|
49 | 51 | 'ipython', |
|
50 | 52 | 'iptest', |
|
51 | 53 | 'ipcontroller', |
|
52 | 54 | 'ipengine', |
|
53 | 55 | 'ipcluster', |
|
54 | 56 | 'irunner' |
|
55 | 57 | ] |
|
56 | 58 | scripts = pjoin(prefix,'scripts') |
|
57 | 59 | if not have_setuptools: |
|
58 | 60 | # only create .bat files if we don't have setuptools |
|
59 | 61 | for program in programs: |
|
60 | 62 | raw = pjoin(scripts, program) |
|
61 | 63 | bat = raw + '.bat' |
|
62 | 64 | py = raw + '.py' |
|
63 | 65 | # Create .py versions of the scripts |
|
64 | 66 | shutil.copy(raw, py) |
|
65 | 67 | # Create .bat files for each of the scripts |
|
66 | 68 | bat_file = file(bat,'w') |
|
67 | 69 | bat_file.write("@%s %s %%*" % (python, py)) |
|
68 | 70 | bat_file.close() |
|
69 | 71 | |
|
70 | 72 | # Now move onto setting the Start Menu up |
|
71 | 73 | ipybase = pjoin(scripts, 'ipython') |
|
72 | 74 | if have_setuptools: |
|
73 | 75 | # let setuptools take care of the scripts: |
|
74 | 76 | ipybase = ipybase + '-script.py' |
|
75 | 77 | workdir = "%HOMEDRIVE%%HOMEPATH%" |
|
76 | 78 | |
|
77 | 79 | link = pjoin(ip_start_menu, 'IPython.lnk') |
|
78 | 80 | cmd = '"%s"' % ipybase |
|
79 | 81 | mkshortcut(python, 'IPython', link, cmd, workdir) |
|
80 | 82 | |
|
81 | 83 | # Disable pysh Start item until the profile restores functionality |
|
82 | 84 | # Most of this code is in IPython/deathrow, and needs to be updated |
|
83 | 85 | # to 0.11 APIs |
|
84 | 86 | |
|
85 | 87 | # link = pjoin(ip_start_menu, 'pysh.lnk') |
|
86 | 88 | # cmd = '"%s" profile=pysh --init' % ipybase |
|
87 | 89 | # mkshortcut(python, 'IPython (command prompt mode)', link, cmd, workdir) |
|
88 | 90 | |
|
89 | 91 | link = pjoin(ip_start_menu, 'pylab.lnk') |
|
90 | 92 | cmd = '"%s" profile=pylab --init' % ipybase |
|
91 | 93 | mkshortcut(python, 'IPython (pylab profile)', link, cmd, workdir) |
|
92 | 94 | |
|
93 | 95 | link = pjoin(ip_start_menu, 'ipcontroller.lnk') |
|
94 | 96 | cmdbase = pjoin(scripts, 'ipcontroller') |
|
95 | 97 | if have_setuptools: |
|
96 | 98 | cmdbase += '-script.py' |
|
97 | 99 | cmd = '"%s"' % cmdbase |
|
98 | 100 | mkshortcut(python, 'IPython controller', link, cmd, workdir) |
|
99 | 101 | |
|
100 | 102 | link = pjoin(ip_start_menu, 'ipengine.lnk') |
|
101 | 103 | cmdbase = pjoin(scripts, 'ipengine') |
|
102 | 104 | if have_setuptools: |
|
103 | 105 | cmdbase += '-script.py' |
|
104 | 106 | cmd = '"%s"' % cmdbase |
|
105 | 107 | mkshortcut(python, 'IPython engine', link, cmd, workdir) |
|
106 | 108 | |
|
107 | 109 | link = pjoin(ip_start_menu, 'ipythonqt.lnk') |
|
108 | 110 | cmdbase = pjoin(scripts, 'ipython-qtconsole') |
|
109 | 111 | if have_setuptools: |
|
110 | 112 | cmdbase += '-script.pyw' |
|
111 | 113 | cmd = '"%s"' % cmdbase |
|
112 | 114 | mkshortcut(pythonw, 'IPython Qt Console', link, cmd, workdir) |
|
113 | 115 | # Create documentation shortcuts ... |
|
114 |
t = prefix + r'\share\doc\ipython\manual\i |
|
|
115 | f = ip_start_menu + r'\Manual in PDF.lnk' | |
|
116 | mkshortcut(t,r'IPython Manual - PDF-Format',f) | |
|
117 | ||
|
118 | t = prefix + r'\share\doc\ipython\manual\html\index.html' | |
|
116 | t = prefix + r'\share\doc\ipython\manual\index.html' | |
|
119 | 117 | f = ip_start_menu + r'\Manual in HTML.lnk' |
|
120 | 118 | mkshortcut(t,'IPython Manual - HTML-Format',f) |
|
121 | 119 | |
|
122 | 120 | |
|
123 | 121 | def remove(): |
|
124 | 122 | """Routine to be run by the win32 installer with the -remove switch.""" |
|
125 | 123 | pass |
|
126 | 124 | |
|
125 | ||
|
127 | 126 | # main() |
|
128 | 127 | if len(sys.argv) > 1: |
|
129 | 128 | if sys.argv[1] == '-install': |
|
130 | 129 | install() |
|
131 | 130 | elif sys.argv[1] == '-remove': |
|
132 | 131 | remove() |
|
133 | 132 | else: |
|
134 | 133 | print "Script was called with option %s" % sys.argv[1] |
@@ -1,268 +1,269 b'' | |||
|
1 | 1 | #!/usr/bin/env python |
|
2 | 2 | # -*- coding: utf-8 -*- |
|
3 | 3 | """Setup script for IPython. |
|
4 | 4 | |
|
5 | 5 | Under Posix environments it works like a typical setup.py script. |
|
6 | 6 | Under Windows, the command sdist is not supported, since IPython |
|
7 | 7 | requires utilities which are not available under Windows.""" |
|
8 | 8 | |
|
9 | 9 | #----------------------------------------------------------------------------- |
|
10 | 10 | # Copyright (c) 2008-2011, IPython Development Team. |
|
11 | 11 | # Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu> |
|
12 | 12 | # Copyright (c) 2001, Janko Hauser <jhauser@zscout.de> |
|
13 | 13 | # Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu> |
|
14 | 14 | # |
|
15 | 15 | # Distributed under the terms of the Modified BSD License. |
|
16 | 16 | # |
|
17 | 17 | # The full license is in the file COPYING.txt, distributed with this software. |
|
18 | 18 | #----------------------------------------------------------------------------- |
|
19 | 19 | |
|
20 | 20 | #----------------------------------------------------------------------------- |
|
21 | 21 | # Minimal Python version sanity check |
|
22 | 22 | #----------------------------------------------------------------------------- |
|
23 | 23 | |
|
24 | 24 | import sys |
|
25 | 25 | |
|
26 | 26 | # This check is also made in IPython/__init__, don't forget to update both when |
|
27 | 27 | # changing Python version requirements. |
|
28 | 28 | if sys.version[0:3] < '2.6': |
|
29 | 29 | error = """\ |
|
30 | 30 | ERROR: 'IPython requires Python Version 2.6 or above.' |
|
31 | 31 | Exiting.""" |
|
32 | 32 | print >> sys.stderr, error |
|
33 | 33 | sys.exit(1) |
|
34 | 34 | |
|
35 | 35 | # At least we're on the python version we need, move on. |
|
36 | 36 | |
|
37 | 37 | #------------------------------------------------------------------------------- |
|
38 | 38 | # Imports |
|
39 | 39 | #------------------------------------------------------------------------------- |
|
40 | 40 | |
|
41 | 41 | # Stdlib imports |
|
42 | 42 | import os |
|
43 | 43 | import shutil |
|
44 | 44 | |
|
45 | 45 | from glob import glob |
|
46 | 46 | |
|
47 | 47 | # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly |
|
48 | 48 | # update it when the contents of directories change. |
|
49 | 49 | if os.path.exists('MANIFEST'): os.remove('MANIFEST') |
|
50 | 50 | |
|
51 | 51 | from distutils.core import setup |
|
52 | 52 | |
|
53 | 53 | # Our own imports |
|
54 | 54 | from IPython.utils.path import target_update |
|
55 | 55 | |
|
56 | 56 | from setupbase import ( |
|
57 | 57 | setup_args, |
|
58 | 58 | find_packages, |
|
59 | 59 | find_package_data, |
|
60 | 60 | find_scripts, |
|
61 | 61 | find_data_files, |
|
62 | 62 | check_for_dependencies, |
|
63 | 63 | record_commit_info, |
|
64 | 64 | ) |
|
65 | 65 | from setupext import setupext |
|
66 | 66 | |
|
67 | 67 | isfile = os.path.isfile |
|
68 | 68 | pjoin = os.path.join |
|
69 | 69 | |
|
70 | 70 | #----------------------------------------------------------------------------- |
|
71 | 71 | # Function definitions |
|
72 | 72 | #----------------------------------------------------------------------------- |
|
73 | 73 | |
|
74 | 74 | def cleanup(): |
|
75 | 75 | """Clean up the junk left around by the build process""" |
|
76 | 76 | if "develop" not in sys.argv: |
|
77 | 77 | try: |
|
78 | 78 | shutil.rmtree('ipython.egg-info') |
|
79 | 79 | except: |
|
80 | 80 | try: |
|
81 | 81 | os.unlink('ipython.egg-info') |
|
82 | 82 | except: |
|
83 | 83 | pass |
|
84 | 84 | |
|
85 | 85 | #------------------------------------------------------------------------------- |
|
86 | 86 | # Handle OS specific things |
|
87 | 87 | #------------------------------------------------------------------------------- |
|
88 | 88 | |
|
89 | 89 | if os.name == 'posix': |
|
90 | 90 | os_name = 'posix' |
|
91 | 91 | elif os.name in ['nt','dos']: |
|
92 | 92 | os_name = 'windows' |
|
93 | 93 | else: |
|
94 | 94 | print 'Unsupported operating system:',os.name |
|
95 | 95 | sys.exit(1) |
|
96 | 96 | |
|
97 | 97 | # Under Windows, 'sdist' has not been supported. Now that the docs build with |
|
98 | 98 | # Sphinx it might work, but let's not turn it on until someone confirms that it |
|
99 | 99 | # actually works. |
|
100 | 100 | if os_name == 'windows' and 'sdist' in sys.argv: |
|
101 | 101 | print 'The sdist command is not available under Windows. Exiting.' |
|
102 | 102 | sys.exit(1) |
|
103 | 103 | |
|
104 | 104 | #------------------------------------------------------------------------------- |
|
105 | 105 | # Things related to the IPython documentation |
|
106 | 106 | #------------------------------------------------------------------------------- |
|
107 | 107 | |
|
108 | 108 | # update the manuals when building a source dist |
|
109 | 109 | if len(sys.argv) >= 2 and sys.argv[1] in ('sdist','bdist_rpm'): |
|
110 | 110 | import textwrap |
|
111 | 111 | |
|
112 | 112 | # List of things to be updated. Each entry is a triplet of args for |
|
113 | 113 | # target_update() |
|
114 | 114 | to_update = [ |
|
115 | 115 | # FIXME - Disabled for now: we need to redo an automatic way |
|
116 | 116 | # of generating the magic info inside the rst. |
|
117 | 117 | #('docs/magic.tex', |
|
118 | 118 | #['IPython/Magic.py'], |
|
119 | 119 | #"cd doc && ./update_magic.sh" ), |
|
120 | 120 | |
|
121 | 121 | ('docs/man/ipcluster.1.gz', |
|
122 | 122 | ['docs/man/ipcluster.1'], |
|
123 | 123 | 'cd docs/man && gzip -9c ipcluster.1 > ipcluster.1.gz'), |
|
124 | 124 | |
|
125 | 125 | ('docs/man/ipcontroller.1.gz', |
|
126 | 126 | ['docs/man/ipcontroller.1'], |
|
127 | 127 | 'cd docs/man && gzip -9c ipcontroller.1 > ipcontroller.1.gz'), |
|
128 | 128 | |
|
129 | 129 | ('docs/man/ipengine.1.gz', |
|
130 | 130 | ['docs/man/ipengine.1'], |
|
131 | 131 | 'cd docs/man && gzip -9c ipengine.1 > ipengine.1.gz'), |
|
132 | 132 | |
|
133 | 133 | ('docs/man/iplogger.1.gz', |
|
134 | 134 | ['docs/man/iplogger.1'], |
|
135 | 135 | 'cd docs/man && gzip -9c iplogger.1 > iplogger.1.gz'), |
|
136 | 136 | |
|
137 | 137 | ('docs/man/ipython.1.gz', |
|
138 | 138 | ['docs/man/ipython.1'], |
|
139 | 139 | 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz'), |
|
140 | 140 | |
|
141 | 141 | ('docs/man/irunner.1.gz', |
|
142 | 142 | ['docs/man/irunner.1'], |
|
143 | 143 | 'cd docs/man && gzip -9c irunner.1 > irunner.1.gz'), |
|
144 | 144 | |
|
145 | 145 | ('docs/man/pycolor.1.gz', |
|
146 | 146 | ['docs/man/pycolor.1'], |
|
147 | 147 | 'cd docs/man && gzip -9c pycolor.1 > pycolor.1.gz'), |
|
148 | 148 | ] |
|
149 | 149 | |
|
150 | 150 | # Only build the docs if sphinx is present |
|
151 | 151 | try: |
|
152 | 152 | import sphinx |
|
153 | 153 | except ImportError: |
|
154 | 154 | pass |
|
155 | 155 | else: |
|
156 | 156 | # The Makefile calls the do_sphinx scripts to build html and pdf, so |
|
157 | 157 | # just one target is enough to cover all manual generation |
|
158 | 158 | |
|
159 | 159 | # First, compute all the dependencies that can force us to rebuild the |
|
160 | 160 | # docs. Start with the main release file that contains metadata |
|
161 | 161 | docdeps = ['IPython/core/release.py'] |
|
162 | 162 | # Inculde all the reST sources |
|
163 | 163 | pjoin = os.path.join |
|
164 | 164 | for dirpath,dirnames,filenames in os.walk('docs/source'): |
|
165 | 165 | if dirpath in ['_static','_templates']: |
|
166 | 166 | continue |
|
167 | 167 | docdeps += [ pjoin(dirpath,f) for f in filenames |
|
168 | 168 | if f.endswith('.txt') ] |
|
169 | 169 | # and the examples |
|
170 | 170 | for dirpath,dirnames,filenames in os.walk('docs/example'): |
|
171 | 171 | docdeps += [ pjoin(dirpath,f) for f in filenames |
|
172 | 172 | if not f.endswith('~') ] |
|
173 |
# then, make them all dependencies for the main |
|
|
174 | # auto-generated as well). | |
|
173 | # then, make them all dependencies for the main html docs | |
|
175 | 174 | to_update.append( |
|
176 |
('docs/dist/i |
|
|
175 | ('docs/dist/index.html', | |
|
177 | 176 | docdeps, |
|
178 | 177 | "cd docs && make dist") |
|
179 | 178 | ) |
|
180 | 179 | |
|
181 | 180 | [ target_update(*t) for t in to_update ] |
|
182 | 181 | |
|
183 | 182 | #--------------------------------------------------------------------------- |
|
184 | 183 | # Find all the packages, package data, and data_files |
|
185 | 184 | #--------------------------------------------------------------------------- |
|
186 | 185 | |
|
187 | 186 | packages = find_packages() |
|
188 | 187 | package_data = find_package_data() |
|
189 | 188 | data_files = find_data_files() |
|
190 | 189 | |
|
191 | 190 | #--------------------------------------------------------------------------- |
|
192 | 191 | # Handle scripts, dependencies, and setuptools specific things |
|
193 | 192 | #--------------------------------------------------------------------------- |
|
194 | 193 | |
|
195 | 194 | # For some commands, use setuptools. Note that we do NOT list install here! |
|
196 | 195 | # If you want a setuptools-enhanced install, just run 'setupegg.py install' |
|
197 | 196 | needs_setuptools = set(('develop', 'sdist', 'release', 'bdist_egg', 'bdist_rpm', |
|
198 | 197 | 'bdist', 'bdist_dumb', 'bdist_wininst', 'install_egg_info', |
|
199 | 198 | 'build_sphinx', 'egg_info', 'easy_install', 'upload', |
|
200 | 199 | )) |
|
201 | 200 | if sys.platform == 'win32': |
|
202 | 201 | # Depend on setuptools for install on *Windows only* |
|
203 | 202 | # If we get script-installation working without setuptools, |
|
204 | 203 | # then we can back off, but until then use it. |
|
205 | 204 | # See Issue #369 on GitHub for more |
|
206 | 205 | needs_setuptools.add('install') |
|
207 | 206 | |
|
208 | 207 | if len(needs_setuptools.intersection(sys.argv)) > 0: |
|
209 | 208 | import setuptools |
|
210 | 209 | |
|
211 | 210 | # This dict is used for passing extra arguments that are setuptools |
|
212 | 211 | # specific to setup |
|
213 | 212 | setuptools_extra_args = {} |
|
214 | 213 | |
|
215 | 214 | if 'setuptools' in sys.modules: |
|
216 | 215 | setuptools_extra_args['zip_safe'] = False |
|
217 | 216 | setuptools_extra_args['entry_points'] = find_scripts(True) |
|
218 | 217 | setup_args['extras_require'] = dict( |
|
219 | 218 | parallel = 'pyzmq>=2.1.4', |
|
220 | 219 | zmq = 'pyzmq>=2.1.4', |
|
221 | doc='Sphinx>=0.3', | |
|
222 | test='nose>=0.10.1', | |
|
220 | doc = 'Sphinx>=0.3', | |
|
221 | test = 'nose>=0.10.1', | |
|
223 | 222 | ) |
|
224 | 223 | requires = setup_args.setdefault('install_requires', []) |
|
225 | 224 | setupext.display_status = False |
|
226 | 225 | if not setupext.check_for_readline(): |
|
227 | 226 | if sys.platform == 'darwin': |
|
228 | 227 | requires.append('readline') |
|
229 | 228 | elif sys.platform.startswith('win') and sys.maxsize < 2**32: |
|
230 | 229 | # only require pyreadline on 32b Windows, due to 64b bug in pyreadline: |
|
231 | 230 | # https://bugs.launchpad.net/pyreadline/+bug/787574 |
|
232 | 231 | requires.append('pyreadline') |
|
233 | 232 | else: |
|
234 | 233 | pass |
|
235 | 234 | # do we want to install readline here? |
|
236 | 235 | |
|
237 | 236 | # Script to be run by the windows binary installer after the default setup |
|
238 | 237 | # routine, to add shortcuts and similar windows-only things. Windows |
|
239 | 238 | # post-install scripts MUST reside in the scripts/ dir, otherwise distutils |
|
240 | 239 | # doesn't find them. |
|
241 | 240 | if 'bdist_wininst' in sys.argv: |
|
242 | 241 | if len(sys.argv) > 2 and \ |
|
243 | 242 | ('sdist' in sys.argv or 'bdist_rpm' in sys.argv): |
|
244 | 243 | print >> sys.stderr, "ERROR: bdist_wininst must be run alone. Exiting." |
|
245 | 244 | sys.exit(1) |
|
246 | 245 | setup_args['scripts'] = [pjoin('scripts','ipython_win_post_install.py')] |
|
247 |
setup_args['options'] = {"bdist_wininst": |
|
|
246 | setup_args['options'] = {"bdist_wininst": | |
|
247 | {"install_script": | |
|
248 | "ipython_win_post_install.py"}} | |
|
248 | 249 | else: |
|
249 | 250 | # If we are running without setuptools, call this function which will |
|
250 | 251 | # check for dependencies an inform the user what is needed. This is |
|
251 | 252 | # just to make life easy for users. |
|
252 | 253 | check_for_dependencies() |
|
253 | 254 | setup_args['scripts'] = find_scripts(False) |
|
254 | 255 | |
|
255 | 256 | #--------------------------------------------------------------------------- |
|
256 | 257 | # Do the actual setup now |
|
257 | 258 | #--------------------------------------------------------------------------- |
|
258 | 259 | |
|
259 | 260 | setup_args['cmdclass'] = {'build_py': record_commit_info('IPython')} |
|
260 | 261 | setup_args['packages'] = packages |
|
261 | 262 | setup_args['package_data'] = package_data |
|
262 | 263 | setup_args['data_files'] = data_files |
|
263 | 264 | setup_args.update(setuptools_extra_args) |
|
264 | 265 | |
|
265 | 266 | |
|
266 | 267 | if __name__ == '__main__': |
|
267 | 268 | setup(**setup_args) |
|
268 | 269 | cleanup() |
@@ -1,388 +1,388 b'' | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | 2 | """ |
|
3 | 3 | This module defines the things that are used in setup.py for building IPython |
|
4 | 4 | |
|
5 | 5 | This includes: |
|
6 | 6 | |
|
7 | 7 | * The basic arguments to setup |
|
8 | 8 | * Functions for finding things like packages, package data, etc. |
|
9 | 9 | * A function for checking dependencies. |
|
10 | 10 | """ |
|
11 | 11 | from __future__ import print_function |
|
12 | 12 | |
|
13 | 13 | #------------------------------------------------------------------------------- |
|
14 | 14 | # Copyright (C) 2008 The IPython Development Team |
|
15 | 15 | # |
|
16 | 16 | # Distributed under the terms of the BSD License. The full license is in |
|
17 | 17 | # the file COPYING, distributed as part of this software. |
|
18 | 18 | #------------------------------------------------------------------------------- |
|
19 | 19 | |
|
20 | 20 | #------------------------------------------------------------------------------- |
|
21 | 21 | # Imports |
|
22 | 22 | #------------------------------------------------------------------------------- |
|
23 | 23 | import os |
|
24 | 24 | import sys |
|
25 | 25 | |
|
26 | 26 | from ConfigParser import ConfigParser |
|
27 | 27 | from distutils.command.build_py import build_py |
|
28 | 28 | from glob import glob |
|
29 | 29 | |
|
30 | 30 | from setupext import install_data_ext |
|
31 | 31 | |
|
32 | 32 | #------------------------------------------------------------------------------- |
|
33 | 33 | # Useful globals and utility functions |
|
34 | 34 | #------------------------------------------------------------------------------- |
|
35 | 35 | |
|
36 | 36 | # A few handy globals |
|
37 | 37 | isfile = os.path.isfile |
|
38 | 38 | pjoin = os.path.join |
|
39 | 39 | |
|
40 | 40 | def oscmd(s): |
|
41 | 41 | print(">", s) |
|
42 | 42 | os.system(s) |
|
43 | 43 | |
|
44 | 44 | # A little utility we'll need below, since glob() does NOT allow you to do |
|
45 | 45 | # exclusion on multiple endings! |
|
46 | 46 | def file_doesnt_endwith(test,endings): |
|
47 | 47 | """Return true if test is a file and its name does NOT end with any |
|
48 | 48 | of the strings listed in endings.""" |
|
49 | 49 | if not isfile(test): |
|
50 | 50 | return False |
|
51 | 51 | for e in endings: |
|
52 | 52 | if test.endswith(e): |
|
53 | 53 | return False |
|
54 | 54 | return True |
|
55 | 55 | |
|
56 | 56 | #--------------------------------------------------------------------------- |
|
57 | 57 | # Basic project information |
|
58 | 58 | #--------------------------------------------------------------------------- |
|
59 | 59 | |
|
60 | 60 | # release.py contains version, authors, license, url, keywords, etc. |
|
61 | 61 | execfile(pjoin('IPython','core','release.py')) |
|
62 | 62 | |
|
63 | 63 | # Create a dict with the basic information |
|
64 | 64 | # This dict is eventually passed to setup after additional keys are added. |
|
65 | 65 | setup_args = dict( |
|
66 | 66 | name = name, |
|
67 | 67 | version = version, |
|
68 | 68 | description = description, |
|
69 | 69 | long_description = long_description, |
|
70 | 70 | author = author, |
|
71 | 71 | author_email = author_email, |
|
72 | 72 | url = url, |
|
73 | 73 | download_url = download_url, |
|
74 | 74 | license = license, |
|
75 | 75 | platforms = platforms, |
|
76 | 76 | keywords = keywords, |
|
77 | 77 | cmdclass = {'install_data': install_data_ext}, |
|
78 | 78 | ) |
|
79 | 79 | |
|
80 | 80 | |
|
81 | 81 | #--------------------------------------------------------------------------- |
|
82 | 82 | # Find packages |
|
83 | 83 | #--------------------------------------------------------------------------- |
|
84 | 84 | |
|
85 | 85 | def add_package(packages,pname,config=False,tests=False,scripts=False, |
|
86 | 86 | others=None): |
|
87 | 87 | """ |
|
88 | 88 | Add a package to the list of packages, including certain subpackages. |
|
89 | 89 | """ |
|
90 | 90 | packages.append('.'.join(['IPython',pname])) |
|
91 | 91 | if config: |
|
92 | 92 | packages.append('.'.join(['IPython',pname,'config'])) |
|
93 | 93 | if tests: |
|
94 | 94 | packages.append('.'.join(['IPython',pname,'tests'])) |
|
95 | 95 | if scripts: |
|
96 | 96 | packages.append('.'.join(['IPython',pname,'scripts'])) |
|
97 | 97 | if others is not None: |
|
98 | 98 | for o in others: |
|
99 | 99 | packages.append('.'.join(['IPython',pname,o])) |
|
100 | 100 | |
|
101 | 101 | def find_packages(): |
|
102 | 102 | """ |
|
103 | 103 | Find all of IPython's packages. |
|
104 | 104 | """ |
|
105 | 105 | packages = ['IPython'] |
|
106 | 106 | add_package(packages, 'config', tests=True, others=['profile']) |
|
107 | 107 | add_package(packages, 'core', tests=True) |
|
108 | 108 | add_package(packages, 'extensions') |
|
109 | 109 | add_package(packages, 'external') |
|
110 | 110 | add_package(packages, 'external.argparse') |
|
111 | 111 | add_package(packages, 'external.decorator') |
|
112 | 112 | add_package(packages, 'external.decorators') |
|
113 | 113 | add_package(packages, 'external.guid') |
|
114 | 114 | add_package(packages, 'external.Itpl') |
|
115 | 115 | add_package(packages, 'external.mglob') |
|
116 | 116 | add_package(packages, 'external.path') |
|
117 | 117 | add_package(packages, 'external.pexpect') |
|
118 | 118 | add_package(packages, 'external.pyparsing') |
|
119 | 119 | add_package(packages, 'external.simplegeneric') |
|
120 | 120 | add_package(packages, 'external.ssh') |
|
121 | 121 | add_package(packages, 'kernel') |
|
122 | 122 | add_package(packages, 'frontend') |
|
123 | 123 | add_package(packages, 'frontend.qt') |
|
124 | 124 | add_package(packages, 'frontend.qt.console', tests=True) |
|
125 | 125 | add_package(packages, 'frontend.terminal', tests=True) |
|
126 | 126 | add_package(packages, 'lib', tests=True) |
|
127 | 127 | add_package(packages, 'parallel', tests=True, scripts=True, |
|
128 | 128 | others=['apps','engine','client','controller']) |
|
129 | 129 | add_package(packages, 'quarantine', tests=True) |
|
130 | 130 | add_package(packages, 'scripts') |
|
131 | 131 | add_package(packages, 'testing', tests=True) |
|
132 | 132 | add_package(packages, 'testing.plugin', tests=False) |
|
133 | 133 | add_package(packages, 'utils', tests=True) |
|
134 | 134 | add_package(packages, 'zmq') |
|
135 | 135 | add_package(packages, 'zmq.pylab') |
|
136 | 136 | add_package(packages, 'zmq.gui') |
|
137 | 137 | return packages |
|
138 | 138 | |
|
139 | 139 | #--------------------------------------------------------------------------- |
|
140 | 140 | # Find package data |
|
141 | 141 | #--------------------------------------------------------------------------- |
|
142 | 142 | |
|
143 | 143 | def find_package_data(): |
|
144 | 144 | """ |
|
145 | 145 | Find IPython's package_data. |
|
146 | 146 | """ |
|
147 | 147 | # This is not enough for these things to appear in an sdist. |
|
148 | 148 | # We need to muck with the MANIFEST to get this to work |
|
149 | 149 | package_data = { |
|
150 | 150 | 'IPython.config.profile' : ['README', '*/*.py'], |
|
151 | 151 | 'IPython.testing' : ['*.txt'], |
|
152 | 152 | } |
|
153 | 153 | return package_data |
|
154 | 154 | |
|
155 | 155 | |
|
156 | 156 | #--------------------------------------------------------------------------- |
|
157 | 157 | # Find data files |
|
158 | 158 | #--------------------------------------------------------------------------- |
|
159 | 159 | |
|
160 | 160 | def make_dir_struct(tag,base,out_base): |
|
161 | 161 | """Make the directory structure of all files below a starting dir. |
|
162 | 162 | |
|
163 | 163 | This is just a convenience routine to help build a nested directory |
|
164 | 164 | hierarchy because distutils is too stupid to do this by itself. |
|
165 | 165 | |
|
166 | 166 | XXX - this needs a proper docstring! |
|
167 | 167 | """ |
|
168 | 168 | |
|
169 | 169 | # we'll use these a lot below |
|
170 | 170 | lbase = len(base) |
|
171 | 171 | pathsep = os.path.sep |
|
172 | 172 | lpathsep = len(pathsep) |
|
173 | 173 | |
|
174 | 174 | out = [] |
|
175 | 175 | for (dirpath,dirnames,filenames) in os.walk(base): |
|
176 | 176 | # we need to strip out the dirpath from the base to map it to the |
|
177 | 177 | # output (installation) path. This requires possibly stripping the |
|
178 | 178 | # path separator, because otherwise pjoin will not work correctly |
|
179 | 179 | # (pjoin('foo/','/bar') returns '/bar'). |
|
180 | 180 | |
|
181 | 181 | dp_eff = dirpath[lbase:] |
|
182 | 182 | if dp_eff.startswith(pathsep): |
|
183 | 183 | dp_eff = dp_eff[lpathsep:] |
|
184 | 184 | # The output path must be anchored at the out_base marker |
|
185 | 185 | out_path = pjoin(out_base,dp_eff) |
|
186 | 186 | # Now we can generate the final filenames. Since os.walk only produces |
|
187 | 187 | # filenames, we must join back with the dirpath to get full valid file |
|
188 | 188 | # paths: |
|
189 | 189 | pfiles = [pjoin(dirpath,f) for f in filenames] |
|
190 | 190 | # Finally, generate the entry we need, which is a pari of (output |
|
191 | 191 | # path, files) for use as a data_files parameter in install_data. |
|
192 | 192 | out.append((out_path, pfiles)) |
|
193 | 193 | |
|
194 | 194 | return out |
|
195 | 195 | |
|
196 | 196 | |
|
197 | 197 | def find_data_files(): |
|
198 | 198 | """ |
|
199 | 199 | Find IPython's data_files. |
|
200 | 200 | |
|
201 | 201 | Most of these are docs. |
|
202 | 202 | """ |
|
203 | 203 | |
|
204 | 204 | docdirbase = pjoin('share', 'doc', 'ipython') |
|
205 | 205 | manpagebase = pjoin('share', 'man', 'man1') |
|
206 | 206 | |
|
207 | 207 | # Simple file lists can be made by hand |
|
208 | 208 | manpages = filter(isfile, glob(pjoin('docs','man','*.1.gz'))) |
|
209 | 209 | if not manpages: |
|
210 | 210 | # When running from a source tree, the manpages aren't gzipped |
|
211 | 211 | manpages = filter(isfile, glob(pjoin('docs','man','*.1'))) |
|
212 | 212 | igridhelpfiles = filter(isfile, |
|
213 | 213 | glob(pjoin('IPython','extensions','igrid_help.*'))) |
|
214 | 214 | |
|
215 | 215 | # For nested structures, use the utility above |
|
216 | 216 | example_files = make_dir_struct( |
|
217 | 217 | 'data', |
|
218 | 218 | pjoin('docs','examples'), |
|
219 | 219 | pjoin(docdirbase,'examples') |
|
220 | 220 | ) |
|
221 | 221 | manual_files = make_dir_struct( |
|
222 | 222 | 'data', |
|
223 |
pjoin('docs',' |
|
|
223 | pjoin('docs','html'), | |
|
224 | 224 | pjoin(docdirbase,'manual') |
|
225 | 225 | ) |
|
226 | 226 | |
|
227 | 227 | # And assemble the entire output list |
|
228 | 228 | data_files = [ (manpagebase, manpages), |
|
229 | 229 | (pjoin(docdirbase, 'extensions'), igridhelpfiles), |
|
230 | 230 | ] + manual_files + example_files |
|
231 | 231 | |
|
232 | 232 | return data_files |
|
233 | 233 | |
|
234 | 234 | |
|
235 | 235 | def make_man_update_target(manpage): |
|
236 | 236 | """Return a target_update-compliant tuple for the given manpage. |
|
237 | 237 | |
|
238 | 238 | Parameters |
|
239 | 239 | ---------- |
|
240 | 240 | manpage : string |
|
241 | 241 | Name of the manpage, must include the section number (trailing number). |
|
242 | 242 | |
|
243 | 243 | Example |
|
244 | 244 | ------- |
|
245 | 245 | |
|
246 | 246 | >>> make_man_update_target('ipython.1') #doctest: +NORMALIZE_WHITESPACE |
|
247 | 247 | ('docs/man/ipython.1.gz', |
|
248 | 248 | ['docs/man/ipython.1'], |
|
249 | 249 | 'cd docs/man && gzip -9c ipython.1 > ipython.1.gz') |
|
250 | 250 | """ |
|
251 | 251 | man_dir = pjoin('docs', 'man') |
|
252 | 252 | manpage_gz = manpage + '.gz' |
|
253 | 253 | manpath = pjoin(man_dir, manpage) |
|
254 | 254 | manpath_gz = pjoin(man_dir, manpage_gz) |
|
255 | 255 | gz_cmd = ( "cd %(man_dir)s && gzip -9c %(manpage)s > %(manpage_gz)s" % |
|
256 | 256 | locals() ) |
|
257 | 257 | return (manpath_gz, [manpath], gz_cmd) |
|
258 | 258 | |
|
259 | 259 | #--------------------------------------------------------------------------- |
|
260 | 260 | # Find scripts |
|
261 | 261 | #--------------------------------------------------------------------------- |
|
262 | 262 | |
|
263 | 263 | def find_scripts(entry_points=False): |
|
264 | 264 | """Find IPython's scripts. |
|
265 | 265 | |
|
266 | 266 | if entry_points is True: |
|
267 | 267 | return setuptools entry_point-style definitions |
|
268 | 268 | else: |
|
269 | 269 | return file paths of plain scripts [default] |
|
270 | 270 | """ |
|
271 | 271 | if entry_points: |
|
272 | 272 | console_scripts = [ |
|
273 | 273 | 'ipython = IPython.frontend.terminal.ipapp:launch_new_instance', |
|
274 | 274 | 'pycolor = IPython.utils.PyColorize:main', |
|
275 | 275 | 'ipcontroller = IPython.parallel.apps.ipcontrollerapp:launch_new_instance', |
|
276 | 276 | 'ipengine = IPython.parallel.apps.ipengineapp:launch_new_instance', |
|
277 | 277 | 'iplogger = IPython.parallel.apps.iploggerapp:launch_new_instance', |
|
278 | 278 | 'ipcluster = IPython.parallel.apps.ipclusterapp:launch_new_instance', |
|
279 | 279 | 'iptest = IPython.testing.iptest:main', |
|
280 | 280 | 'irunner = IPython.lib.irunner:main' |
|
281 | 281 | ] |
|
282 | 282 | gui_scripts = [ |
|
283 | 283 | 'ipython-qtconsole = IPython.frontend.qt.console.qtconsoleapp:main', |
|
284 | 284 | ] |
|
285 | 285 | scripts = dict(console_scripts=console_scripts, gui_scripts=gui_scripts) |
|
286 | 286 | else: |
|
287 | 287 | parallel_scripts = pjoin('IPython','parallel','scripts') |
|
288 | 288 | main_scripts = pjoin('IPython','scripts') |
|
289 | 289 | scripts = [ |
|
290 | 290 | pjoin(parallel_scripts, 'ipengine'), |
|
291 | 291 | pjoin(parallel_scripts, 'ipcontroller'), |
|
292 | 292 | pjoin(parallel_scripts, 'ipcluster'), |
|
293 | 293 | pjoin(parallel_scripts, 'iplogger'), |
|
294 | 294 | pjoin(main_scripts, 'ipython'), |
|
295 | 295 | pjoin(main_scripts, 'pycolor'), |
|
296 | 296 | pjoin(main_scripts, 'irunner'), |
|
297 | 297 | pjoin(main_scripts, 'iptest') |
|
298 | 298 | ] |
|
299 | 299 | return scripts |
|
300 | 300 | |
|
301 | 301 | #--------------------------------------------------------------------------- |
|
302 | 302 | # Verify all dependencies |
|
303 | 303 | #--------------------------------------------------------------------------- |
|
304 | 304 | |
|
305 | 305 | def check_for_dependencies(): |
|
306 | 306 | """Check for IPython's dependencies. |
|
307 | 307 | |
|
308 | 308 | This function should NOT be called if running under setuptools! |
|
309 | 309 | """ |
|
310 | 310 | from setupext.setupext import ( |
|
311 | 311 | print_line, print_raw, print_status, |
|
312 | 312 | check_for_sphinx, check_for_pygments, |
|
313 | 313 | check_for_nose, check_for_pexpect, |
|
314 | 314 | check_for_pyzmq, check_for_readline |
|
315 | 315 | ) |
|
316 | 316 | print_line() |
|
317 | 317 | print_raw("BUILDING IPYTHON") |
|
318 | 318 | print_status('python', sys.version) |
|
319 | 319 | print_status('platform', sys.platform) |
|
320 | 320 | if sys.platform == 'win32': |
|
321 | 321 | print_status('Windows version', sys.getwindowsversion()) |
|
322 | 322 | |
|
323 | 323 | print_raw("") |
|
324 | 324 | print_raw("OPTIONAL DEPENDENCIES") |
|
325 | 325 | |
|
326 | 326 | check_for_sphinx() |
|
327 | 327 | check_for_pygments() |
|
328 | 328 | check_for_nose() |
|
329 | 329 | check_for_pexpect() |
|
330 | 330 | check_for_pyzmq() |
|
331 | 331 | check_for_readline() |
|
332 | 332 | |
|
333 | 333 | def record_commit_info(pkg_dir, build_cmd=build_py): |
|
334 | 334 | """ Return extended build command class for recording commit |
|
335 | 335 | |
|
336 | 336 | The extended command tries to run git to find the current commit, getting |
|
337 | 337 | the empty string if it fails. It then writes the commit hash into a file |
|
338 | 338 | in the `pkg_dir` path, named ``.git_commit_info.ini``. |
|
339 | 339 | |
|
340 | 340 | In due course this information can be used by the package after it is |
|
341 | 341 | installed, to tell you what commit it was installed from if known. |
|
342 | 342 | |
|
343 | 343 | To make use of this system, you need a package with a .git_commit_info.ini |
|
344 | 344 | file - e.g. ``myproject/.git_commit_info.ini`` - that might well look like |
|
345 | 345 | this:: |
|
346 | 346 | |
|
347 | 347 | # This is an ini file that may contain information about the code state |
|
348 | 348 | [commit hash] |
|
349 | 349 | # The line below may contain a valid hash if it has been substituted |
|
350 | 350 | # during 'git archive' |
|
351 | 351 | archive_subst_hash=$Format:%h$ |
|
352 | 352 | # This line may be modified by the install process |
|
353 | 353 | install_hash= |
|
354 | 354 | |
|
355 | 355 | The .git_commit_info file above is also designed to be used with git |
|
356 | 356 | substitution - so you probably also want a ``.gitattributes`` file in the |
|
357 | 357 | root directory of your working tree that contains something like this:: |
|
358 | 358 | |
|
359 | 359 | myproject/.git_commit_info.ini export-subst |
|
360 | 360 | |
|
361 | 361 | That will cause the ``.git_commit_info.ini`` file to get filled in by ``git |
|
362 | 362 | archive`` - useful in case someone makes such an archive - for example with |
|
363 | 363 | via the github 'download source' button. |
|
364 | 364 | |
|
365 | 365 | Although all the above will work as is, you might consider having something |
|
366 | 366 | like a ``get_info()`` function in your package to display the commit |
|
367 | 367 | information at the terminal. See the ``pkg_info.py`` module in the nipy |
|
368 | 368 | package for an example. |
|
369 | 369 | """ |
|
370 | 370 | class MyBuildPy(build_cmd): |
|
371 | 371 | ''' Subclass to write commit data into installation tree ''' |
|
372 | 372 | def run(self): |
|
373 | 373 | build_py.run(self) |
|
374 | 374 | import subprocess |
|
375 | 375 | proc = subprocess.Popen('git rev-parse --short HEAD', |
|
376 | 376 | stdout=subprocess.PIPE, |
|
377 | 377 | stderr=subprocess.PIPE, |
|
378 | 378 | shell=True) |
|
379 | 379 | repo_commit, _ = proc.communicate() |
|
380 | 380 | # We write the installation commit even if it's empty |
|
381 | 381 | cfg_parser = ConfigParser() |
|
382 | 382 | cfg_parser.read(pjoin(pkg_dir, '.git_commit_info.ini')) |
|
383 | 383 | cfg_parser.set('commit hash', 'install_hash', repo_commit) |
|
384 | 384 | out_pth = pjoin(self.build_lib, pkg_dir, '.git_commit_info.ini') |
|
385 | 385 | out_file = open(out_pth, 'wt') |
|
386 | 386 | cfg_parser.write(out_file) |
|
387 | 387 | out_file.close() |
|
388 | 388 | return MyBuildPy |
General Comments 0
You need to be logged in to leave comments.
Login now