Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6d22b56

Browse files
committed
Updated to work with current Python docs setup, and added a minimal README.
1 parent 4454a1f commit 6d22b56

2 files changed

Lines changed: 54 additions & 13 deletions

File tree

Mac/OSX/Doc/README

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
In this directory you can build the Python documentation in a form that
2+
is suitable for access with Apple Help Viewer. This will enable the
3+
"Python Documentation" menu entries in the MacPython IDE Help menu.
4+
5+
Unfortunately the procedure to build the docs is not very streamlined.
6+
7+
First, edit setup.py. At the top, edit MAJOR_VERSION and MINOR_VERSION,
8+
and check that DESTDIR makes sense. The documentation will be installed
9+
inside PythonIDE.app.
10+
11+
In DocBuild.initialize_options, set self.download to True if you want to
12+
download the docs. Set it to False if you want to build the docs from
13+
the source tree, but this requires LaTex and lots of other stuff.
14+
Doable, but not easy.
15+
16+
Second, if you want to download the docs you may need to do a couple
17+
more edits. The way the docs are packaged will often change between
18+
major releases. Fiddle DocBuild.downloadDocs to make it do the right
19+
thing (download the docs from python.org, unpack them, rename the
20+
directory to "build/html").
21+
22+
After these edits you should be ready to roll. "pythonw setup.py build"
23+
should download and unpack (or build) the docs. Next, it will do some
24+
magic to make the docs indexable. Finally, it will run the Apple Help
25+
Indexing Tool. (This last step is the reason you must use "pythonw" as
26+
opposed to "python"). Usually it will time out while waiting for AHIT to
27+
do its work. Wait until AHIT is done.
28+
29+
Now you're ready to install with "python setup.py install".
30+
31+
After this is done test your work. Fire up PythonIDE, and check that
32+
Help->Python Documentation brings up the documentation in the Help Viewer.
33+
Also open an IDE edit window, type something like "import sys", select
34+
"import", and use Help->Lookup in Python Documentation to check that the
35+
index has been generated correctly.

Mac/OSX/Doc/setup.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@
2828
import Carbon.File
2929
import time
3030

31+
MAJOR_VERSION='2.4'
32+
MINOR_VERSION='2.4.1'
33+
DESTDIR='/Applications/MacPython-%s/PythonIDE.app/Contents/Resources/English.lproj/PythonDocumentation' % MAJOR_VERSION
34+
3135
class DocBuild(build):
3236
def initialize_options(self):
3337
build.initialize_options(self)
3438
self.build_html = None
3539
self.build_dest = None
36-
self.download = 0
37-
self.doc_version = '2.3b1' # Only needed if download is true
40+
self.download = 1
41+
self.doc_version = MINOR_VERSION # Only needed if download is true
3842

3943
def finalize_options(self):
4044
build.finalize_options(self)
@@ -48,20 +52,22 @@ def spawn(self, *args):
4852

4953
def downloadDocs(self):
5054
workdir = os.getcwd()
51-
url = 'http://www.python.org/ftp/python/doc/%s/html-%s.tgz' % \
55+
# XXX Note: the next strings may change from version to version
56+
url = 'http://www.python.org/ftp/python/doc/%s/html-%s.tar.bz2' % \
5257
(self.doc_version,self.doc_version)
58+
tarfile = 'html-%s.tar.bz2' % self.doc_version
59+
dirname = 'Python-Docs-%s' % self.doc_version
60+
61+
if os.path.exists(self.build_html):
62+
raise RuntimeError, '%s: already exists, please remove and try again' % self.build_html
5363
os.chdir(self.build_base)
5464
self.spawn('curl','-O', url)
65+
self.spawn('tar', '-xjf', tarfile)
66+
os.rename(dirname, 'html')
5567
os.chdir(workdir)
56-
tarfile = 'html-%s.tgz' % self.doc_version
57-
## This no longer works due to name changes
58-
## self.mkpath(self.build_html)
59-
## os.chdir(self.build_html)
60-
## self.spawn('tar', '-xzf', '../' + tarfile)
61-
## os.chdir(workdir)
62-
print "** Please unpack %s" % os.path.join(self.build_base, tarfile)
63-
print "** Unpack the files into %s" % self.build_html
64-
raise RuntimeError, "You need to unpack the docs manually"
68+
## print "** Please unpack %s" % os.path.join(self.build_base, tarfile)
69+
## print "** Unpack the files into %s" % self.build_html
70+
## raise RuntimeError, "You need to unpack the docs manually"
6571

6672
def buildDocsFromSource(self):
6773
srcdir = '../../..'
@@ -173,7 +179,7 @@ def finalize_options(self):
173179
build_cmd = self.get_finalized_command('build')
174180
self.build_dest = build_cmd.build_dest
175181
if self.install_doc == None:
176-
self.install_doc = os.path.join(self.prefix, 'Resources/Python.app/Contents/Resources/English.lproj/PythonDocumentation')
182+
self.install_doc = os.path.join(self.prefix, DESTDIR)
177183
print 'INSTALL', self.build_dest, '->', self.install_doc
178184

179185
def run(self):

0 commit comments

Comments
 (0)