Skip to content

Commit

Permalink
fix: remove sphinx dependency for install
Browse files Browse the repository at this point in the history
  • Loading branch information
satra committed Aug 14, 2012
1 parent e8a9d85 commit 0fd57e8
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 65 deletions.
12 changes: 2 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@
PYTHON ?= python
NOSETESTS ?= nosetests

zipdoc:
@echo "Clean documentation directory."
python setup.py clean
@echo "Build documentation.zip..."
python setup.py build_sphinx
@echo "Clean documentation directory."
python setup.py clean
zipdoc: html
zip documentation.zip doc/_build/html

sdist: zipdoc
@echo "Building source distribution..."
Expand Down Expand Up @@ -75,6 +70,3 @@ check-before-commit: trailing-spaces html test
@echo "removed spaces"
@echo "built docs"
@echo "ran test"



113 changes: 58 additions & 55 deletions build_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
from distutils.cmd import Command
from distutils.command.clean import clean

# Sphinx import.
from sphinx.setup_command import BuildDoc

_info_fname = pjoin(os.path.dirname(__file__), 'nipype', 'info.py')
INFO_VARS = {}
exec(open(_info_fname, 'rt').read(), {}, INFO_VARS)
Expand Down Expand Up @@ -104,61 +101,67 @@ def relative_path(filename):

################################################################################
# Distutils Command class build the docs
class MyBuildDoc(BuildDoc):
""" Sub-class the standard sphinx documentation building system, to
add logics for API generation and matplotlib's plot directive.
"""

def run(self):
self.run_command('api_docs')
# We need to be in the doc directory for to plot_directive
# and API generation to work
"""
os.chdir('doc')
try:
BuildDoc.run(self)
finally:
os.chdir('..')
"""
# It put's the build in a doc/doc/_build directory with the
# above?!?! I'm leaving the code above here but commented out
# in case I'm missing something?
BuildDoc.run(self)
self.zip_docs()

def zip_docs(self):
if not os.path.exists(DOC_BUILD_DIR):
raise OSError, 'Doc directory does not exist.'
target_file = os.path.join('doc', 'documentation.zip')
# ZIP_DEFLATED actually compresses the archive. However, there
# will be a RuntimeError if zlib is not installed, so we check
# for it. ZIP_STORED produces an uncompressed zip, but does not
# require zlib.
try:
zf = zipfile.ZipFile(target_file, 'w',
compression=zipfile.ZIP_DEFLATED)
except RuntimeError:
warnings.warn('zlib not installed, storing the docs '
'without compression')
zf = zipfile.ZipFile(target_file, 'w',
compression=zipfile.ZIP_STORED)

for root, dirs, files in os.walk(DOC_BUILD_DIR):
relative = relative_path(root)
if not relative.startswith('.doctrees'):
for f in files:
zf.write(os.path.join(root, f),
os.path.join(relative, 'html_docs', f))
zf.close()

# Sphinx import.
try:
from sphinx.setup_command import BuildDoc
except:

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

def run(self):
self.run_command('api_docs')
# We need to be in the doc directory for to plot_directive
# and API generation to work
"""
os.chdir('doc')
try:
BuildDoc.run(self)
finally:
os.chdir('..')
"""
# It put's the build in a doc/doc/_build directory with the
# above?!?! I'm leaving the code above here but commented out
# in case I'm missing something?
BuildDoc.run(self)
self.zip_docs()

def zip_docs(self):
if not os.path.exists(DOC_BUILD_DIR):
raise OSError, 'Doc directory does not exist.'
target_file = os.path.join('doc', 'documentation.zip')
# ZIP_DEFLATED actually compresses the archive. However, there
# will be a RuntimeError if zlib is not installed, so we check
# for it. ZIP_STORED produces an uncompressed zip, but does not
# require zlib.
try:
zf = zipfile.ZipFile(target_file, 'w',
compression=zipfile.ZIP_DEFLATED)
except RuntimeError:
warnings.warn('zlib not installed, storing the docs '
'without compression')
zf = zipfile.ZipFile(target_file, 'w',
compression=zipfile.ZIP_STORED)

for root, dirs, files in os.walk(DOC_BUILD_DIR):
relative = relative_path(root)
if not relative.startswith('.doctrees'):
for f in files:
zf.write(os.path.join(root, f),
os.path.join(relative, 'html_docs', f))
zf.close()


def finalize_options(self):
""" Override the default for the documentation build
directory.
"""
self.build_dir = os.path.join(*DOC_BUILD_DIR.split(os.sep)[:-1])
BuildDoc.finalize_options(self)
else:
MyBuildDoc = None

################################################################################
# Distutils Command class to clean
Expand Down

0 comments on commit 0fd57e8

Please sign in to comment.