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