Skip to content

Commit 0fd57e8

Browse files
committed
fix: remove sphinx dependency for install
1 parent e8a9d85 commit 0fd57e8

File tree

2 files changed

+60
-65
lines changed

2 files changed

+60
-65
lines changed

Makefile

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,8 @@
55
PYTHON ?= python
66
NOSETESTS ?= nosetests
77

8-
zipdoc:
9-
@echo "Clean documentation directory."
10-
python setup.py clean
11-
@echo "Build documentation.zip..."
12-
python setup.py build_sphinx
13-
@echo "Clean documentation directory."
14-
python setup.py clean
8+
zipdoc: html
9+
zip documentation.zip doc/_build/html
1510

1611
sdist: zipdoc
1712
@echo "Building source distribution..."
@@ -75,6 +70,3 @@ check-before-commit: trailing-spaces html test
7570
@echo "removed spaces"
7671
@echo "built docs"
7772
@echo "ran test"
78-
79-
80-

build_docs.py

Lines changed: 58 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
from distutils.cmd import Command
1919
from distutils.command.clean import clean
2020

21-
# Sphinx import.
22-
from sphinx.setup_command import BuildDoc
23-
2421
_info_fname = pjoin(os.path.dirname(__file__), 'nipype', 'info.py')
2522
INFO_VARS = {}
2623
exec(open(_info_fname, 'rt').read(), {}, INFO_VARS)
@@ -104,61 +101,67 @@ def relative_path(filename):
104101

105102
################################################################################
106103
# Distutils Command class build the docs
107-
class MyBuildDoc(BuildDoc):
108-
""" Sub-class the standard sphinx documentation building system, to
109-
add logics for API generation and matplotlib's plot directive.
110-
"""
111-
112-
def run(self):
113-
self.run_command('api_docs')
114-
# We need to be in the doc directory for to plot_directive
115-
# and API generation to work
116-
"""
117-
os.chdir('doc')
118-
try:
119-
BuildDoc.run(self)
120-
finally:
121-
os.chdir('..')
122-
"""
123-
# It put's the build in a doc/doc/_build directory with the
124-
# above?!?! I'm leaving the code above here but commented out
125-
# in case I'm missing something?
126-
BuildDoc.run(self)
127-
self.zip_docs()
128-
129-
def zip_docs(self):
130-
if not os.path.exists(DOC_BUILD_DIR):
131-
raise OSError, 'Doc directory does not exist.'
132-
target_file = os.path.join('doc', 'documentation.zip')
133-
# ZIP_DEFLATED actually compresses the archive. However, there
134-
# will be a RuntimeError if zlib is not installed, so we check
135-
# for it. ZIP_STORED produces an uncompressed zip, but does not
136-
# require zlib.
137-
try:
138-
zf = zipfile.ZipFile(target_file, 'w',
139-
compression=zipfile.ZIP_DEFLATED)
140-
except RuntimeError:
141-
warnings.warn('zlib not installed, storing the docs '
142-
'without compression')
143-
zf = zipfile.ZipFile(target_file, 'w',
144-
compression=zipfile.ZIP_STORED)
145-
146-
for root, dirs, files in os.walk(DOC_BUILD_DIR):
147-
relative = relative_path(root)
148-
if not relative.startswith('.doctrees'):
149-
for f in files:
150-
zf.write(os.path.join(root, f),
151-
os.path.join(relative, 'html_docs', f))
152-
zf.close()
153-
104+
# Sphinx import.
105+
try:
106+
from sphinx.setup_command import BuildDoc
107+
except:
154108

155-
def finalize_options(self):
156-
""" Override the default for the documentation build
157-
directory.
109+
class MyBuildDoc(BuildDoc):
110+
""" Sub-class the standard sphinx documentation building system, to
111+
add logics for API generation and matplotlib's plot directive.
158112
"""
159-
self.build_dir = os.path.join(*DOC_BUILD_DIR.split(os.sep)[:-1])
160-
BuildDoc.finalize_options(self)
161113

114+
def run(self):
115+
self.run_command('api_docs')
116+
# We need to be in the doc directory for to plot_directive
117+
# and API generation to work
118+
"""
119+
os.chdir('doc')
120+
try:
121+
BuildDoc.run(self)
122+
finally:
123+
os.chdir('..')
124+
"""
125+
# It put's the build in a doc/doc/_build directory with the
126+
# above?!?! I'm leaving the code above here but commented out
127+
# in case I'm missing something?
128+
BuildDoc.run(self)
129+
self.zip_docs()
130+
131+
def zip_docs(self):
132+
if not os.path.exists(DOC_BUILD_DIR):
133+
raise OSError, 'Doc directory does not exist.'
134+
target_file = os.path.join('doc', 'documentation.zip')
135+
# ZIP_DEFLATED actually compresses the archive. However, there
136+
# will be a RuntimeError if zlib is not installed, so we check
137+
# for it. ZIP_STORED produces an uncompressed zip, but does not
138+
# require zlib.
139+
try:
140+
zf = zipfile.ZipFile(target_file, 'w',
141+
compression=zipfile.ZIP_DEFLATED)
142+
except RuntimeError:
143+
warnings.warn('zlib not installed, storing the docs '
144+
'without compression')
145+
zf = zipfile.ZipFile(target_file, 'w',
146+
compression=zipfile.ZIP_STORED)
147+
148+
for root, dirs, files in os.walk(DOC_BUILD_DIR):
149+
relative = relative_path(root)
150+
if not relative.startswith('.doctrees'):
151+
for f in files:
152+
zf.write(os.path.join(root, f),
153+
os.path.join(relative, 'html_docs', f))
154+
zf.close()
155+
156+
157+
def finalize_options(self):
158+
""" Override the default for the documentation build
159+
directory.
160+
"""
161+
self.build_dir = os.path.join(*DOC_BUILD_DIR.split(os.sep)[:-1])
162+
BuildDoc.finalize_options(self)
163+
else:
164+
MyBuildDoc = None
162165

163166
################################################################################
164167
# Distutils Command class to clean

0 commit comments

Comments
 (0)